I have an application where button Id's keeps on changing.The only thing consistent is the label. EG: the 'Login' label of a button. How can I find a button whose label is 'Login'? an anybody please help me on this?
-
Can you post the markup of the buttonTGH– TGH2013-04-19 05:32:41 +00:00Commented Apr 19, 2013 at 5:32
-
<span class="dijitReset dijitInline dijitButtonText" id="dijit_form_Button_0_label" data-dojo-attach-point="containerNode" unselectable="on"> <span class="dijitReset dijitInline dijitButtonText" id="dijit_form_Button_0_label" data-dojo-attach-point="containerNode" unselectable="on"> Text - Sign Inshravi– shravi2013-04-19 06:02:39 +00:00Commented Apr 19, 2013 at 6:02
-
Try to detect the csspath of the button using firebug. Also check if the login button is present inside a frame.HemChe– HemChe2013-04-19 06:26:58 +00:00Commented Apr 19, 2013 at 6:26
Add a comment
|
1 Answer
Can you use xpath?
//button[text()='EG']
3 Comments
shravi
Hey I tried with WebElement signin_button= driver.findElement(By.xpath("//button[text()='Sign In']")); but it did not workout :(
Arran
Of course the above XPath won't work because you are getting your HTML elements mixed up. You originally told us it's a
button, thus @TGH has given his solution above, which would work. What you've actually shown us, is a span (assume it is a span just styled to look like a button). So what is it exactly that you are trying to do?shravi
I solved that by using:driver.findElement(By.cssSelector("#loginForm>div>table>tbody>tr:nth-child(4)>td>div>span>span>span"));