简体   繁体   English

Selenium点击元素仅在调试模式下有效

[英]Selenium click on elements works only in debug mode

I've created a test that click on an element X. 我创建了一个单击元素X的测试。
This element is only revealed after you click on another button, 只有在您点击另一个按钮后才显示此元素,
and those elements are connected with ng-hide . 这些元素与ng-hide连接。

When i try to run my code the click on X element doesn't work. 当我尝试运行我的代码时,单击X元素不起作用。
However, in debug mode or after adding 1 second sleep, it does. 但是,在调试模式下或添加1秒睡眠后,确实如此。

I'm using selenium framework in python, with a remote webdriver with ImplicitlyWait of 10 sec. 我在python中使用selenium框架,使用ImplicitlyWait为10秒的远程webdriver。

Does someone knows the reason for this behavior? 有人知道这种行为的原因吗?

As said by @Siking, this is clearly a timing issue. 正如@Siking所说,这显然是一个时间问题。

The fact is that Selenium is very fast and faster than loading of element. 事实是,Selenium比元素的加载速度更快,速度更快。 Sometimes, Selenium requires a pause or a sleep to ensure that an element is present. 有时,Selenium需要暂停或睡眠以确保元素存在。

I also recommend -especially for asynchronous requests- using waitForElementPresent to wait until ajax method is finished. 我还建议 - 特别是对于异步请求 - 使用waitForElementPresent等待ajax方法完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM