1

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?

3
  • Can you post the markup of the button Commented 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 In Commented 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. Commented Apr 19, 2013 at 6:26

1 Answer 1

2

Can you use xpath?

//button[text()='EG']
Sign up to request clarification or add additional context in comments.

3 Comments

Hey I tried with WebElement signin_button= driver.findElement(By.xpath("//button[text()='Sign In']")); but it did not workout :(
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?
I solved that by using:driver.findElement(By.cssSelector("#loginForm>div>table>tbody>tr:nth-child(4)>td>div>span>span>span"));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.