Spring Selenium错误创建RemoteWebDriver(io.opentelemetry)

huangapple go评论56阅读模式
英文:

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 = &quot;&lt;project-arn&gt;&quot;;
    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(&quot;browserName&quot;, &quot;chrome&quot;);
    capabilities.setCapability(&quot;browserVersion&quot;, &quot;latest&quot;);
    capabilities.setCapability(&quot;platform&quot;, &quot;windows&quot;);

    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(&quot;browserVersion&quot;, &quot;103&quot;);
chromeOptions.setCapability(&quot;platformName&quot;, &quot;Windows 10&quot;);
WebDriver driver = new RemoteWebDriver(new URL(&quot;http://www.google.com&quot;), 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);

huangapple
  • 本文由 发表于 2023年4月19日 17:34:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76052947.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定