Cynthia
Cynthia

Reputation: 27

How to locate element by span value in protractor?

I have a drop down box and I want to locate element by span value. How to do this? I don't want to use xpath as it is not a best practice.

enter image description here

Upvotes: 1

Views: 5960

Answers (1)

yong
yong

Reputation: 13712

Option 1

element(by.cssContainingText('span.mat-option-text', '100'))

Option 2

element(by.xpath('//span[@class="mat-option-text"][text()="100"]'))

Upvotes: 4

Related Questions