I have a site I need to login to but one of the input text fields id and name change each time. Is there a way to access element via a regex? Thanks in advance.
Example:
id="form:wrap:j_idt1297:0:j_idt1298:input"
id="form:wrap:j_idt2151:0:j_idt2152:input"
<input class="iceInpSecrt large"
id="form:wrap:j_idt1297:0:j_idt1298:input"
name="form:wrap:j_idt1297:0:j_idt1298:input"
onblur="setFocus('');" onfocus="setFocus(this.id);"
onkeyup="iceSubmit(form,this,event);"
onmousedown="this.focus();" tabindex="" type="password" value="">
Yes, you can match elements using regular expressions. It is similar to locating the id/name by string.
It looks like:
browser.text_field(:id => /a_regex/)
For your example, the following would locate the text field with either of the ids mentioned:
browser.text_field(:id => /form:wrap:j_idt\d{4}:0:j_idt\d{4}:input/)
Note:
/form:wrap:j_idt/
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.