cheezy / page-object

Gem to implement PageObject pattern in watir-webdriver and selenium-webdriver
MIT License
653 stars 220 forks source link

Page navigation broken #454

Open enkessler opened 7 years ago

enkessler commented 7 years ago

The dependency upgrade to 0.10.0 of the page_navigation gem appear to have broken PageFactory::PageNavigation#visit_page. Prior to the upgrade, calling visit_page would navigate the browser to the desired page. After the upgrade, no navigation occurs.

cheezy commented 7 years ago

There has been no change made to that code for years. Can you provide some more details so I can look into it?

Sent from my iPad

On Nov 8, 2017, at 9:13 AM, Eric Kessler notifications@github.com wrote:

The dependency upgrade to 0.10.0 of the page_navigation gem appear to have broken PageFactory::PageNavigation#visit_page. Prior to the upgrade, calling visit_page would navigate the browser to the desired page. After the upgrade, no navigation occurs.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

enkessler commented 7 years ago

My bad. It turns out that I can, in fact upgrade page_navigation to 0.10.0 and things still work.

However, I cannot upgrade past page-object 2.1.1 without visit_page no longer...well, visiting a page. It doesn't throw an error. It just doesn't go anywhere in the browser.

I mistakenly thought that it was the dependency because that is the version where it was changed. Something got broken from then onward, however, because the problem persists all the way from 2.2 through 2.2.4, only change in my Gemfile.lock is the page-object going from 2.1.1 to 2.2.x and the required watir upgrade at 2.2.3.

bethmuir commented 6 years ago

So, I am in the process of updating a test suite that hasn't been updated in a while (going from page-object 1.1.0 to 2.2.4), and I just hit the same problem. The issue seems to be with the initialize method in page-object.rb, in which the line

goto if visit && respond_to?(:goto)

has been changed to

goto if visit && self.class.instance_methods(false).include?(:goto)

Not sure why this would have been changed, as self is a PageObject at that point and this is never going to be true without including inherited methods. I tried monkeypatching the initialize method back to just using respond_to? and it did indeed make visit work again, but I wonder if I'm missing some other dependency update that's causing this issue.

EDIT: Had to set this aside for a while, but working on it today I see that it's the page_url method on the PageObject that defines goto. So, on a page where I've defined direct_url or page_url directly, it works, but the problem is most of my pages are constructing the url using ERB from a common "<%=base_url/relative_url%>" pattern, so they all inherit from a base page. To make visit work I will have to copy and paste it into every single PageObject.