Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
600 views
in Technique[技术] by (71.8m points)

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.

question from:https://stackoverflow.com/questions/28110008/python-selenium-wait-until-element-is-clickable-not-working

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...