2

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.

1 Answer 1

1

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!

2
  • 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. Dec 8, 2018 at 19:09
  • Thanks @Bence Kaulics...this worked perfectly well. Much appreciate your help :) Dec 8, 2018 at 19:50

Your Answer

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

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