I’m having problem automating to type the text in the textbox with variable id’s using Selenium RC with Java. Strange thing is that, the code below worked fine in Selenium RC with C# but not with Java.
selenium.type("xpath=//input[matches(@id,'.*firstName')]", firstName);
worked on Selenium RC with C# but not with Java.
I also tried these options after looking in some stackoverflow posts but it still doesn’t work
xpath=//input[@contains(@id,'firstName')];
xpath=//input[@contains(@id,'.*firstName')];
xpath=//input["id=regexp:.*firstName");
css=input[id^='regexp:.*firstName'];
css=input[id^='firstName']
Here’s the Xpath code for the text box.
<td>
<input type="text" class="textboxbase" id="mymainfirstgenid_13_mainsecond:firstName" style= "width:160px; "tabindex="0">
</td>
I used (.*) as regular expression for the variable id in Selenium C# which works fine but doesn’t work in Java. Also i can’t use class and name as parameters because they are same for all the fields. Only each element has variable id’s.
Any help would be highly appreciated.
is for the BEGINNING of a string.
For the end of a string use this: