Current value of href for the login button on this website: https://www.firmex.com is provided below:

<a href="https://login.firmex.com/?utm_campaign=login_button_on_firmex&amp;utm_source=firmex.com&amp;utm_medium=login_button%20&amp;_ga=2.239553475.1528002918.1522096243-201959362.1514578998" >

What would be the correct xpath for this href. I have used the following value:

driver.findElement(By.xpath("//a[@href='https://login.firmex.com/?utm_campaign=login_button_on_firmex&amp;utm_source=firmex.com&amp;utm_medium=login_button%20&amp;_ga=2.239553475.1528002918.1522096243-201959362.1514578998']")).click();

Any inputs would be appreciated.

New contributor
Nivesh Kotian is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
up vote 1 down vote accepted

You should use this as a xpath locator to locate the login button for this website:

xpath = //a[@class='button login']

This should remain consistent unlike the href that would change as it apparently is appending the GA cookie value (_ga=something) in the href value.

Thanks!

  • Just to be a bit more error proof I would suggest the following xpath expression: //nav[@id='site-navigation']/a[@class='button login'] as the navigation pane seems to have solid id. – Bence Kaulics Dec 8 at 19:09
  • Thanks @Bence Kaulics...this worked perfectly well. Much appreciate your help :) – Nivesh Kotian Dec 8 at 19:50

Your Answer

Nivesh Kotian is a new contributor. Be nice, and check out our Code of Conduct.

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.