Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protractor: Finding Element by Div Text

I would recommend you to use by.cssContainingText

element(by.cssContainingText('.col-sm-8', 'Account Information'))

There is no webdriver method which would allow locating an element by its text. You could try using xpath in the following way (not tested):

element(by.xpath('//div[contains(text(), "Account Information: ")]')

keep in mind by.cssContainingText matches the element by PARTIAL text

so element(by.cssContainingText('div', 'male')) will actually match both male and female text

To solve this, use xpath with exact text match

element(by.xpath('//div[text()="male"]'))