Python selenium:等到元素可点击 - 不工作 [英] Python selenium: wait until element is clickable - not working

查看:48
本文介绍了Python selenium:等到元素可点击 - 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将测试一个网络应用程序.我的表格中有一个按钮可以选择所有条目.我试过了:

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 点击按钮,但没有任何反应.(也使用 send_Keys(Keys.Return))该应用程序是用 GXT 开发的,我认为按钮后面有很多 javascript.是否有可能等到事件加载器准备就绪?等待点击解决问题,但不是自动化测试的解决方案.

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.

推荐答案

python 中显式等待的正确语法是:

Correct syntax for explicit wait in python is :

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

更好的是在上面你做:element.click();

所以在你的情况下:

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();

最好遵循它.还分享您的整个代码,以便我可以更正它.您仅有的 1 行代码不会让人感到困惑.

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

这篇关于Python selenium:等到元素可点击 - 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆