Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium java + PhantomJS - phantomjs://platform/console++.js:263 in error

I was trying to run selenium with phantomjs headless browser and getting "phantomjs://platform/console++.js:263 in error" error message.

Searched over internet but did not get any solution, so asking here.

Same code and solution not working for me Link

Why I am getting this error message?, is this phantomjs issue or selenium?. Let me know how to resolve it?.

Configuration:

1) Selenium 2.53.1.jar

2) Phantomjs 2.1.1 .exe

3) Junit4

Code:

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 testCreazione() throws Exception {
        driver.get(baseUrl + "/SegreteriaSportiva/Calciatori.aspx");

        driver.findElement(By.cssSelector("#ASPxButton1_CD > span")).click();

        driver.findElement(By.id("FrmEdit_TS_TipoPersonaId_FK_B-1")).click();
        driver.findElement(By.id("FrmEdit_TS_TipoPersonaId_FK_DDD_L_LBI2T0")).click();
        driver.findElement(By.id("FrmEdit_Nome_I")).clear();
        driver.findElement(By.id("FrmEdit_Nome_I")).sendKeys("Prova");
        driver.findElement(By.id("FrmEdit_Cognome_I")).clear();
        driver.findElement(By.id("FrmEdit_Cognome_I")).sendKeys("Calciatore");
        driver.findElement(By.id("FrmEdit_TS_RuoloId_FK_B-1")).click();
        driver.findElement(By.id("FrmEdit_TS_RuoloId_FK_DDD_L_LBI3T0")).click();
        driver.findElement(By.id("FrmEdit_DataNascita_I")).clear();
        driver.findElement(By.id("FrmEdit_DataNascita_I")).sendKeys("01/01/2014");
        driver.findElement(By.id("FrmEdit_Cittadinanza_I")).clear();
        driver.findElement(By.id("FrmEdit_Cittadinanza_I")).sendKeys("italiana");
        driver.findElement(By.id("FrmEdit_LuogoNascita_I")).clear();
        driver.findElement(By.id("FrmEdit_LuogoNascita_I")).sendKeys("roma");
        driver.findElement(By.cssSelector("#BTN_Edit_CD > span")).click();
        driver.findElement(By.id("Grid_DXFREditorcol3_I")).click();
        driver.findElement(By.id("Grid_DXFREditorcol3_I")).sendKeys("Prova");
}

Error message:

    INFO: environment: {}
[INFO  - 2016-11-15T00:41:42.115Z] GhostDriver - Main - running on port 20668
[INFO  - 2016-11-15T00:41:42.955Z] Session [4766f980-aacc-11e6-a7fd-efd8c5848edd] - page.settings - {"XSSAuditingEnabled":false,"javascriptCanCloseWindows":true,"javascriptCanOpenWindows":true,"javascriptEnabled":true,"loadImages":true,"localToRemoteUrlAccessEnabled":false,"userAgent":"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/538.1 (KHTML, like Gecko) PhantomJS/2.1.1 Safari/538.1","webSecurityEnabled":true}
[INFO  - 2016-11-15T00:41:42.955Z] Session [4766f980-aacc-11e6-a7fd-efd8c5848edd] - page.customHeaders:  - {}
[INFO  - 2016-11-15T00:41:42.956Z] Session [4766f980-aacc-11e6-a7fd-efd8c5848edd] - Session.negotiatedCapabilities - {"browserName":"phantomjs","version":"2.1.1","driverName":"ghostdriver","driverVersion":"1.2.0","platform":"windows-7-32bit","javascriptEnabled":true,"takesScreenshot":true,"handlesAlerts":false,"databaseEnabled":false,"locationContextEnabled":false,"applicationCacheEnabled":false,"browserConnectionEnabled":false,"cssSelectorsEnabled":true,"webStorageEnabled":false,"rotatable":false,"acceptSslCerts":false,"nativeEvents":true,"proxy":{"proxyType":"direct"}}
[INFO  - 2016-11-15T00:41:42.956Z] SessionManagerReqHand - _postNewSessionCommand - New Session Created: 4766f980-aacc-11e6-a7fd-efd8c5848edd
[ERROR - 2016-11-15T00:42:27.341Z] WebElementLocator - _handleLocateCommand - Element(s) NOT Found: GAVE UP. Search Stop Time: 1479170547300

  phantomjs://platform/console++.js:263 in error
like image 405
Selenium Avatar asked Nov 15 '16 01:11

Selenium


1 Answers

Just set the driver capabilities to set the web driver log level to NONE . The logs won't appear.

 String[] phantomArgs = new String[] { "--webdriver-loglevel=NONE" }; 
 desireCaps.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs);
like image 133
Klaus Avatar answered Dec 29 '22 01:12

Klaus