views:

72

answers:

4

I am trying to create a test that can enter a username and password into a login form on a page. However, the textbox name changes on every load of the page, and so the test stops each time I run it.

How can I set up Selenium IDE so that it can identify the text box across refreshes?

+1  A: 

Does the location of the text box change, or just the name?

You could use a css or xpath selector to get the text box if it is in the same place.

s_hewitt
+2  A: 

//form1 (3) - First form element in the HTML

Pulled from here as an example This is making use of XPath. In theory you can make use of XPath to focus on parsing the structure of the XHTML, however this is fairly fragile, so it's not necessarily a wise thing to do but it should take care of your issue.

Aaron
+4  A: 

I am assuming that the textbox only changes part of the ID and not the entire ID each time.

To work with this I would recommend using xpath like people have put above but make it more robust in that it only find that element each time.

e.g.

//input[contains(@id,'thePartOfTheIdThatNeverChanges')]

or

//input[starts-with(@id,'thePartOfTheIdThatNeverChanges')]

or

//input[ends-with(@id,'thePartOfTheIdThatNeverChanges')]

AutomatedTester
+1  A: 

I would recommend CSS because - a. for the readability b. for the ease of access (and, in your case, maintainability).

I use firebug for accessing/formulating the CSS identifier.

Rajat