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

[Feature] waitFor() with string for selectorOrFunctionOrTimeout - return of JSHandle or ElementHandle #1993

Closed
thernstig opened this issue Apr 27, 2020 · 2 comments · Fixed by #1995

Comments

@thernstig
Copy link
Contributor

thernstig commented Apr 27, 2020

https://github.com/microsoft/playwright/blob/master/docs/api.md#pagewaitforselectororfunctionortimeout-options-arg says it returns a JSHandle, but in case of the argument selectorOrFunctionOrTimeout being a string, the function is a shortcut for waitForSelector, which returns an ElementHandle.

Is there any way to improve in this area in regards to docs/code completion (such as VS Code IntelliSense)? Or is waitFor actually always returning a JSHandle even though selectorOrFunctionOrTimeout is a string?

If it always returns a JSHandle, is it recommended to actually use waitForSelector instead?

(Maybe the function should be removed completely and a new waitForTimeout would be better?)

@thernstig thernstig changed the title [Feature] waitFor() with string - return of JSHandle or ElementHandle [Feature] waitFor() with string for selectorOrFunctionOrTimeout - return of JSHandle or ElementHandle Apr 27, 2020
@thernstig
Copy link
Contributor Author

@pavelfeldman Great to see a change here. A question: Should waitForSelector() be deprecated instead and waitFor() be the same as waitForSelector() was?

I understand this is less than ideal with the actual name. But the reason I ask is that waitFor() is shorter and I've noticed that often using waitForSelector() wraps on a new line for the input (the selector) as it becomes longer (and if you use code formatters that only allow 80 chars width it is quite common it wraps).

A minor thing maybe, but still wanted to ask.

@thernstig
Copy link
Contributor Author

@pavelfeldman Just wanted to see if you had any input on my last comment here. I'm not sure myself if a change is good, but good to get your reasoning around this as you are the expert.

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 a pull request may close this issue.

1 participant