1

Below is my DOM.

<div class="clickable ng-binding ng-scope" ng-click="controller.selectElement(tab, detail)" ng-class="{active:(detail===(tab.selectedElement || (tab.selectedElements && tab.selectedElements[detail.property])))}" ng-repeat="detail in tab.selectedSource.detail | orderBy:'title'">
<!-- ngIf: tab.label ==='Table Data' -->
                                    City                                 
</div>

Can anyone tell me how to locate element in xpath by text for the above DOM. I'm specific to locate element by text because the text between the tags are only thing which is unique.

I Tried Below Xpath.

//div[contains(text(),'City')], 

//div[text()='City']

Please advice.

Thanks.

1 Answer 1

1

Try using . instead of text() as below :-

//div[contains(.,'City')]

or

//div[normalize-space(.) = 'City']

Hope it helps...:)

Sign up to request clarification or add additional context in comments.

2 Comments

@sudheendranPL you welcome..Glad to help you..Please accept the answer by click on check mark beside the answer if it helped..meta.stackexchange.com/questions/5234/…)
Accepted :) Thank you.:)

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.