Open BIGred053 opened 5 years ago
You're getting errors from the JS in the page you're loading. PhantomJS (which Poltergeist depends on) went EOL a while ago and does a pretty terrible job of replicating a modern browser nowadays, so there's a lot of JS libraries that are no longer compatible with it. Thats a large part of the reason Poltergeist is no longer maintained. You will have a better time if you upgrade to one of the newer, more modern browser using drivers - https://github.com/teamcapybara/capybara#drivers
Additionally - by doing - expect(current_url).to include anticipated_url
you're opening yourself to a race condition. You'd be much better off using Capybaras matcher with a regex expect(page).to have_current_path(%r{^http://x\.y\.z/blah})
Thanks for this feedback!
Meta
Poltergeist Version: 1.6.0/1.18.1 (Tried both, saw issues with both)
Expected Behavior
I am attempting to confirm the correct function of a link with
target="_blank"
by switching to the window opened up when clicking the link, then checking thecurrent_url
. This should return the url opened by clicking the link.Actual Behavior
In reality, I am getting the following error when attempting to
switch_to_window
:If I attempt the
switch_to_window
inbinding.pry
, it gives this error code, but actually seems to process switching windows, since afterwards I can checkcurrent_url
and get the correct result and a passing test.Since I ran into this with versions 1.6.0 and 1.18.1, I decided to try to work around this by executing some javascript to reset the links'
target
to "self". After this workaround, when testing the specs involved individually, they typically pass. However, when I run the entire file of specs, they fail locally. They do pass in our CI process, though.If this is an error in something in my implementation, please let me know.
Steps to reproduce
Here is the code I attempt:
Here is my 'workaround' code: