Better deal with strings in `switchWindow`
See original GitHub issueIs your feature request related to a problem? Please describe.
Currently the switchWindow
command iterates over all window handles and calls matches on url and title to see if the input matches it. This can be problematic if users use strings that contain a regexp character:
// works perfectly if you match like this
browser.switchWindow('google.com')
// doesn't work if you have a `?` character
browser.switchWindow('google.com?foobar=barfoo') // does not match the url e.g. https://google.com?foobar=barfoo
Describe the solution you’d like
Let’s check if the command input is a string and use includes
if so otherwise use match
if it is a RegExp.
Describe alternatives you’ve considered n/a
Additional context This comes from a conversation I had with someone in Gitter stumbling over this.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
switchWindow - WebdriverIO
matcher, String , RegExp, String or regular expression that matches the title and url of the page or window name ...
Read more >switchWindow | API Reference - Nightwatch.js
switchWindow (). Change focus to another window. ... handleOrName, string, The server assigned window handle or the name attribute. callback
Read more >How to handle multiple windows in Selenium - Tools QA
This method will return the value of the String type. getWindowHandles( ): To handle all opened windows which are the child windows by...
Read more >How to handle multiple windows in Selenium? - BrowserStack
Think of it as a pointer to a window, which returns the string value. It is assumed that each browser will have a...
Read more >C# switching windows in .net - Stack Overflow
SwitchToThisWindow is expecting a handle to the window that you ... we have switch window. private void switchWindow() { Process[] procs ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@christian-bromann since this has not been updated for a while, do you mind if i take a shot at it?
@kacperturon sure thing!