小编Sel*_*ium的帖子

Selenium java + PhantomJS - phantomjs://platform/console++.js:263错误

我试图用phantomjs无头浏览器运行selenium并得到"phantomjs://platform/console++.js:263 in error"错误消息.

通过互联网搜索但没有得到任何解决方案,所以问这里.

相同的代码和解决方案对我不起作用Link

为什么我收到此错误消息?,这是phantomjs问题还是selenium?让我知道如何解决它?

组态:

1)Selenium 2.53.1.jar

2)Phantomjs 2.1.1 .exe

3)Junit4

码:

private PhantomJSDriver driver;
    private String baseUrl;

    @Before
    public void setUp() throws Exception {
       // File file = new File("D:/Selenium/Drivers/phantomjs.exe");
       // System.setProperty("phantomjs.binary.path", file.getAbsolutePath());

        System.setProperty("phantomjs.binary.path", "D:/Selenium/Drivers/phantomjs.exe");
        Capabilities caps = new DesiredCapabilities();
        ((DesiredCapabilities) caps).setJavascriptEnabled(true);                
        ((DesiredCapabilities) caps).setCapability("takesScreenshot", true);  
        //((DesiredCapabilities) caps).setCapability(PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY, "D:/Selenium/Drivers/phantomjs.exe");
        WebDriver   driver = new  PhantomJSDriver(caps);

        driver = new PhantomJSDriver();
        baseUrl = "http://www.gts.fiorentina.test/";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        driver.get(baseUrl + "/Account/Login.aspx?ReturnUrl=%2f");

        driver.findElement(By.id("tbUserName_I")).clear();
        driver.findElement(By.id("tbUserName_I")).sendKeys("rogai");
        driver.findElement(By.id("tbPassword_I")).clear();
        driver.findElement(By.id("tbPassword_I")).sendKeys("Fiorentina2014!");
        driver.findElement(By.id("btnLogin_CD")).click();
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    }

    @Test
    public void …
Run Code Online (Sandbox Code Playgroud)

selenium headless-browser phantomjs selenium-webdriver

9
推荐指数
1
解决办法
4092
查看次数