Reputation: 317
I want to make a simple script which will create an email account at the url: https://service.mail.com/registration.html
Each time I reload the page, the input text fields have a different ID. How do I locate these elements reliably ? Also, why would someone want to change the ID all the time ?
Example:
<input class="Text ColouredFocus" type="text" value="" name="z1085243925" id="id11b" maxlength="30" onchange="var wcall=wicketAjaxPost('?wicket:interface=:4:FormRegistration:ListRegistrationData:0:ItemRegistrationData:BorderBoxRegistrationData:PanelRegistrationData:Row1:Field::IBehaviorListener:1:', wicketSerialize(Wicket.$('id11b')),function() { }.bind(this),function() { }.bind(this), function() {return Wicket.$('id11b') != null;}.bind(this));" tabindex="1">
Thanks !
Upvotes: 0
Views: 248
Reputation: 474191
You don't have to always use id
or name
attributes. There is an enormous amount of techniques and location strategies. Choosing one sometimes is not that trivial as it might seem.
For instance, in this case, from my perspective, a readable and a reliable way to locate the input fields would be to rely on the class names of the li
parents. Sample for the last name:
driver.findElement(By.cssSelector(".userdata-lastname input"));
Upvotes: 1