Search code examples
pythonpython-3.xselenium-webdriverselenium-chromedriver

Unable to Find Webpage Element in Form using Selenium


I am attempting to enter text into the Address search field on this website - https://www.verizon.com/business/products/internet/#lq

From the inspection, the element appears to be in a form that I am not familiar with accessing using the XPATH. Here is the code snippet I am currently attempting; I've tried multiple IDs with no success -

driver.get("https://www.verizon.com/business/products/internet/#lq")
time.sleep(5)
address_input5 = wait.until(EC.element_to_be_clickable((By.XPATH, "//input[@id='cln96qoj400be35cyp7u0ckuz']")))
address_input5.clear()
address_input5.send_keys(address)
address_input5.send_keys(Keys.RETURN)
time.sleep(5)

And the inspection snippet -

Should I be using a different method than XPATH to select this element?

UPDATE #2

#.gTCII .form-group input[name="lq-widget-street-Address"]

address_input5 = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[name="lq-widget-street-Address"]')))
address_input5 = wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'input[data-testid="test-input"]')))```

Solution

  • You can use "css selector", 'input[data-testid="test-input"]', to locate that input field.

    The CSS selector is cleaner and not a changing auto-generated selector. It's easy to verify in the console output: