Home > Software engineering >  Why won't Selenium (Python) click() or send_keys() to this textarea? (TimeoutException)
Why won't Selenium (Python) click() or send_keys() to this textarea? (TimeoutException)

Time:08-29

I've been working with this online form and having no problems getting Selenium to click() or send_keys() on other elements. But one element (the "Notes" textarea toward the end of the form) is giving me a TimeoutException, even when I give it a WebDriverWait and the element is clearly present on the page.

Anyone know what's going on? I just want to send_keys() to it, but I've tried also click() first then send_keys(); I'm consistently getting the TimeoutException.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait

chrome_options = webdriver.ChromeOptions()
chrome_options.add_experimental_option("detach", True)

webdriver = webdriver.Chrome(options=chrome_options)

webdriver.get("https://lincdoc.ou.edu/lincdoc/doc/run/ouathletics/OU_AdvisingForm2#ldTimeoutUri")

WebDriverWait(webdriver, 5).until(ec.presence_of_element_located((By.CSS_SELECTOR, "input[id$='8e']"))).send_keys("hi")

CodePudding user response:

Did you try XPATH?

(By.XPATH("//*[@id='gCCP8e']"))

CodePudding user response:

The xpath seems to change on each reload but last two digits of id are always the same, so try this (xpath):

//*/textarea[contains(@id,'8e')]
  • Related