I have an angular form that I need to test and I want to select an item without an identity, via its textnode contents. In jquery and selenium on other platforms, I was able to use a special css selector called :contains() which allows me to find stuff
ptor.findElement(protractor.By.css('label:contains(\'some text\') > input')).getAttribute('value').then(function (value) {
expect(value).toContain('myExpectedValue');
});
When I run this I get a lexical error about invalid string. I've tried a variety of ways to escape the quotes in the string. I have also tried an xpath expression, which did the same thing after introducing quotes. It looked something like this:
ptor.findElement(protractor.By.xpath('//label[text()="some text"]/descendant::input[1])')).getAttribute('value').then(function (value) {
expect(value).toContain('myExpectedValue');
});
That failed the same way.
1: Is the :contains selenium function available in protractor?
2: Am I escaping my strings wrong?
Please don't tell me to attach an identity to the object. I am not allowed to modify the markup.