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

Setting cookies will request a page twice #63

Closed
n-studio opened this issue Sep 20, 2021 · 1 comment · May be fixed by #64
Closed

Setting cookies will request a page twice #63

n-studio opened this issue Sep 20, 2021 · 1 comment · May be fixed by #64

Comments

@n-studio
Copy link

When I set cookies, the spider will request the page twice instead of once. Is it an expected behavior or is it a bug? It also sleeps twice.

Without cookies

DEBUG -- : BrowserBuilder (selenium_chrome): created browser instance
DEBUG -- : BrowserBuilder (selenium_chrome): enabled before_request.delay
DEBUG -- : Browser: sleep 2.93 seconds before request...
DEBUG -- : BrowserBuilder (selenium_chrome): enabled custom user_agent
DEBUG -- : BrowserBuilder (selenium_chrome): enabled native headless_mode
INFO -- : Browser: started get request to: https://www.google.com
[DEPRECATION] :driver_path is deprecated. Use :service with an instance of Selenium::WebDriver::Service instead.
INFO -- : Browser: finished get request to: https://www.google.com
INFO -- : Info: visits: requests: 1, responses: 1

With cookies

DEBUG -- : BrowserBuilder (selenium_chrome): created browser instance
DEBUG -- : BrowserBuilder (selenium_chrome): enabled custom cookies
DEBUG -- : BrowserBuilder (selenium_chrome): enabled before_request.delay
DEBUG -- : Browser: sleep 1.63 seconds before request...
DEBUG -- : BrowserBuilder (selenium_chrome): enabled custom user_agent
DEBUG -- : BrowserBuilder (selenium_chrome): enabled native headless_mode
DEBUG -- : Browser: sleep 3.03 seconds before request... // <-- sleeps a second time
INFO -- : Browser: started get request to: https://www.google.com
[DEPRECATION] :driver_path is deprecated. Use :service with an instance of Selenium::WebDriver::Service instead.
INFO -- : Browser: finished get request to: https://www.google.com
INFO -- : Info: visits: requests: 1, responses: 1
DEBUG -- : Browser: driver.current_memory: 333616
INFO -- : Browser: started get request to: https://www.google.com // <-- makes another request
INFO -- : Browser: finished get request to: https://www.google.com
INFO -- : Info: visits: requests: 2, responses: 2
@n-studio
Copy link
Author

lib/kimurai/capybara_ext/session.rb

      # cookies
      # (Selenium only) if config.cookies present and browser was just created,
      # visit url_to_visit first and only then set cookies:

It seems to be the expected behavior, maybe due to selenium limitations?
Closing now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant