java - Locating Elements with dynamic id -
if have element in page follows (there multiple select elements)
<select size="1" name="j_id0:j_id2:j_id37:j_id38:0:j_id41"> <select size="1" name="j_id0:j_id2:j_id37:j_id38:1:j_id41">
with identifier being name name change dynamically how locate in selenium(java) without referencing name?
i using xpath follows
/html/body/div/div[2]/table/tbody/tr/td[2]/form/div[3]/div/div/div/div[2]/div[1]/span[3]/select
problem being if on page changes xpath break.
are there better alternative ways less broken?
you've correctly noted presented xpath quite fragile. useful see complete html of page, or, @ least, preceding , following elements of select
element. have now, can rely on part of name
attribute:
//select[contains(@name, "j_id")]
Comments
Post a Comment