bonigarcia / webdrivermanager

Automated driver management and other helper features for Selenium WebDriver in Java
https://bonigarcia.dev/webdrivermanager/
Apache License 2.0
2.56k stars 673 forks source link

NoSuchField: LOG - Java 17 Selenium 4.10.0 crashes when closing WebDriverManager created Driver #1086

Closed abr46c closed 11 months ago

abr46c commented 1 year ago

Description of the problem: NoSuchField LOG on Driver.Quit

Browser and version: Chrome 115

Operating system: Windows 10

WebDriverManager version: 5.4.1

WebDriverManager call: return WebDriverManager.chromedriver().capabilities(options).create();

WebDriverManager traces: Starting ChromeDriver 115.0.5790.102 (90efd4b0ad6aa15eeafcdabd5817ae939f7ba059-refs/branch-heads/5790_90@{#9}) on port 51993 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. Jul 25, 2023 11:55:23 AM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: W3C Jul 25, 2023 11:55:23 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch WARNING: Unable to find an exact match for CDP version 115, so returning the closest version found: 114 Jul 25, 2023 11:55:23 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch INFO: Found CDP implementation for version 115 of 114

Error log: Step failed java.lang.NoSuchFieldError: LOG at org.openqa.selenium.remote.http.jdk.JdkHttpClient$5.close(JdkHttpClient.java:307) at org.openqa.selenium.devtools.Connection.close(Connection.java:190) at java.base/java.util.Optional.ifPresent(Optional.java:178) at org.openqa.selenium.chromium.ChromiumDriver.quit(ChromiumDriver.java:292) at myccapp.utils.Controller.stopDriver(Controller.java:266) at myccapp.stepdefs.GlobalHooks.completeCdcInvitation(GlobalHooks.java:218) at myccapp.stepdefs.GlobalHooks.insertLandingPageShop_AllProducts(GlobalHooks.java:152)

Copying dependencies below; please note that regression to Selenium 4.9.1 will fix this issue (note that http-jdk-client is in place which is required for Selenium to operate with Java17):

dependencies { implementation 'io.swagger:swagger-annotations:1.6.11' implementation 'org.springframework.boot:spring-boot-starter-data-rest' implementation "org.openapitools:jackson-databind-nullable:0.2.6" implementation 'javax.validation:validation-api:2.0.1.Final' testImplementation group: 'io.github.bonigarcia', name: 'webdrivermanager', version: '5.4.1' testImplementation 'io.cucumber:cucumber-java:7.13.0' testImplementation 'io.cucumber:cucumber-core:7.13.0' testImplementation 'io.cucumber:cucumber-junit:7.13.0' testImplementation 'io.cucumber:cucumber-picocontainer:7.13.0' implementation group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.4.16' implementation group: 'org.apache.httpcomponents.client5', name: 'httpclient5', version: '5.2.1' testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.10.0' implementation 'org.seleniumhq.selenium:selenium-http-jdk-client:4.10.0' testImplementation group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3' testImplementation group: 'org.apache.commons', name: 'commons-compress', version: '1.23.0' testImplementation 'io.github.cdimascio:dotenv-java:3.0.0' implementation group: 'org.glassfish', name: 'javax.json', version: '1.1.4' implementation 'com.google.code.gson:gson:2.10.1' implementation 'com.querydsl:querydsl-apt' annotationProcessor 'com.querydsl:querydsl-apt:5.0.0:general' implementation 'com.github.java-json-tools:json-patch:1.13' implementation group: 'org.apache.commons', name: 'commons-text', version: '1.10.0' implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' implementation group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: '2.15.2' testCompileOnly 'org.projectlombok:lombok:1.18.28' testImplementation 'org.springframework.boot:spring-boot-starter-webflux:3.1.2' testAnnotationProcessor 'org.projectlombok:lombok:1.18.28' testImplementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.15.2' testImplementation 'org.apache.commons:commons-io:1.3.2' }

SimonasPetk commented 1 year ago

I get the same error

Description of the problem: NoSuchField LOG on Driver.Quit

Browser and version: Chrome 115

Operating system: Windows 11

WebDriverManager version: 5.4.1

WebDriverManager call: WebDriverManager.getInstance(DriverManagerType.CHROME).setup(); WebDriver driver = new ChromeDriver(options);

bonigarcia commented 1 year ago

I am unable to reproduce this problem. I'm running this test and Java 17, but everything seems to work correctly. Am I missing something?

abr46c commented 1 year ago

I am still experiencing this issue as seen as well by Simonas. The call that is generating this driver is below; I will paste additional plugins from my build.gradle. I will have to find time to make a test repo where I can remove these plugins and try to assist further.

ChromeOptions options = new ChromeOptions(); options.setAcceptInsecureCerts(true); return WebDriverManager.chromedriver().capabilities(options).create();

plugins { id "org.openapi.generator" version "6.6.0" id "de.undercouch.download" version "5.4.0" id 'org.springframework.boot' version '2.+' id 'io.spring.dependency-management' version '1.1.2' id 'java' id 'eclipse' } apply plugin: 'java' apply plugin: 'groovy'

abr46c commented 1 year ago

@bonigarcia I created a test repo and updated my plugins and have determined that the issue was not triggered until I included the following two plugins.

I have tried reversioning them to no avail; I will determine if either can be removed (but I believe them to be necessary for OpenApi Generation).

id 'org.springframework.boot' version '3.1.2'
id 'io.spring.dependency-management' version '1.1.3'
bonigarcia commented 11 months ago

@abr46c Any update on this issue? Can it be closed?

abr46c commented 7 months ago

@bonigarcia Hi sorry for the long response; but I did just figure out the nature of this issue this week.

Spring Dependency Management was locking Selenium's version to an older version (4.1.4) and this was causing issues with WDM and other dependencies like Appium. Overriding this value so that the included versions of Selenium were used fixed all issues.

https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-dependencies/2.7.9/spring-boot-dependencies-2.7.9.pom