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

Probable incompatibility with Selenium? #1001

Closed
bobmaerten opened this issue Aug 22, 2022 · 5 comments
Closed

Probable incompatibility with Selenium? #1001

bobmaerten opened this issue Aug 22, 2022 · 5 comments

Comments

@bobmaerten
Copy link

bobmaerten commented Aug 22, 2022

Our test suite does not pass anymore since the release of the 3.16 version.

I found the culprit would be #976

Our stack consist of :

  • Ruby 3.1.2
  • Rails 7.0.3.1
  • VCR 6.1.0
  • Selenium webdriver 4.3.0
  • Capybara 3.37.1

Non-system tests pass as usual. On another app using the exact same stack but without system tests either (no Selenium/Capybara) we do not encounter problem either.

We have tried many different approaches to try to make tests pass:

- Webmock.enable! + Webmock.disable! # in setup/ teardown blocks
- WebMock.allow_net_connect!(net_http_connect_on_start: true)
- WebMock.allow_net_connect!(net_http_connect_on_start: [localhost]) # like exposed in #975
@bobmaerten bobmaerten changed the title Probable incompa Probable incompatibility with Selenium? Aug 22, 2022
@bblimke
Copy link
Owner

bblimke commented Aug 22, 2022

@bobmaerten thank you for reporting.

Can you please provide some more details? Does it raise any error and stacktrace? Are you able to provide an example that fails?

@bobmaerten
Copy link
Author

I was a little bit reluctant to create this issue, as we have very little context to provide. Our tests all fail with an error from Capybara returning page.current_path as nil but no further stack trace :'( . The tests are rather simple and were perfectly functional until v3.16. Here a sample of a failing test

def test_perform_visit
  visit some_path
  assert has_selector?(%(a.btn-primary[id="default-action"]))
  assert has_selector?(%(a.btn-secondary[id="other-action"]))

  find(%([id="other-action"]), match: :first).click

  assert has_selector?(%(a.btn-primary[id="other-action"])) # Fails here after click involving a controller request
  assert has_selector?(%(a.btn-secondary[id="default-action"]))
end
Minitest::UnexpectedError:         NoMethodError: undefined method `map' for true:TrueClass
            test/support/system/eshop/default_button_system_test:14:in `block in <class:DefaultButtonSystemTest>'

@daraul
Copy link

daraul commented Jun 16, 2023

I found that my system tests do not run, and instead give me this error:

WebMock::NetConnectNotAllowedError: Real HTTP connections are disabled. Unregistered request: POST http://127.0.0.1:9515/session with body '{"capabilities":{"alwaysMatch":{"browserName":"chrome","goog:chromeOptions":{}}}}' with headers {'Accept'=>'application/json', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'Content-Length'=>'81', 'Content-Type'=>'application/json; charset=UTF-8', 'User-Agent'=>'selenium/4.9.1 (ruby macosx)'}

You can stub this request with the following snippet:

stub_request(:post, "http://127.0.0.1:9515/session").
  with(
    body: "{\"capabilities\":{\"alwaysMatch\":{\"browserName\":\"chrome\",\"goog:chromeOptions\":{}}}}",
    headers: {
          'Accept'=>'application/json',
          'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
          'Content-Length'=>'81',
          'Content-Type'=>'application/json; charset=UTF-8',
          'User-Agent'=>'selenium/4.9.1 (ruby macosx)'
    }).
  to_return(status: 200, body: "", headers: {})

Removing require webmock/minitest from my Rails application's test/test_helper.rb file causes the test to run just fine.


edit: Adding WebMock.disable_net_connect!(allow_localhost: true) to my test also allows it to run without a problem. I'm not sure if this is the recommended solution.

@bobmaerten
Copy link
Author

I checked our test-suite against the latest version and it seems to work fine now. Can't tell what changed either on the gem side or from our tests ¯_(ツ)_/¯.

@bblimke
Copy link
Owner

bblimke commented Aug 20, 2023

There were no WebMock version changes, therefore I expect that the issue was related to webmock in combination with something that has changed. Anyway, in case it happens again, please open the issue again.

@bblimke bblimke closed this as completed Aug 20, 2023
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

No branches or pull requests

3 participants