Home > Software engineering >  XPath not working for one of the selenium scenario
XPath not working for one of the selenium scenario

Time:10-05

HTML

<div data-testid="signin-back-button" class="white-arrow">
     <a href="/" class="back-text" onclick="backBtnClick()">
         <img class="back-arrow-white" src="/images/arrow-left-white.svg" aria-hidden="true">
              Back
      </a>
</div>

I have written xpath as

//a[@onclick='backBtnClick()']/img[contains(text(),'Back')]

CodePudding user response:

There is not need to rely on text, please use below xpath

//a[@onclick='backBtnClick()']//child::img[contains(@src,'images/arrow-left-white.svg')]

CodePudding user response:

use double slash in your xpath

//a[@onclick='backBtnClick()']//img[contains(text(),'Back')]
  • Related