Skip to content

Commit

Permalink
fix: capture correct url for navigations
Browse files Browse the repository at this point in the history
  • Loading branch information
vigneshshanmugam committed Jul 21, 2021
1 parent 27cdd0c commit ff02ee0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
32 changes: 32 additions & 0 deletions __tests__/core/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,38 @@ describe('runner', () => {
]);
});

it('run steps - new window navigation', async () => {
const j1 = journey('j1', async ({ page, context }) => {
step('visit test page', async () => {
await page.goto(server.TEST_PAGE);
await page.setContent(
'<a target=_blank rel=noopener href="/popup.html">popup</a>'
);
});
step('click popup', async () => {
const [page1] = await Promise.all([
context.waitForEvent('page'),
page.click('a'),
]);
await page1.waitForLoadState();
});
});
const context = await Runner.createContext({});
await runner.registerJourney(j1, context);
const result = await runner.runSteps(j1, context, {});
await Gatherer.stop();
expect(result).toEqual([
{
status: 'succeeded',
url: server.TEST_PAGE,
},
{
status: 'succeeded',
url: server.PREFIX + '/popup.html',
},
]);
});

it('run steps - accumulate results', async () => {
const error = new Error('broken step 2');
const j1 = journey('j1', async ({ page }) => {
Expand Down
4 changes: 2 additions & 2 deletions src/core/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,9 @@ export default class Runner extends EventEmitter {
if (!data.url && req.isNavigationRequest()) {
data.url = req.url();
}
driver.page.off('request', captureUrl);
driver.context.off('request', captureUrl);
};
driver.page.on('request', captureUrl);
driver.context.on('request', captureUrl);
try {
pluginManager.onStep(step);
await step.callback();
Expand Down

0 comments on commit ff02ee0

Please sign in to comment.