How to handle dynamically updated params in XPath queries in Selenium?
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.
(//*[@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?
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;
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.