java - WebDriverException 无法识别的平台

标签 java selenium-webdriver phantomjs

我正在尝试将 PhantomJSDriver 与 Selenium 一起使用。

这是我的测试代码:

    public static void main(String[] args) {
    // TODO code application logic here

    DesiredCapabilities caps = new DesiredCapabilities();
    caps.setJavascriptEnabled(true);
    //caps.setCapability("takesScreenshot", true);
    caps.setCapability(
            PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
            "C:\\Users\\Eligijus\\Documents\\NetBeansProjects\\CrawlerApp\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe"
    );
    WebDriver driver = new PhantomJSDriver(caps);

    driver.get("http://en.wikipedia.org");

    System.out.println("Page Title" +driver.getTitle());
    }

    }

这是控制台日志:

Exception in thread "main" org.openqa.selenium.WebDriverException: 
Unrecognized platform: windows-10-32bit
Build info: version: '3.6.0', revision: '6fbf3ec767', time: '2017-09-
27T16:15:26.402Z'
System info: host: 'DESKTOP-67KOQUP', ip: '192.168.1.25', os.name: 'Windows 
10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_131'
Driver info: driver.version: PhantomJSDriver
at org.openqa.selenium.Platform.fromString(Platform.java:325)
at 
org.openqa.selenium.remote.RemoteWebDriver
.startSession(RemoteWebDriver.java:23
4)
at org.openqa.selenium.remote.RemoteWebDriver.<init>
(RemoteWebDriver.java:140)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>
(PhantomJSDriver.java:116)
at org.openqa.selenium.phantomjs.PhantomJSDriver.<init>
(PhantomJSDriver.java:105)
at crawlerapp.CrawlerApp.main(CrawlerApp.java:24)
C:\Users\Eligijus\AppData\Local\NetBeans\Cache\8.2\executor-
snippets\run.xml:53: Java returned: 1
BUILD FAILED (total time: 2 seconds)

任何人都知道如何让它发挥作用。我在我的 Mac 上尝试了相同的操作,但遇到了相同的错误。

谢谢

最佳答案

遇到与上述相同的问题,您可能应该尝试将 seleninum 的版本更改为 3.5.3 而不是 3.6.0

详细内容可以引用以下github问题 https://github.com/SeleniumHQ/selenium/issues/4781#issuecomment-333452945

关于java - WebDriverException 无法识别的平台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46506654/

相关文章:

Phantomjs 停止加载整页

java - PhantomJS 和导体框架

node.js - Selenium 网络驱动程序 : HTML renders differently for Firefox vs. PhantomJS

java - 奇怪的 : For loop returns last iteration under certain conditions

java - 如何打印一条错误消息,指出用户输入索引太大?

java - 线程中的异常 "main"java.lang.IllegalArgumentException : Cannot instantiate interface org. springframework.context.ApplicationListener

java - Spring 3 - 如何在传递额外的请求参数时抛出异常

python - 在 selenium 中使用 python 循环

javascript - 在 FireFox 和 IE 中使用 Selenium WebdriverJS 时出现问题

selenium-webdriver - 如何使用 NodeJS - Protractor 从 Excel 读取/写入 Excel?