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

switchTo with empty string should throw error #1057

Closed
Debashis9012 opened this issue Jan 28, 2020 · 2 comments · Fixed by #1118
Closed

switchTo with empty string should throw error #1057

Debashis9012 opened this issue Jan 28, 2020 · 2 comments · Fixed by #1118
Labels

Comments

@Debashis9012
Copy link
Contributor

Expected behavior

switchTo("") should throw the below error.

 ✘ Error: The "targetUrl" argument must be of type string or regex. 

Actual behavior

switchTo("")
✔ Switched to tab matching

Versions

commit: 8bf5be40abd96c2f391d94665e3005929d838de8
@luciferankon
Copy link
Contributor

targetUrl is of type string why should it throw
✘ Error: The "targetUrl" argument must be of type string or regex.
this error? Does not it makes sense to provide a error which makes more sense to user about what happened?
something like targetUrl should not be empty

@zabil
Copy link
Member

zabil commented Feb 28, 2020

something like targetUrl should not be empty

Agree, but it should be a mix. The type of the argument also indicates that what's possible and the user can discover the support for regex. the message can be

In this case however, I think it should not switch to "" as there is not tab or window with that name so more importantly it should raise an error saying

Error: Cannot switch to tab or window. Hint: The targetUrl is empty. Please use a valid string or regex.

luciferankon added a commit that referenced this issue Mar 9, 2020
zabil added a commit that referenced this issue Mar 10, 2020
* Throw error when supplied targetUrl to switchTo is empty #1057
* Checked for only spaces #1057
* Remove period

The full message is "Error: Cannot switch to tab or window. Hint: The targetUrl is empty. Please use a valid string or regex, run `.trace` for more info."

* Update test/unit-tests/switchTo.test.js

The full message is "Error: Cannot switch to tab or window. Hint: The targetUrl is empty. Please use a valid string or regex, run `.trace` for more info."

* Update test/unit-tests/switchTo.test.js

The entire message is "Error: Cannot switch to tab or window. Hint: The targetUrl is empty. Please use a valid string or regex, run `.trace` for more info."

Co-authored-by: Vinay Shankar Shukla <vinaysh@thoughtworks.com>
Co-authored-by: Zabil Cheriya Maliackal <zabil@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants