Skip to content
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(api): redo waitFor* methods #188

Merged
merged 4 commits into from
Jan 5, 2021
Merged

Conversation

yury-s
Copy link
Member

@yury-s yury-s commented Jan 5, 2021

Current waitFor* methods are easy to misuse as they require calling .get() on the returned object which is easy to forget if you just want to wait for certain condition and don't use the result. The API is updated in the following way:

  • The following methods keep their name (starting with waitFor) but become synchronous and have different return type.
waitForElementState => void waitForElementState
waitForFunction => JSHandle waitForFunction
waitForLoadState => void waitForLoadState
waitForSelector => ElementHandle waitForSelector
waitForTimeout => void waitForTimeout
  • Some of the methods have been renamed and now start with future prefix. They are non-blocking and still return Deferred<> object:
waitForEvent => futureEvent
waitForNavigation => futureNavigation
waitForRequest => futureRequest
waitForResponse => futureResponse

As before the client has to call .get() on the returned object in order to retrieve the result. .get() call is blocking. In the future we may add corresponding synchronous waitFor* methods for convenience if need be.

Change in the behavior of waitForFunction is probably the most controversial as now there is no way to create the function before doing some actions with the page. Again if that turns out to be a problem in practice we'll add futureCondition or something that would restore existing behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant