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

Browser Navigation Forward #623

Closed
digitalgrease opened this issue Mar 8, 2019 · 4 comments · Fixed by #767
Closed

Browser Navigation Forward #623

digitalgrease opened this issue Mar 8, 2019 · 4 comments · Fixed by #767

Comments

@digitalgrease
Copy link

Hi,

I am using a forward() equivalent of the back() method on Browser and would like to submit a PR for the feature?

@driesvints
Copy link
Member

What would this actual do? Can you show a specific example with some code?

@digitalgrease
Copy link
Author

digitalgrease commented Mar 8, 2019

So for example we are testing an application where we visit a URL and it displays the contents of a folder with images.
When we click to view a single image we want a modal/popup to display the image with the file and other properties. We want a new URL to be pushed onto the history when we open this modal.
Then, when we close the modal, we want it to return to the original URL as if the user has moved back.
We want to test that clicking forward in the browser reopens the modal/popup.

    public function test()
    {
        $this->browse(function (Browser $browser) {
            $browser->loginAs($this->user)
                ->visit('/image#/folder/1')
                ->waitUntilMissing('div.loading-spinner')
                
                // Assert a single image can be opened in a modal popup.
                ->mouseover('...')
                ->click('...')
                ->waitUntilMissing('div.loading-spinner')
                ->assertPresent('div.modal')

                // Assert "X" closes the image popup.
                ->click('svg[data-icon="times"]')
                ->assertMissing('div.modal')
                
                // Assert forward reopens the image popup.
                ->forward()
                ->waitUntilMissing('div.loading-spinner')
                ->assertPresent('div.modal')
            ;
        });
    }

@digitalgrease
Copy link
Author

Here is the implementation I have in my local copy.

    /**
     * Navigate to the next page.
     *
     * @return $this
     */
    public function forward()
    {
        $this->driver->navigate()->forward();

        return $this;
    }

@driesvints
Copy link
Member

Okay, you may send in a PR if you like but it's up to Taylor to decide upon it eventually. Please make sure to provide a thorough explanation in your PR comment and add tests for the new feature. Thanks!

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

Successfully merging a pull request may close this issue.

2 participants