Testing with a selenium driver in Java without opening any browser

后端 未结 4 1520
暖寄归人
暖寄归人 2020-12-17 00:40

I need to test with selenium chrome driver in Java. But chrome window should\'t be opened. Assume this a product and no window should be opened.

I\'ve also looked at

4条回答
  •  無奈伤痛
    2020-12-17 01:10

    I like this article.

    Basically you need to add PhantomJS dependency in pom (I like maven for dependency management):

    
        com.github.detro.ghostdriver
        phantomjsdriver
        1.1.0
    
    

    And run code

        System.setProperty( "phantomjs.binary.path", "c:\\path\\to\\phantomjs-1.9.8-windows\\phantomjs.exe" );
        WebDriver driver = new PhantomJSDriver();
        driver.get("http://www.google.com");
        driver.quit();
    

    It worked for me with versions:

    • PhantomJS 1.9.8
    • PhantomJS driver 1.1.0
    • Selenium 2.44.0

提交回复
热议问题