Closed skyhirider closed 1 year ago
Looks like you have two htmlunit versions in your classpath
I am wondering thou how the application could run once fine, and after I call driver.close() and re-load a new driver again it fails. Its in the same one run, so the class path should remain constant.
@skyhirider Can i close this?
Sorry, did not have time to test it more, I think you can close it. If I find the issue is related to the driver or htmlunit itself I will leave a comment and re-open it.
@rbri I found the issue and it was my mistake.
I imported both htmlunit and the htmlunit-driver into a project, where the browser was 2.65.1 and the driver was 3.64.0
The driver tried to call the old method signature which it could no longer find as the browser on the classpath did not have it.
For any people finding this later, don't be like me, check your maven dependency conflicts in Idea :)
And don't import both driver and browser, the driver is enough in your pom file.
@skyhirider great - have fun using HtmlUnit.
I am using the snapshot version of HtmlUnit and noticed that when I am closing or quitting all drivers and then re-initializing during the same application run I get a NoSuchMethodError.
Running with HtmlUnit 2.64, driver 3.62 and Selenium 4.2.2 works fine and each additional loop works fine.
This is odd, as the first cycle executes the code fine, but after closing and re-running I get this throwable.
Unfortunately I don't have a test case for this one nor any code I can easily share and will test it after the next major version is released to see if it was related to the snapshot build only somehow, but wanted to let you know in case it is obvious for you what could have caused this.
java.lang.NoSuchMethodError: 'com.gargoylesoftware.htmlunit.javascript.host.css.CSS2Properties com.gargoylesoftware.htmlunit.javascript.host.Window.getComputedStyle(java.lang.Object, java.lang.String)' at org.openqa.selenium.htmlunit.HtmlUnitWebElement.getCssValue(HtmlUnitWebElement.java:585) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:52) at jdk.proxy2/jdk.proxy2.$Proxy31.getCssValue(Unknown Source) at org.openqa.selenium.support.ui.ExpectedConditions.getAttributeOrCssValue(ExpectedConditions.java:1184) at org.openqa.selenium.support.ui.ExpectedConditions.lambda$attributeToBeNotEmpty$0(ExpectedConditions.java:1178) at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:208)
https://github.com/SeleniumHQ/htmlunit-driver/blob/c7dc458f43ddef8a553f0301eb008e7b509fe38d/src/main/java/org/openqa/selenium/htmlunit/HtmlUnitWebElement.java#L585