WedDriverException:初始化RemoteWebDriver时无法将java.util.HashMap强制转换为java.lang.String [英] WedDriverException : java.util.HashMap cannot be cast to java.lang.String when initializing RemoteWebDriver

查看:136
本文介绍了WedDriverException:初始化RemoteWebDriver时无法将java.util.HashMap强制转换为java.lang.String的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试并行运行Junit测试,是否使用3个节点设置了网格,执行测试时却遇到了异常

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:在45000毫秒后无法连接到端口7055上的主机127.0.0.1.

我的理解是与Firefox和selenium版本无关,我认为该异常是由于firefox对某个webdriver实例发出的锁定导致的,该锁定未在45000毫秒内释放,这引发了其他webdriver实例尝试超时的异常同时在端口7055上连接(可能是由于系统缓慢)

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

但再次出现异常 WedDriverException:无法将java.util.HashMap强制转换为java.lang.String

设置firefoxbinary的功能时抛出此异常

This exception is thrown when setting capability for firefoxbinary

capablities.setCapability("firefox_binary", firefoxBinary);

否则,将创建RemoteWebdriver实例而不会出现任何问题

Otherwise the RemoteWebdriver instance is created without any issues

请告知我是否正确地增加了对7055端口的锁定的超时时间,如果可以的话,请帮助我解决Firefox Binary中的webdriver异常

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

推荐答案

我有同样的问题

此代码可在我的本地PC上运行.

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

RemoteWebDriver似乎有一个错误,请检查 这个问题

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

更新!!!!!

使用:

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

代替...

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

这篇关于WedDriverException:初始化RemoteWebDriver时无法将java.util.HashMap强制转换为java.lang.String的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆