feat: browser.waitForTarget (#3356)

This adds `browser.waitForTarget` and `browserContext.waitForTarget`. It also fixes a flaky test that was incorrectly expecting targets to appear instantly.
This commit is contained in:
Joel Einbinder
2018-10-09 14:16:53 -07:00
committed by Andrey Lushnikov
parent 07febb637c
commit 6ac66c3547
5 changed files with 110 additions and 1 deletions

View File

@@ -121,7 +121,7 @@ module.exports.addTests = function({testRunner, expect}) {
server.waitForRequest('/one-style.css')
]);
// Connect to the opened page.
const target = context.targets().find(target => target.url().includes('one-style.html'));
const target = await context.waitForTarget(target => target.url().includes('one-style.html'));
const newPage = await target.page();
// Issue a redirect.
serverResponse.writeHead(302, { location: '/injectedstyle.css' });