简体   繁体   中英

Selenium click on elements works only in debug mode

I've created a test that click on an element X.
This element is only revealed after you click on another button,
and those elements are connected with ng-hide .

When i try to run my code the click on X element doesn't work.
However, in debug mode or after adding 1 second sleep, it does.

I'm using selenium framework in python, with a remote webdriver with ImplicitlyWait of 10 sec.

Does someone knows the reason for this behavior?

As said by @Siking, this is clearly a timing issue.

The fact is that Selenium is very fast and faster than loading of element. Sometimes, Selenium requires a pause or a sleep to ensure that an element is present.

I also recommend -especially for asynchronous requests- using waitForElementPresent to wait until ajax method is finished.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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