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

[6.x] Support waiting for URLs with waitForLocation #916

Merged
merged 1 commit into from
Aug 16, 2021
Merged

[6.x] Support waiting for URLs with waitForLocation #916

merged 1 commit into from
Aug 16, 2021

Conversation

SjorsO
Copy link
Contributor

@SjorsO SjorsO commented Aug 15, 2021

One of my projects has a model that returns a dynamic URL. In my test, I want Dusk to click a link, and then wait for that location. The test looks something like this:

$browser->click('@visit-'.$model->id)
    ->waitForLocation($model->detail_page_url)
    ...

The code above doesn't work, because $model->detail_page_url returns a full URL, but waitForLocation can only wait for paths (/some-path). This PR updates waitForLocation so it can also wait for full URLs. There is currently no method to wait for a URL.

I've chosen to use ${location.protocol}//${location.host}${location.pathname} to get the current URL (taken from this StackOverflow answer). This way query parameters and fragment identifiers (#) in the current URL are ignored.

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 this pull request may close these issues.

2 participants