Selenium stating button not found when clearly it exists?

The problem

I came across this issue the other day and with the help of a friendly developer we narrowed this down to a post-back timeout.

Selenium states “[error] Element 100_page1_Page1Information_button1 not found” when clearly the button is there on the screen.

I can click the button and the test can continue but Selenium barfs due apparently not finding the button.

The reason

The command before this one in the script changes a drop down which then does a post back to refresh a list shown on the same page. The problem is that the Selenium test is moving to the next command (push the button) whilst the post-back is still taking place.

The solution

A simple solution exists – slow the selenium playback script down. Re-run the test and the next step in the script should hopefully occur after the post back has happened.

clip_image004[3]

Comments

# re: Selenium stating button not found when clearly it exists?
Gravatar I have the exact same problem as you but unfortunately, this didn't resolve it. My button is never found when I playback when the instruction works when I run it manually. I've added a big long pause before attempting the click to ensure the button is there, but still nothing. Any ideas?
Left by IDE tester on 1/27/2009 4:30 PM
# re: Selenium stating button not found when clearly it exists?
Gravatar @ IDE tester

Could it be that the window on which this button is present has lost focus somehow? It happened once with me.
Left by shadeslayer on 2/20/2009 11:51 AM
# re: Selenium stating button not found when clearly it exists?
Gravatar Hi,

Yeah - it could be. We had an error very much like that after a pop up opened. We needed to set the script to move over to the new pop up using the page title. If the page is the same then it is more than likely a speed issue or you've used click instead of clickandwait.

thanks for the comments.

Rob
Left by Rob Lambert on 2/20/2009 11:56 AM
# Slowing the playback works for me
Gravatar Slowing the playback works for me - Thanks for the article. I was just going insane. :)
Left by Elvis on 9/8/2009 10:44 PM
# re: Selenium stating button not found when clearly it exists?
Gravatar Glad it helped Elvis.

Another solution is to make sure the step before is a 'wait' step. i.e. click and wait.
Left by RLambert on 9/14/2009 9:16 AM
# re: Selenium stating button not found when clearly it exists?
Gravatar Slowing the script speed will allow the button to be clicked the first time through the loop, all subsequent loops after that will fail with: error: Element //div[8]/div[11]/button[1] not found. Why would the script see the button the first time, but not after that?
Left by Tig on 1/5/2010 6:20 PM
# re: Selenium stating button not found when clearly it exists?
Gravatar Hi Tig,

Not sure on the specific circumstance you have. Try changing the previous step to be a 'clickandwait' command and remove the pause. This seems more maintainable.

I've not seen your issue before and don't know your app so difficult to answer really. Is your data in the same state as before? Have you reset the stack or environment between runs?

Thanks for commenting

Rob..
Left by RLambert on 1/7/2010 10:37 AM

Leave Your Comment

Title*
Name*
Email (never displayed)
 (will show your gravatar)
Url
Comment*

Please add 5 and 8 and type the answer here:

Preview Your Comment.