[rb] Add check of process existence before polling for exit of process#10015
[rb] Add check of process existence before polling for exit of process#10015yoshoku wants to merge 2 commits intoSeleniumHQ:trunkfrom yoshoku:add_check_process_exists
Conversation
If the instance variable @ process is nil and the poll_for_exit method is called, NoMethodError will raise. To prevent this, it is necessary to check if the process exists.
|
@yoshoku Thank you for the contribution!
I would rather try to understand why you get this error first. By the time this code is called, the |
|
@p0deje how about instead using the safe operator here? That would maybe cover any extenuating use case and not need the extra addition? |
|
@p0deje Thank you for your interest. For example, this error can be reproduced by rewriting the def lock
raise Error::WebDriverError
end$ git clone [email protected]:teamcapybara/capybara.git
$ cd capybara
$ bundle install
$ bundle exec rspec spec/selenium_spec_chrome.rb
...
/foobar/gems/selenium-webdriver-4.0.3/lib/selenium/webdriver/common/service_manager.rb:65:in `stop': undefined method `poll_for_exit' for nil:NilClass (NoMethodError)
from /foobar/gems/selenium-webdriver-4.0.3/lib/selenium/webdriver/common/platform.rb:155:in `block in exit_hook'
... |
Description
In the
stopmethod ofSelenium::WebDriver::ServiceManager, I would like to add a check if the process exists before calling thepoll_for_exitmethod of the instance variable@process.Motivation and Context
The simplest error reproduction is as follows:
I am using selenium-webdriver with capybara and parallel_tests, and sometimes I get this error.
In the
stop_serverprivate method ofSelenium::WebDriver::ServiceManager, the existence of the process is checked at the beginning. I think that the same check is also necessary before calling thepoll_for_exitmethod.Types of changes
Checklist