0

HTML Tag:

<a href="/candidate/updateprofile.html">
    <span class="no-of-jobs">100%</span>
    <span class="grey-text">Profile Strength</span>
    Update your profile </a>

Earlier when I created the script, it did work:

driver.findElement(By.xpath("//*[contains(@href,'updateprofile')]")).click();

Now it is not clicking on Update your profile

  • Give us a bit more context. It might stop working for hundred different reasons. – Alexey R. May 18 '18 at 11:46
  • Please edit your question with the error you are receiving. – Kate Paulk May 18 '18 at 11:50
  • Check xpath whether it's same as before – Joe May 18 '18 at 11:50
  • xpath you have corresponds to your html. So there could could be two kind of reasons. 1 (unlikely) there are some elements which are not links but which have href attribute with 'updateprofile' value. 2 (likely) your link is not interactable due to some reason by the moment you invoke click method. – Alexey R. May 18 '18 at 11:58
  • Xpaths can be brittle. Minor changes can cause the path to change. If you have an element id to target then I suggest using that. – CaptainKidd May 18 '18 at 13:00
1

Xpath can change on reloading page. Also xpath is given the least priority while locating a web element while providing a web application testing services (automation). Priority should be ID,Class > CSS > Linktext > Partial Text > Xpath.

You can try linktext or partial linktext here. It may help. Below is the syntax

driver.findElement(By.linkText("Update your profile")).click();

OR

driver.findElement(By.partialLinkText("Update")).click();

Hopefully, It will work. If it still fails to click on the element then you need to provide the whole error along with the html page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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