Selenium - Cannot Click On Hidden Element
I am working with Selenium and Python. I am struggling to use the click() method in order to click a dynamically created radio button. The markup for the radio is below.
Solution 1:
try explicit condition
to wait for the element to be displayed. (if it is time-related issue, i.e., takes time to display)
element = WebDriverWait(driver, 10).until(
EC.visibility_of_element_located((By.XPATH, "//*[@id='radio_1']"))
element.click()
This waits up to 10 seconds before throwing a TimeoutException or if it is present on the DOM of a page and visible, will return it in 0 - 10 seconds. WebDriverWait by default calls the ExpectedCondition every 500 milliseconds until it returns successfully. A successful return is for ExpectedCondition type is Boolean return true or not null return value for all other ExpectedCondition types.
Reference:
Solution 2:
C#
You can use waiter to element to become visible like this:
var element = Waiter.Until(ExpectedConditions.ElementIsVisible(By.Id("ID"))).FirstOrDefault();
Post a Comment for "Selenium - Cannot Click On Hidden Element"