【问题标题】:Selenium standalone server fails in production mode - GrailsSelenium 独立服务器在生产模式下失败 - Grails
【发布时间】:2017-12-04 15:10:05
【问题描述】:

我有一个使用 Grails 编写的 Web 应用程序,它在尝试启动 Selenium 独立服务器时在生产模式下失败。

这是错误:

 2017-12-04 10:04:52,905 [http-bio-8080-exec-7] ERROR 
 errors.GrailsExceptionResolver  - ClassNotFoundException occurred when 
 processing request: [GET] /Diversotron-0.1/api/edit
 com.google.common.base.Function. Stacktrace follows:
 java.lang.ClassNotFoundException: com.google.common.base.Function
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2585)
    at java.lang.Class.getDeclaredConstructors(Class.java:1906)
    at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
    at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
    at diversotron.PropotronService.setPropotron(PropotronService.groovy:29)
    at diversotron.ApiController.edit(ApiController.groovy:53)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)

第 29 行是这样的:

 WebDriver driver = new RemoteWebDriver(new URL("http://123.456.78.910:4444/wd/hub"), capabilities)

这在调试模式下工作得很好。有人有想法么? (IP地址为隐私隐藏)

【问题讨论】:

    标签: selenium grails


    【解决方案1】:

    使用FirefoxOptions通过org.openqa.selenium.MutableCapabilities合并能力如下:

    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("...", true);
    capabilities.setCapability("...", true);
    FirefoxOptions options = new FirefoxOptions();
    options.merge(capabilities);
    WebDriver driver = new RemoteWebDriver(new URL("http://127.0.0.1:4444/wd/hub"), options);
    

    【讨论】:

    • 我正在使用 Chrome,但无论如何,它在这一行失败了:ChromeOptions options = new ChromeOptions()
    • @Sulteric ChromeOptions 失败意味着我们需要查看导入和 jar 兼容性。
    • 检查org.openqa.selenium.MutableCapabilities的JavaDoc链接的更新答案
    • 这是org.openqa.selenium.MutableCapabilities 的JavaDoc。除此之外没有什么可下载的。更新 Selenium Client Jars 会处理它。
    • 这个东西在 3.8.1 中。下载了,将库添加到我的项目中。 options.merge(功能);仍然失败
    猜你喜欢
    • 1970-01-01
    • 2015-09-01
    • 2020-12-30
    • 2011-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多