Eligijus Blankus
Eligijus Blankus

Reputation: 41

WebDriverException Unrecognised platform

I am trying to use PhantomJSDriver with Selenium.

Here is my test code:

    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());
    }

    }

And here is the console log:

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)

Anyone knows how to make it work. I have tried the same on my mac but getting the same error.

Thanks

Upvotes: 1

Views: 2314

Answers (2)

use below pom file to solve the issue

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <cucumber.version>1.2.4</cucumber.version>
    <!--<selenium.version>3.6.0</selenium.version> it does not work with PhantomJS 2.1.1-->
    <selenium.version>3.5.3</selenium.version>
</properties>

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependencies>
    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>${selenium.version}</version>
    </dependency>

.... ....

Upvotes: 0

KIT
KIT

Reputation: 31

Hitting the same problem as mentioned, you should probably try changing the version of seleninum to 3.5.3 instead of 3.6.0

You can refer to the following github issue for details https://github.com/SeleniumHQ/selenium/issues/4781#issuecomment-333452945

Upvotes: 3

Related Questions