Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A selenium webdriver exception

Tags:

ruby

selenium

qa

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>'

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

like image 841
Small Wolf Avatar asked Nov 28 '10 09:11

Small Wolf


People also ask

What is WebDriver exception in Selenium?

An exception object is created when an exception is encountered, which contains debugging information such as the line number, the type of Exception, the method hierarchy. Once the exception object is created and handed over to the runtime environment, this process is called “Throwing the Exception.”

What exceptions does Selenium WebDriver throw?

ElementNotVisibleException class is a subclass of ElementNotInteractableException class. This exception is thrown when WebDriver tries to perform an action on an invisible web element, which cannot be interacted with. That is, the web element is in a hidden state.

How many exceptions are there in Selenium?

Basically, there are 2 types of exceptions in Selenium and they are as follows: Checked Exception. Unchecked Exception.


2 Answers

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.

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.

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.

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

like image 148
jarib Avatar answered Oct 01 '22 09:10

jarib


I did lsof -i TCP:7054 and found the corresponding process_id, and then finally killed the given process withkill -9 process_id

And then tried the test again, and it did worked :)

like image 37
kxhitiz Avatar answered Oct 01 '22 09:10

kxhitiz