Reputation: 21
While running code for clicking the checkbox, I am observing the time out exception.
I have waited with time.sleep(80)
, but did not work
def __init__(self, driver):
self.driver = driver
def filterclick(self):
try:
element=WebDriverWait(self.driver,80).until(EC.presence_of_element_located((By.XPATH,"//input[@class='select-all']")))
element.click()
finally:
self.driver.close()
I want to check the check box, but getting time out exception
HtMl code for check box:
Upvotes: 0
Views: 161
Reputation: 27
try using element_to_be_clickable method in place of presence_of_element_located.
try:
wait = WebDriverWait(self.driver, 80)
element =
wait.until(EC.element_to_be_clickable((By.XPATH,"//input[@class='select-
all']")))
element.click()
finally:
self.driver.close()
Most probably this will work, if it doesn't you can try using implicit wait. I had faced a similar issue as well but it worked on using time.sleep function. Since you have already tried time.sleep(secs) try to use the implicit wait.
Here's how you can use it:
self.driver.implicitly_wait(4)
element = find_element_by_xpath("//input[@class='select-all']")
element.click()
I suggest using the 'wait' variable as you can reuse it somewhere else, you won't have to retype all that. For implicit wait, you can alter the wait duration as per your choice.
Upvotes: 0
Reputation: 1789
Check if element is not at all visible. If that is the case then it will raise Timeout Exception.
OR you can try the following
element = driver.find_element_by_xpath("//input[@class='select-all']")
element.location_once_scrolled_into_view
element.click()
Upvotes: 1