Reputation: 65
I have a situation in my web application where some listed items do share common className that is used by our automated test suites. Now, I have to click on specific element and need to locate it by it's class and text of that element.
Here is an example:
<ul>
<li class="autotest-list">Milk</li>
<li class="autotest-list">Sugar</li>
<li class="autotest-list">Candy</li>
</ul>
I need a way how to click on ie.Sugar. Something like this:
element(by.className('autotest-list').text('Sugar');
or this
element(by.className('autotest-list')&&text('Sugar');
Thank you all in advance!
Upvotes: 0
Views: 1646
Reputation: 18799
If you don't mind, you could use by.xpath
:
element(by.xpath('li[@class="auto test-list" and text()="Sugar"]'))
Upvotes: 0