Search code examples
robotframeworkselenium2library

Unable to locate element by div class


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')

Solution

  • 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')]