79441541

Date: 2025-02-15 12:56:44
Score: 0.5
Natty:
Report link

There are ways to work around this limitation and achieve case-insensitive text search for elements.

  1. 1.Use XPath with translate()

    element = driver.find_element(By.XPATH, '//label[contains(translate(text(), "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"), "username")]')

  2. Find All, Then Filter.

  3. Use JavaScript Execution (execute_script)

    script = """ return Array.from(document.querySelectorAll("*")) .filter(el => el.innerText.toLowerCase().includes("username")); """ elements = driver.execute_script(script)

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: Adel Alaa