Home > Back-end >  How to define xpath of button in this case (selenium)
How to define xpath of button in this case (selenium)

Time:10-26

enter image description here

Hi maybe someone helps me, in this case, I need to define XPath of button on this page by selenium and I have a problem ?

span Zaloguj

CodePudding user response:

Please use anyone from below xpath: .

//span[text()='Zaloguj']

And if you find many more then use

(//span[text()='Zaloguj'])[1]

You can give an index according to your best matches

CodePudding user response:

Please use anyone from below xpath:

//span[text()='Zaloguj']

or

//div[@class ='btn btn-login']/span[text()='Zaloguj']

CodePudding user response:

If you do not want to be dependent on text, cause text may change, you can use the below XPath :

//i[@class='icon-login']//following-sibling::span

PS : Please check in the dev tools (Google chrome) if we have unique entry in HTML DOM or not.

Steps to check:

Press F12 in Chrome -> go to element section -> do a CTRL F -> then paste the xpath and see, if your desired element is getting highlighted with 1/1 matching node.

  • Related