-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling cssContainingText to search for subelements results in "Invalid locator" error #948
Comments
Why not just: expect(element.all(by.cssContainingText('tbody tr','my text')).
count()).toBe(10); Or if your prefer element.all(by.cssContainingText('tbody tr','my text')).then(function(rows) {
expect(rows.length).toBe(10);
}); |
The above was a simple example. In practice:
So I would want to call:
And then in the question page object:
Where this.element represents the question returned in the first code block. This can't be represented with a single query as I'm doing a 'contains' at both level, and I want to split it out to better structure the page objects. An aside: I'd actually prefer to do an exact match on the trimmed value of element (rather than a contains), but that's a separate question/issue that I guess will lead to me extending webdriver. I would still like to be able to make use of cssContainingText as shown in the example above. |
We've moved away from webdriver's use of FindElement/FindElements to element()/elements.all() to better support page objects: If you change all your FindElements, everything should work as intended. Also, you don't need to call |
Thanks @hankduan - I got it working in this way and will close the issue. |
#52 discusses chaining findElement to find child elements.
As discussed in that issue, I can see that this works:
It also works to call protractor.By.cssContainingText in place of the first locator.
But if I change it to:
then I get "TypeError: Invalid locator".
Is this expected behaviour? Would be great to be able to use cssContainingText in this way.
The text was updated successfully, but these errors were encountered: