Switching between browser tabs

3,265 views
Skip to first unread message

Vsevolod Sergienko

unread,
Apr 25, 2015, 11:09:32 AM4/25/15
to nightw...@googlegroups.com
Hi Andrei,

can you please tell me if there's a way to switch between browser tabs using nightwatch?

or if there isn't i'd appreciate a tip how to implement custom function to do so.
i've looked all docs and code references and wasn't able to find anything even distantly related

Thanks

Jared Payne

unread,
Aug 19, 2015, 4:44:21 PM8/19/15
to NightwatchJs
           browser

.window_handles(function(result) {
                var newHandle = result.value[0];
                this.switchWindow(newHandle);
            })

Vsevolod Serhiyenko

unread,
Aug 19, 2015, 7:37:13 PM8/19/15
to nightw...@googlegroups.com
yah, thanks a lot Jared!
but it's long implemented :)

--
You received this message because you are subscribed to a topic in the Google Groups "NightwatchJs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nightwatchjs/31oFNtA0qZ0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nightwatchjs...@googlegroups.com.
To post to this group, send email to nightw...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nightwatchjs/869994c2-b60a-4ce3-bdf4-665087a98fde%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Vsevolod Sergiyenko
QA Team Lead
Skype: ac4bussiness


Anthony Beck

unread,
Feb 4, 2016, 4:47:24 PM2/4/16
to NightwatchJs
Thanks for sharing this solution. It really helped!


On Saturday, April 25, 2015 at 8:09:32 AM UTC-7, Vsevolod Sergienko wrote:

Jaime Wissner

unread,
Jun 27, 2016, 1:52:00 PM6/27/16
to NightwatchJs
Hi, the solution given here doesn't work. Maybe it used to, but it doesn't anymore. Any other solutions?

David Linse

unread,
Jun 27, 2016, 2:28:48 PM6/27/16
to nightw...@googlegroups.com

hi..
just out of interests..
what's the actual use case or what is the scenario you want to test ?

regards
~david

--
You received this message because you are subscribed to the Google Groups "NightwatchJs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nightwatchjs...@googlegroups.com.

To post to this group, send email to nightw...@googlegroups.com.

Jaime Wissner

unread,
Jun 27, 2016, 2:33:43 PM6/27/16
to NightwatchJs
I'm just tasked right now with being able to switch tabs for tests which involve links opening in other tabs. Right now my test is simply opening the browser, opening a new tab, and attempting to switch tabs. When I run window_handles with two tabs fully loaded, I only get one handle. This is on Windows 10 Firefox 42

David Linse

unread,
Jun 27, 2016, 2:57:08 PM6/27/16
to nightw...@googlegroups.com

thanks for the explanation..
i've successfully used `window_handles` on osx using both, java and chromedriver ..
is the code working for other browsers or did you tried an other ?

regards
~david

Jaime Wissner

unread,
Jun 27, 2016, 3:02:42 PM6/27/16
to NightwatchJs
It's working on chrome. I had never tried it on chrome. Are there solutions for firefox? Testing all browser is, obviously, critical.

Jaime Wissner

unread,
Jun 27, 2016, 3:05:34 PM6/27/16
to NightwatchJs
Actually, I stand corrected. it is NOT working. Tabs are being assigned their own handles, but running this code does NOT switch the tab on my end.

Anshika Saxena

unread,
Feb 12, 2020, 5:17:21 AM2/12/20
to NightwatchJs
Hi Team,

I am trying to switch between one tab to another in chrome using the same code but it is not working.

Can anyone please help me on this.

Pieraś

unread,
Feb 12, 2020, 5:23:41 AM2/12/20
to nightw...@googlegroups.com
Always provide some code you are using and error debug.

Anshika Saxena

unread,
Feb 12, 2020, 5:28:46 AM2/12/20
to NightwatchJs
  browser

.window_handles(function(result) {
                var newHandle = result.value[0];
                this.switchWindow(newHandle);
            })

Reply all
Reply to author
Forward
0 new messages