Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python selenium: wait until element is clickable - not working

I will test a web-app. there is a button available in my table to select all entries. I've tried:

driver.wait.until(ExpectedCondition.element_to_be_clickable((By.XPATH, "myXpath"))).click() 

selenium clicks on the button, but nothing happens. (also with send_Keys(Keys.Return)) the application is developed with GXT, I thing that there is much javascript behind the button. Is there is possibility to wait until a eventloader is ready? waiting before a click solves the problem, but not a solution for automated testing.

like image 256
Storm Avatar asked Jan 23 '15 12:01

Storm


People also ask

Why is Selenium element not clickable?

This is because the element is present in DOM, but its position is not fixed on the page. Adding the explicit wait. The webdriver can wait till the expected condition - visibilityOf(webdriver shall wait for an element in DOM to be visible). Adding the explicit wait.

Is clickable in Selenium Python?

We can check if the element is clickable or not in Selenium webdriver using synchronization. In synchronization, there is an explicit wait where the driver waits till an expected condition for an element is met. To verify, if the element can be clicked, we shall use the elementToBeClickable condition.

How do you wait until an element is clickable on a website?

Wait until the element's . Displayed property is true (which is essentially what visibilityOfElementLocated is checking for). Wait until the element's . Enabled property is true (which is essentially what the elementToBeClickable is checking for).

How do you get Selenium to wait until the element is present?

We can wait until an element is present in Selenium webdriver. This can be done with the help of synchronization concept. We have an explicit wait condition where we can pause or wait for an element before proceeding to the next step. The explicit wait waits for a specific amount of time before throwing an exception.


1 Answers

Correct syntax for explicit wait in python is :

 element = WebDriverWait(driver, 20).until(  EC.presence_of_element_located((By.ID, "myElement"))) 

Better that After above you do : element.click();

So in your case :

from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC  element = WebDriverWait(driver, 20).until( EC.element_to_be_clickable((By.XPATH, "myXpath")))  element.click(); 

Better you follow it. Also share your whole code so I can correct it. Your just 1 line code doing little confuse.

like image 122
Helping Hands Avatar answered Sep 23 '22 01:09

Helping Hands