Skip to content

Commit

Permalink
wait for page load, close #95
Browse files Browse the repository at this point in the history
  • Loading branch information
angrykoala committed Jun 12, 2018
1 parent 1d50be8 commit 7048a94
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

* Request filter and assertion by postBody
* RequestMock object with assertion
* Browser.waitForPageLoad
* Mocks cleared on close
* BeforeClose hook in components
* ClearRequestMocks on open option
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,9 @@ await browser.setViewport({width: 300});

> Unlike Puppeteer setViewport, no parameter is required, as the current values will be used for the new viewport.
**waitForPageLoad()**
Waits until a dom ready event is fired, this method will also wait until Wendigo is ready to perform assertions on the given page.

**focus(selector)**
Focus the first element matching the given selector.

Expand Down Expand Up @@ -989,7 +992,7 @@ browser.requests.assert.responseHeaders({
Asserts that an successful response was received (status is between 200 and 299), or false if false is given.


**postBody(expected, msg?)**
**postBody(expected, msg?)**
Asserts that a request contains the given post body (regardless of method). The expected value can be a string, regex or object.

```js
Expand Down
10 changes: 10 additions & 0 deletions lib/mixins/browser_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,15 @@ module.exports = function BrowserNavigationMixin(s) {
config = Object.assign({}, this.page.viewport(), config);
return this.page.setViewport(config);
}

waitForPageLoad() {
return this.page.waitForNavigation({
waitUntil: "domcontentloaded"
}).then(() => {
return this.page.waitFor(() => {
return Boolean(window.WendigoUtils); // Waits until wendigo utils is ready
});
});
}
};
};
8 changes: 8 additions & 0 deletions tests/browser/navigation_load.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@ describe("Wait For", function() {
await browser.assert.text("p", "html_test"); // Requires WendigoUtils
});

it("Wait For Page Load", async () => {
await browser.open(configUrls.index);
await browser.click("a");
await browser.waitForPageLoad();
await browser.assert.global("WendigoUtils");
await browser.assert.text("p", "html_test");
});

});

0 comments on commit 7048a94

Please sign in to comment.