Reputation: 5155
I'm trying to run protractor and a jquery selector is returning an error. But it works on my chrome when i try it on console?
I am trying to select "TestE2E" from dropdown menu.
This is what I Tried:
browser.actions().click($( ".portal-list li a:contains(TestE2E)" )).perform()
I have even tried
elements(By.css('.portal-list li a:contains(TestE2E)').click()
I get this error:
✗ Go back to experiences page (0.37 secs)
- InvalidElementStateError: invalid element state: Failed to execute 'querySelectorAll' on 'Document': '.portal-list li a:contains(TestE2E)' is not a valid selector.
(Session info: chrome=44.0.2403.130)
(Driver info: chromedriver=2.10.267517,platform=Mac OS X 10.9.5 x86_64)
How can I fix it? This is my HTML
<div>
<ul><li>
<a href="javascript:void(0);">TestE2E</a>
</li></ul>
</div>
Thanks
Upvotes: 0
Views: 134
Reputation: 3921
How about this instead?
element(by.cssContainingText('.portal-list li a', 'TestE2E').click()
http://www.protractortest.org/#/api?view=ProtractorBy.prototype.cssContainingText
Upvotes: 1