简体   繁体   中英

WedDriverException : java.util.HashMap cannot be cast to java.lang.String when initializing RemoteWebDriver

I am trying to run Junit tests in parllel ,did a grid setup with 3 nodes , while executing the test got an exception

org.openqa.selenium.firefox.NotConnectedException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms.

My understanding is There is nothing to do with Firefox and selenium version , I believe the exception is due to lock issued by the firefox for an webdriver instance which is not released within 45000 ms which throws an timeout exception for other webdriver instance trying to connect on port 7055 at the same time (mite be because of system slowness)

So i believe increasing the timeout in this case using the following code

   DesiredCapabilities capablities = new DesiredCapabilities();

    FirefoxBinary firefoxBinary = new FirefoxBinary();
    firefoxBinary.setTimeout(120000);


    FirefoxProfile profile = new FirefoxProfile();
    profile.setAcceptUntrustedCertificates(true);
    profile.setAssumeUntrustedCertificateIssuer(false);

    capablities = DesiredCapabilities.firefox();

    capablities.setCapability("firefox_binary", firefoxBinary);
    capablities.setCapability("firefox_profile", profile);

   driver =  new RemoteWebDriver(new URL("http://" + parameters.getRemoteUrl() + ":4444/wd/hub"), capablities);

but again got an exception WedDriverException : java.util.HashMap cannot be cast to java.lang.String

This exception is thrown when setting capability for firefoxbinary

capablities.setCapability("firefox_binary", firefoxBinary);

Otherwise the RemoteWebdriver instance is created without any issues

Kindly let me know if i am correct in increasing the timeout with regard to the lock on port 7055 , if so kindly help me out in solving the webdriver exception in Firefox Binary

I am not sure if the original error(Unable to connect to host 127.0.0.1 on port 7055) you received is due to timeout issue. I am sure it is related to the selenium and firefox version you are using. Take a look at a similar question and my answer on SO if you haven't already. I believe you need to upgrade your selenium version if you are not using the latest.

I have the same problem

this code works on my local PC.

FirefoxProfile fp = new FireFoxProfile();
fp.setPreference("Firefox43", "43.0.1");        
File pathBinary = new 
         File("C:\\PathToFirefox\\firefox.exe");
FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);       
WebDriver driver = new FirefoxDriver(firefoxBinary, fp);

But this code, doesn't ...

FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("Firefox43", "43.0.1");
File pathBinary = new 
         File("C:\\PathToFirefox\\firefox.exe");
FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);        
capabilities.setCapability(FirefoxDriver.PROFILE, fp);
capabilities.setCapability(FirefoxDriver.BINARY,firefoxBinary);
WebDriver driver = new RemoteWebDriver(new URL(hubUrl), capabilities);

It seems that there is a bug with RemoteWebDriver, check this question

UPDATE !!!!!

Use :

capabilities.setCapability(FirefoxDriver.BINARY, new
            File("C:\\PathToFirefox\\firefox.exe"));

Instead of ...

File pathBinary = new 
             File("C:\\PathToFirefox\\firefox.exe");
FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);
capabilities.setCapability(FirefoxDriver.BINARY,firefoxBinary);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM