1

I am trying to populate form fields in sequence for a test using selenium. I cannot use the name since they are assigned a unique identifer by the back end (no id). Any thoughts on how to tackle this would be greatly appreciated.

<input type="text" class="abc" tabindex="1" size="5" maxlength="15" name="8886456-98245574-3353546773" value="">

The same class names are being used by more than one field in the form.

3
  • 1
    List<WebElement> inputTags=driver.findElements(By.tagName("input")); iterate the list and get all input tags in order. Commented Feb 4, 2013 at 5:25
  • I'll try that today and revert - thank you for sharing. Much appreciated Commented Feb 4, 2013 at 16:48
  • any ideas on how to make it work with Selenium RC and not webdriver? thanks for your earlier feedback - +1 Commented Feb 14, 2013 at 0:35

1 Answer 1

1
int inputTagCount=selenium.getXpathCount("//tr/td/input[@class='abc']");

The above logic will gives you count of input tags which are under tr followed by td tag

in order to find each individual input tag run the above locator in loop

for(int i=0;i<inputTagCount;i++}
{
     selenium.type("//tr["+i+"]/td/input[@class='abc']","test");
}

This is how you need to do in selenium RC

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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.