Update validateURL to account for more scenarios
In some scenarios, the URL will not have already changed by the time this check is being made, so if the check fails, we wait and recheck a few times
This commit is contained in:
parent
cf4c4d8585
commit
16ce5ad0e4
1 changed files with 16 additions and 2 deletions
|
|
@ -116,7 +116,21 @@ export class BasePage {
|
|||
}
|
||||
|
||||
async validateURL(url: string) {
|
||||
const currentUrl = this.page.url();
|
||||
expect(currentUrl).toEqual(url);
|
||||
let failCount = 0;
|
||||
/*
|
||||
We can't assume that the URL has already changed when we get here, but the point of this
|
||||
is to help speed up tests, so we want to move on as soon as we can if this passes, but
|
||||
without waiting too long if it fails
|
||||
*/
|
||||
while(failCount < 10) {
|
||||
await this.page.waitForTimeout(1000);
|
||||
const currentUrl = this.page.url();
|
||||
if(currentUrl == url)
|
||||
break;
|
||||
else {
|
||||
failCount++;
|
||||
}
|
||||
}
|
||||
expect(failCount).not.toEqual(10);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue