-
Notifications
You must be signed in to change notification settings - Fork 14
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
fix: premature resolution of wait conditions when using scopedBy page objects #326
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,16 @@ class BaseElement extends BasePageObject { | |
|
||
async waitForInsert() { | ||
await handleError.call(this, async () => { | ||
if (typeof this._selector === 'function') { | ||
try { | ||
return await this._browser.waitUntil(async () => await this.isExisting()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this go in the browser's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried that first and ran into so many issues because of all of the areas in which |
||
} catch (e) { | ||
// if the waitUntil condition fails fall through to the original non-scoped | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will unfortunately double the waiting time of failing tests, right? 30 secs to 60 secs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the default timeout is still 30 seconds. I tested this by commenting out all of the timeout overrides in one of the tests and allowing it to fail, which it did after 30 seconds |
||
// call so we continue to throw custom human readable faltest errors about the | ||
// element selector that is missing | ||
} | ||
} | ||
|
||
await this._browser.waitForInsert(this._selector); | ||
}, async elementError => { | ||
// If it's an expected error, that means a parent doesn't exist, | ||
|
@@ -56,6 +66,16 @@ class BaseElement extends BasePageObject { | |
|
||
async waitForDestroy() { | ||
await handleError.call(this, async () => { | ||
if (typeof this._selector === 'function') { | ||
try { | ||
return await this._browser.waitUntil(async () => !(await this.isExisting())); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. return value is not used in this method. |
||
} catch (e) { | ||
// if the waitUntil condition fails fall through to the original non-scoped | ||
// call so we continue to throw custom human readable faltest errors about the | ||
// element selector that was not destroyed | ||
} | ||
} | ||
|
||
await this._browser.waitForDestroy(this._selector, ...arguments); | ||
}, () => { | ||
// If it's an expected error, that means a parent doesn't exist, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These can go in a reusable function, kinda like
handleError
so they both can use it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you want it called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waitForScoped?