Reputation: 42474
Here is my code
driver.findElements(By.cssSelector(".main-menu a:contains(\"Access Menu\")")).size()
is throwing exception
org.openqa.selenium.InvalidElementStateException: invalid element state: SyntaxError: DOM Exception 12
Same css value is working in jquery i.e. $(".main-menu a:contains(\"Access Menu\")").size()
Upvotes: 0
Views: 3620
Reputation: 1251
Is it possible to have your html of your <a>
?
Because the DOM Exception 12
is generally a trouble with your html syntax. Maybe the jQuery
don't care about but the WebDriver
throws an exception.
Edit (after BoltClock intervention):
There is another solution instead of using the CssSelector, the xpath !
"//*[@class='.main-menu']/a[contains(text(),'Access Menu')]"
Tell me what's up.
Upvotes: 1