Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug when I use ruby to run selenium and firefox for my automation testing #9467

Closed
ThomasSun001 opened this issue May 11, 2021 · 4 comments
Closed

Comments

@ThomasSun001
Copy link

🐛 Bug Report

It consumes a lot of, actually much of CPU and memory during the start and failed at the end which is quite bizarre !

To Reproduce

Detailed steps to reproduce the behavior:

Test script or set of commands reproducing this issue

  1. irb
  2. require 'selenium-webdriver'
  3. Selenium::WebDriver::Firefox::Service.driver_path = "/geckodriver"
  4. options = Selenium::WebDriver::Firefox::Options.new(args: ['-headless'],log_level: :info)
  5. driver = Selenium::WebDriver.for(:firefox,options:options) #it will take a long time to start the browser, normally just a few seconds, but now it consumes almost 100 % CPU and up to 5 or 6 GB RAM given my machine is 8GB during the startup, at the end this step will proceed successfully
  6. driver.navigate.to("https://www.baidu.com") _It failed at this step! Net::ReadTimeout: Net::ReadTimeout
    from /home/centos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/protocol.rb:176:in rbuf_fill' from /home/centos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/protocol.rb:154:in readuntil'
    from /home/centos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/protocol.rb:164:in readline' from /home/centos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http/response.rb:40:in read_status_line'
    from /home/centos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http/response.rb:29:in read_new' from /home/centos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1446:in block in transport_request'
    from /home/centos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1443:in catch' from /home/centos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1443:in transport_request'
    from /home/centos/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/net/http.rb:1416:in request' from /home/centos/.rvm/gems/ruby-2.4.1/gems/selenium-webdriver 3.142.7/lib/selenium/webdriver/remote/http/default.rb:129:in response_for'
    from /home/centos/.rvm/gems/ruby-2.4.1/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/default.rb:82:in request' from /home/centos/.rvm/gems/ruby-2.4.1/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/http/common.rb:64:in call'
    from /home/centos/.rvm/gems/ruby-2.4.1/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/bridge.rb:167:in execute' from /home/centos/.rvm/gems/ruby-2.4.1/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/w3c/bridge.rb:567:in execute'
    from /home/centos/.rvm/gems/ruby-2.4.1/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/remote/w3c/bridge.rb:59:in get' from /home/centos/.rvm/gems/ruby-2.4.1/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/navigation.rb:32:in to'
    from (irb):9
    from /home/centos/.rvm/rubies/ruby-2.4.1/bin/irb:11:in `' _
  7. my network to this website is :
    PING baidu.com (220.181.38.148) 56(84) bytes of data.
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=44 time=3.87 ms
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=44 time=3.91 ms
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=44 time=3.85 ms
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=4 ttl=44 time=3.93 ms
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=5 ttl=44 time=3.85 ms
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=6 ttl=44 time=3.83 ms
  8. I only use headless mode, when I switch to non-headless, it then will say:
    Selenium::WebDriver::Error::UnknownError: invalid argument: can't kill an exited process

Expected behavior

It will start and run firefox browser quietly and swiftly

Environment

OS: Linux 3.10.0-1127.19.1.el7.x86_64 #1 SMP Tue Aug 25 17:23:54 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux, Centos7
Browser: Firefox
Browser version: Mozilla Firefox 68.12.0esr
Browser Driver version: geckodriver 0.26.0 (e9783a644016 2019-10-10 13:38 +0000)
Language Bindings version: ruby 2.4.1

@ghost ghost added the needs-triaging label May 11, 2021
@diemol
Copy link
Member

diemol commented May 11, 2021

What is the actual bug? Can we have a script to reproduce the behaviour? Narrative descriptions leave lots of room for assumptions.

@titusfortner
Copy link
Member

By default the driver waits for the "Document Readiness State" to be in a "complete" status. (https://w3c.github.io/webdriver/#dfn-table-of-page-load-strategies).

If you manually navigate to the site, you'll see that it never finishes loading.

In Selenium 3.x you can get around this by:

caps = Selenium::WebDriver::Remote::Capabilities.firefox(page_load_strategy: 'none')
driver = Selenium::WebDriver.for(:firefox, options:options, desired_capabilities: caps)

@ThomasSun001
Copy link
Author

What is the actual bug? Can we have a script to reproduce the behaviour? Narrative descriptions leave lots of room for assumptions.
Well, thx for your reply, If I know that the bug is, then I will be looking for some solutions, the thing is I have no idea what happened for this error!
by the way:
the script to reproduce:
Selenium::WebDriver::Firefox::Service.driver_path = "/geckodriver" Selenium::WebDriver.logger.level = :info Selenium::WebDriver.logger.output = 'selenium.log' options = Selenium::WebDriver::Firefox::Options.new(args: ['-headless'],log_level: :info) driver = Selenium::WebDriver.for(:firefox,options:options)
The log will output nothing,
I update my firefox to Mozilla Firefox 78.10.0esr, it works smoothly, but my another computer which is also centos7, the firefox version Mozilla Firefox 68.12.0esr, it also works, So I'm deeply confused!

@titusfortner
Copy link
Member

@ThomasSun001 typically Github issues are created for obvious, repeatable problems with the code that are actionable by the committers, not for general support when things aren't working as you expect. I'd recommend connecting with us in the User Group or Chat/Slack - https://www.selenium.dev/support/

It is not obvious to me what your current concern is since you didn't reference the solution I provided to your previously described problem.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants