硒网络驱动程序异常 [英] A selenium webdriver exception

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

问题描述

今天,当我使用 selenium webdrive 时,出现错误.我的平台是 mac osx .这是我的异常日志.

Today, when i use the selenium webdrive, i got an error. my platform is mac osx . this is my exception log.

ruby-1.9.2-p0 > Selenium::WebDriver.for :firefox
Selenium::WebDriver::Error::WebDriverError: unable to bind to locking port 7054 within 45 seconds
 from /Users/Apple/.rvm/gems/ruby-1.9.2-p0/gems/selenium-webdriver-0.1.0/lib/selenium/webdriver/firefox/socket_lock.rb:48:in `lock'
 from /Users/Apple/.rvm/gems/ruby-1.9.2-p0/gems/selenium-webdriver-0.1.0/lib/selenium/webdriver/firefox/socket_lock.rb:29:in `locked'
 from /Users/Apple/.rvm/gems/ruby-1.9.2-p0/gems/selenium-webdriver-0.1.0/lib/selenium/webdriver/firefox/launcher.rb:32:in `launch'
 from /Users/Apple/.rvm/gems/ruby-1.9.2-p0/gems/selenium-webdriver-0.1.0/lib/selenium/webdriver/firefox/bridge.rb:21:in `initialize'
 from /Users/Apple/.rvm/gems/ruby-1.9.2-p0/gems/selenium-webdriver-0.1.0/lib/selenium/webdriver/common/driver.rb:38:in `new'
 from /Users/Apple/.rvm/gems/ruby-1.9.2-p0/gems/selenium-webdriver-0.1.0/lib/selenium/webdriver/common/driver.rb:38:in `for'
 from /Users/Apple/.rvm/gems/ruby-1.9.2-p0/gems/selenium-webdriver-0.1.0/lib/selenium/webdriver.rb:51:in `for'
 from (irb):8
 from /Users/Apple/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands/console.rb:44:in `start'
 from /Users/Apple/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands/console.rb:8:in `start'
 from /Users/Apple/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.1/lib/rails/commands.rb:23:in `<top (required)>'
 from script/rails:6:in `require'
 from script/rails:6:in `<main>'

我不知道为什么会这样.我的 Firefox 路径是默认路径.谢谢你的帮助!!

i do not know why this happend. my firefox path is the default path. thank you for your help!!

推荐答案

WebDriver 使用端口 7054(锁定端口")作为互斥锁,以确保我们不会同时启动两个 Firefox 实例.您创建的每个新实例都会在启动浏览器之前等待互斥锁,然后在浏览器打开时立即释放它.

WebDriver uses port 7054 (the "locking port") as a mutex to ensure that we don't launch two Firefox instances at the same time. Each new instance you create will wait for the mutex before starting the browser, then release it as soon as the browser is open.

所以这确实可能是一个资源问题 - 之前创建的驱动程序需要超过 45 秒才能启动并在这段时间内保持锁定.

So this could indeed be a resource issue - a previously created driver is taking more than 45 seconds to launch and is holding on to the lock for that time.

如果在您的情况下这似乎不太可能,那么了解哪个进程持有锁会很有趣.尝试在超时前 45 秒内运行 lsof -i TCP:7054.

If this seems unlikely in your case it would be interesting to know what process is holding the lock. Try running lsof -i TCP:7054 in the 45 seconds before it times out.

使用 -d 运行 ruby​​(或设置 $DEBUG = true)也将为进一步调试提供一些有用的信息.

Running ruby with -d (or setting $DEBUG = true) will also provide some useful info for debugging this further.

这篇关于硒网络驱动程序异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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