Unable to locate element by div class

975 Views Asked by At

Trying to check if the element set focus to using class header matching by text and getting error unable to locate the element. I know the header title which is 'My Details' in this example, and using this title, how to locate the element?

<div class="attribute-group-header card__header">
<h3 class="attribute-group-title card__header-title">My Details</h3>
</div>


 Element should be focused      //div[contains(.,'My Details')
2

There are 2 best solutions below

1
On BEST ANSWER

To locate the h3 in your example code, use this xpath //h3[contains(text(),'My Details')]

To locate the div which has card__header in class, use this xpath //div[contains(@class,'card__header')]

0
On

It worked fine with this keyword and the X-path reference. Thank you all for guiding me to find the solution

 Element should be enabled     //h3[contains(text(),'${MyLinkText}')]