[ide] selenium fails with "element not found" error when playing test that was just recorded

6,243 views
Skip to first unread message

pierre tombal

unread,
Feb 8, 2011, 7:14:43 AM2/8/11
to Selenium Users
Greetings selenium users,

I'm getting "Element not found" error when i try to play a test case
recorded second ago using Selenium IDE 1.0.10
Now, even stranger than the fact that Selenium IDE cannot play it's
own recording is that if you highlight the command and click on Find
button, it actually locates the input field successfully.

After browsing through all possible posts and groups with similar
questions i've found that the problem may be the following (found
almost exactly the same post, with no solution unfortunately, from
june 2007):

my input field is hidden deep in the <table><tr><td><table><tr><td>...
and so on structure at least 30 levels deep.
Actually View source code in any browser does not display id for my
field at all.
BUT - firebug on firefox can dig that deep through table and td tags
and shows the proper id that selenium recorded.

So, my conclusion is - while recording, Selenium IDE can find field ID
but while playing the recording, it is limited to a certain depth and
cannot find any field that is not in the displayed HTML source code
for the page - or to be more precise, since View source code cannot go
deeper than certain level in the html code, selenium IDE cannot find
the element with recorded ID. But then again, how does the Find button
manage to locate it in Selenium IDE???

Any ideas? Anyone?

Thanks in advance and please don't hesitate to give any suggestion or.
Well, apart from adding clickandwait that is :)

Cheers,
Pierre

BillR

unread,
Feb 8, 2011, 8:39:33 PM2/8/11
to Selenium Users
Usually this is due to an element having a dynamic tag, e.g. with some
random-looking number in it, generated by javascript. In this case,
IDE is not useful and you have to e.g. craft an xpath that will find
the element by dom structure. In this case I knew that my element was
the second input child of a parent I could id another input child of:

selenium_.click("//input[@value='" + ss[1] + "']/../input[2]");

If you don't get everything you want, think of the things you don't get that you don't want.

unread,
Feb 9, 2011, 12:41:15 AM2/9/11
to Selenium Users
Just Look at concept of Xpath - You should need to identify the
element at dynamically by
- Using mapping it with some other field. e.g - For the user name text
field(Dynamic field) you should have to map it with the user name
lable like in where <TR[1]/ td[1]= Username(lable) enter value in
TR[1]/ td[2] = Input(<User value>)

Or
-You can directly input the value in field like giving exact path as
mentioned in below post.

Thanks
Cheers

Ross Patterson

unread,
Feb 9, 2011, 8:42:58 AM2/9/11
to seleniu...@googlegroups.com
Yeah, Bill is right - record and playback scenarios that don't work are often the result of ID values that aren't constants, especially when the application uses a UI toolkit (e.g., GWT, YUI, extJs).

And to set your mind at ease, there isn't any sort of depth limitation. I've seen some really deep XPath locators, similar to yours.

Ross

Brian Kitchener

unread,
Feb 9, 2011, 4:49:07 PM2/9/11
to Selenium Users
I'm going to disagree with everyone here. If your script doesn't play
back, but you can find the element with the "Find" button, your xpath
is fine. It means one of two things:

Option 1 : your script isn't waiting long enough. Insert a
waitForVisible command before your failed test, using the same
locator.

Option 2 : you have the wrong frame selected when the command fires.
Perhaps there is a selectFrame command somewhere in the script
earlier. To test this, insert a selectWindow("null") before your
failed step.

These are common problems with recording tests with the IDE.

pierre tombal

unread,
Feb 10, 2011, 2:34:32 AM2/10/11
to Selenium Users
Thanks a lot to everyone who took their time to reply to this post.
I really appreciate the fact that you guys tried to help.

I'll try Brian suggestion and go with waitForVisible and let you know
how it went (It is definitely not dynamic since Firebug always finds
it with the same name as Selenium IDE recorded it).

Btw. If i move the slider on Selenium IDE to slow (it was on fast)
then it works correctly.

So, thanks again and i'll post my results tomorrow.

Cheers

pierre tombal

unread,
Feb 10, 2011, 5:41:38 PM2/10/11
to Selenium Users
Yep, waitForVisible works.

Thanks guys, case closed.

Krishnan Rengarajan

unread,
Aug 6, 2013, 9:03:59 AM8/6/13
to seleniu...@googlegroups.com
yipeee thanks a lot Brian!!!! :)

guruna...@assetvantage.com

unread,
Nov 15, 2013, 12:15:29 AM11/15/13
to seleniu...@googlegroups.com
waitForVisible is working fine and perfect...

Sumedha

unread,
Oct 22, 2014, 4:44:14 PM10/22/14
to seleniu...@googlegroups.com
Hello Brian
 
I realize that this post is closed. Let me know if I need to create a new post.
 
I have recently started using Selenium and while playing back my recorded script, it keeps failing for the following reason. I have already used waitforVisible, but that did not help. Can you tell me what I'm missing here?
 
  • [info] Executing: |waitForVisible | | |
  • [error] Timed out after 30000ms
  • [info] Executing: |click | //div[@id='module-scroll-container']/div/div/div/div/div/div | |
 
I do not see that the attribute above is dynamic. Where/How can I check if an object is dynamic?
 
Would you be able to assist me?
 
Thanks!
-Sumedha.
Reply all
Reply to author
Forward
0 new messages