0

I need to click on property by name Émilie's Castle location, but I can not locate by text the name:

<div class="text capitalize">
      <div class="name truncate">Émilie's Castle location</div>

In selenium ide it works:

css=div.name.truncate:contains(Émilie's Castle location)

In protractor I try to use this line of code but it doesn't work:

element(by.className('name truncate')).click();

I can not use classname because all properties have the same name of class:

<div class="name truncate">

How to locate by text in webdriver and protractor?

Thank you in advance!

1
  • Did my solution work for you?
    – Rakesh
    Nov 4, 2017 at 9:52

1 Answer 1

3

Use below code, it should work:

element(by.cssContainingText('.name.truncate', 'Émilie's Castle location')).click();
3
  • This will work perfectly. See here the API-Description Nov 4, 2017 at 9:15
  • @Rakesh Thanks,yes it works: element(by.cssContainingText('.name','Émilie\'s Castle location')).click();
    – Lelik_
    Nov 6, 2017 at 18:21
  • @Lelik_ Cool..Please accept the solution
    – Rakesh
    Nov 6, 2017 at 18:35

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