英文:
Spring Selenium error creating RemoteWebDriver (io.opentelemetry)
问题
I'm using Spring Selenium framework and when trying to instantiate RemoteWebDriver, i'm getting the same error even with the simplest code.
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'preconditionSteps': Unsatisfied dependency expressed through field 'driver'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteChromeDriver' defined in class path resource [com/osmolka/fw/config/RemoteWebDriverConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openqa.selenium.WebDriver]: Factory method 'remoteChromeDriver' threw exception; nested exception is java.util.ServiceConfigurationError: io.opentelemetry.sdk.autoconfigure.spi.traces.SdkTracerProviderConfigurer: org.openqa.selenium.remote.tracing.opentelemetry.SeleniumSpanExporter not a subtype
I need to run tests on AWS, so used this:
@ThreadScopeBean
@ConditionalOnMissingBean
public WebDriver remoteChromeDriver() {
String myProjectARN = "<project-arn>";
DeviceFarmClient client = DeviceFarmClient.builder().region(Region.US_WEST_2).build();
CreateTestGridUrlRequest request = CreateTestGridUrlRequest.builder()
.expiresInSeconds(300)
.projectArn(myProjectARN)
.build();
CreateTestGridUrlResponse response = client.createTestGridUrl(request);
URL testGridUrl = null;
try {
testGridUrl = new URL(response.url());
} catch (Exception ex) {
ex.printStackTrace();
}
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "chrome");
capabilities.setCapability("browserVersion", "latest");
capabilities.setCapability("platform", "windows");
RemoteWebDriver driver = new RemoteWebDriver(testGridUrl, capabilities);
return driver;
}
The same piece of code with the same environment variables works on a project created from scratch, but without Spring. But it actually does not matter what code to write as long as it compiles. The same error appears even for something like that:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setCapability("browserVersion", "103");
chromeOptions.setCapability("platformName", "Windows 10");
WebDriver driver = new RemoteWebDriver(new URL("http://www.google.com"), chromeOptions);
So this error is thrown every time when calling new RemoteWebDriver. Struggling with this for a few days already...
英文:
I'm using Spring Selenium framework and when trying to instantiate RemoteWebDriver, i'm getting the same error even with the simplest code.
> org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'preconditionSteps': Unsatisfied dependency expressed through field 'driver'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'remoteChromeDriver' defined in class path resource [com/osmolka/fw/config/RemoteWebDriverConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.openqa.selenium.WebDriver]: Factory method 'remoteChromeDriver' threw exception; nested exception is java.util.ServiceConfigurationError: io.opentelemetry.sdk.autoconfigure.spi.traces.SdkTracerProviderConfigurer: org.openqa.selenium.remote.tracing.opentelemetry.SeleniumSpanExporter not a subtype
I need to run tests on AWS, so used this:
@ThreadScopeBean
@ConditionalOnMissingBean
public WebDriver remoteChromeDriver() {
String myProjectARN = "<project-arn>";
DeviceFarmClient client = DeviceFarmClient.builder().region(Region.US_WEST_2).build();
CreateTestGridUrlRequest request = CreateTestGridUrlRequest.builder()
.expiresInSeconds(300)
.projectArn(myProjectARN)
.build();
CreateTestGridUrlResponse response = client.createTestGridUrl(request);
URL testGridUrl = null;
try {
testGridUrl = new URL(response.url());
} catch (Exception ex) {
ex.printStackTrace();
}
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("browserName", "chrome");
capabilities.setCapability("browserVersion", "latest");
capabilities.setCapability("platform", "windows");
RemoteWebDriver driver = new RemoteWebDriver(testGridUrl, capabilities);
return driver;
}
Absolute same peace of code with same env. variables works on a project created from scratch, but without Spring. but actually does not matter what code to write as long as it compiles. Same error appears even for something like that:
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setCapability("browserVersion", "103");
chromeOptions.setCapability("platformName", "Windows 10");
WebDriver driver = new RemoteWebDriver(new URL("http://www.google.com"), chromeOptions);
So this eeror thrown every time when calling new RemoteWebDriver. Struggling with this for few days already...
答案1
得分: 0
需要使用另一个构造函数来禁用opentelemetry:
RemoteWebDriver driver = new RemoteWebDriver(testGridUrl, capabilities, false);
英文:
Need to disable opentelemetry by using another constructor:
RemoteWebDriver driver = new RemoteWebDriver(testGridUrl, capabilities, false);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论