Prashanth Sams
Prashanth Sams

Reputation: 21129

Why CSS contains() fail to work with Protractor?

In Protractor, the xpath contains[.,''] works all time instead of CSS's contains() feature; is there any cause for such broken functionality? or any tweak to implement it?

Upvotes: 1

Views: 83

Answers (1)

Florent B.
Florent B.

Reputation: 42528

The pseudo class contains is not a CSS feature. It's implemented by external libraries like JQuery or Mootools. To get an element by text, use the locator by.cssContainingText:

var elem = element(by.cssContainingText('div.left', 'my text'));

Upvotes: 4

Related Questions