Firefox硒驱动程序无法加载任意 [英] Firefox Selenium Driver fails to load arbitarily

查看:138
本文介绍了Firefox硒驱动程序无法加载任意的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码来创建我的网络驱动程序。

现在这个代码工作正常,如果我创建驱动程序1的1.

在多个创建这些驱动程序时出现的问题线程。

  public static WebDriver getConfiguredWebDriver(.....)
WebDriver driver = null;
DesiredCapabilities cap = new DesiredCapabilities();
if(ffp!= null){
ffp.setPreference(general.useragent.override,getRandomizedUASettings(rand,UserAgentList));
}
driver = new FirefoxDriver(null,ffp,cap);
// driver = new FirefoxDriver();在多线程
return driver中也给出了同样的错误;



$ b $ p
$ b $ p










Thread-4org.openqa.selenium.WebDriverException:无法连接到端口7057上的二进制FirefoxBinary(C:\ Program Files(x86)\Mozilla Firefox\firefox.exe);进程输出如下:
null
Build info:version:'2.28.0',revision:'18309',time:'2012-12-11 20:21:45'
系统信息:os.name:'Windows 7',os.arch:'amd64',os.version:'6.1',java.version:'1.6.0_26'

线程代码是

  while(...){
....... //
FirefoxProfile ffp = new FirefoxProfile();
DataEntryThread t = new DataEntryThread(parentFrame,lead,new ProxySettings(proxySettings),ffp,UserAgentList);
t.start();
....... //
}

任何线程随机甚至端口号。这里有什么问题?如何在不同的线程上实现加载多个firefox驱动程序?

解决方案

上面代码的一部分

  boolean driverCreated = false; 
int retryCnt = 3;
int count = 0; (!driverCreated& count< retryCnt){
try {
driver = new FirefoxDriver(null,ffp,cap);
driverCreated = true;
System.out.println(Driver Created);
} catch(Exception e){
retryCnt ++;


if(driverCreated == false){return null;基本上,我认为使用不同的线程加载驱动程序访问相同的Firefox二进制文件在同样的错误,但我仍然不确定。


I have this code for creating my web driver.
Now this code works fine if I create the driver 1 by 1.
The problem arises when creating these drivers on multiple threads.

public static WebDriver getConfiguredWebDriver(.....)
  WebDriver driver = null;
  DesiredCapabilities cap = new DesiredCapabilities();
  if(ffp != null) {
    ffp.setPreference("general.useragent.override", getRandomizedUASettings(rand, UserAgentList));
  }
  driver = new FirefoxDriver(null, ffp, cap);
  //driver = new FirefoxDriver(); also gives an error of the same kind during multithreading
  return driver;
}

It gives me this error

"Thread-4" org.openqa.selenium.WebDriverException: Failed to connect to binary FirefoxBinary(C:\Program Files (x86)\Mozilla Firefox\firefox.exe) on port 7057; process output follows: null Build info: version: '2.28.0', revision: '18309', time: '2012-12-11 20:21:45' System info: os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.6.0_26'

The thread code is

while(...) {
  ....... //
  FirefoxProfile ffp = new FirefoxProfile();
  DataEntryThread t = new DataEntryThread(parentFrame, lead, new ProxySettings(proxySettings), ffp, UserAgentList);
  t.start();
  ....... //
}

The error comes on any thread randomly and even the port number. What is wrong here ? How do I achieve loading multiple firefox drivers on different threads ?

解决方案

I have found a work around for this.. just modify a part of the above code

boolean driverCreated = false;
int retryCnt = 3;
int count = 0;
while(!driverCreated && count < retryCnt) {
  try {
    driver = new FirefoxDriver(null, ffp, cap);
    driverCreated = true;
    System.out.println("Driver Created");
  } catch (Exception e) {
    retryCnt++;
  }
}
if(driverCreated == false) { return null; }

Basically, I think the driver being loaded using different threads is accessing the same binary file of firefox at the same time which gives an error but I am still unsure of it.

这篇关于Firefox硒驱动程序无法加载任意的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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