1

I am new to Selenium IDE.

In my Web application, while playing back the recorded events, some internal id in XPath expression gets changed dynamically.

E.g.: (//*[@id='edit_1_undefined']) in this script, id 1 changes to 2 and so on. So playback failed. I need to update Id in Xpath manually.

Is there any solution to this problem?

dzieciou
10.5k9 gold badges49 silver badges102 bronze badges
asked Apr 23, 2013 at 13:56

3 Answers 3

3

This is the problem with Selenium IDE or any other recorder for that matter. It doesn't deal with dynamic data very well. If you really want to solve this problem without switching tools, you can try to use an xpath with an static anchor that's higher up in the DOM.

For instance, you just start at //*[@id='edit_1_undefined'] and lets assume this element is an input field. Now lets just suppose that this is under a div with a static id of editList. You could do something like this;

//*[@id='editList']/input

That's of course making a few assumptions about your layout, but hopefully that can help.

However, if you wanted to move to a related framework that gives you much more power, the underlying engine for selenium has an open API that many languages implement (Called webdriver). For example, there is watir-webdriver which is a ruby gem that lets you use the selenium engine (Check out http://watirwebdriver.com/). I believe Selenium IDE even lets you 'record' into ruby code directly, though I'm not sure how reliable it is.

answered Apr 23, 2013 at 21:29
2

You've discovered one of the many flaws in automation, especially record n play automation.

Either it make sure the app you are testing never changes its identifiers or you don't use record and replay and use code that can be more 'intelligent'

answered Apr 23, 2013 at 15:50
2

Does the code under test have unique semantic CSS classes you can rely on instead of an ID?

For example, this page has the following HTML for showing an answer <div id="answer-5968" class="answer" data-answerid="5968" >. Instead of searching for this element by its ID, you can rely on class="answer" in your markup.

answered Jul 17, 2013 at 12:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.