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
Searching with RelativeLocator does not work #135
Comments
@keinhaar looks like you are reaching some of the not yet implemented corners of the js support. The second more or less says that HtmlUnit DomNodes are not supporting the method lookupPrefix() right now - or that you are the first one using this methods ;-) Usually it is possible to add support for such methods. It will help if you can provide your findElements.js or even more details about your solution to give me the chance to write a unit test. And the bad news at the end... i will be out for the next two weeks - to you need this soon or is it ok to wait a bit? |
Thanks for the fast response. I understand that i can't expect a quick fix. I'm totally fine to wait a bit ;-) |
Ok, looks like i have sufficient info for making a local test case - will inform you about the progress. Thanks a lot for reporting this. |
I'm trying to run my automated tests headless with this driver, but it does not work, because the RelativeLocator seems to have 2 Problems:
a=a.replace(t?/(^|\s|\b)(\S)/g:/(^|[^\d\p{L}\p{S}])([\p{Ll}|\p{S}])/gu
in line 111. htmlunit complains about the invalid flag "u" at the end. I removed it, and the error is gone. Don't know what side effects this will have.WebElement el = driver.findElement(By.xpath("//div[text()='Username']");
works as expected. The error occurs if I useRelativeLocator.with(By.tagName("input")).toRightOf(By.xpath("//div[text()='Username']");
Any help would be great.
org.openqa.selenium.WebDriverException: org.htmlunit.ScriptException: InvalidSelectorError: Unable to locate an element with the xpath expression //div[text()='Username'] because of the following error: TypeError: Cannot find function lookupPrefix in object [object HTMLHtmlElement]. (injected script#91) Build info: version: '4.12.1', revision: '8e34639b11' System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.16.1' Driver info: driver.version: HtmlUnitDriver at org.openqa.selenium.htmlunit.HtmlUnitDriver.executeScript(HtmlUnitDriver.java:841) at org.openqa.selenium.support.locators.RelativeLocator$RelativeBy.findElements(RelativeLocator.java:194) at org.openqa.selenium.By.findElement(By.java:122) at org.openqa.selenium.htmlunit.HtmlUnitElementFinder.findElement(HtmlUnitElementFinder.java:68) at org.openqa.selenium.htmlunit.HtmlUnitDriver.lambda$findElement$8(HtmlUnitDriver.java:713) at org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:1172) at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:713) Caused by: org.htmlunit.ScriptException: InvalidSelectorError: Unable to locate an element with the xpath expression //div[text()='Username'] because of the following error: TypeError: Cannot find function lookupPrefix in object [object HTMLHtmlElement]. (injected script#91) at org.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:996) at org.htmlunit.corejs.javascript.Context.call(Context.java:590) at org.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:484) at org.htmlunit.javascript.HtmlUnitContextFactory.callSecured(HtmlUnitContextFactory.java:348) at org.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:923)
The text was updated successfully, but these errors were encountered: