David C
David C

Reputation: 389

Nightwatch switchWindow() not working in Google Chrome

I have a test that cause a new window to open that contains a form to fill out. In FireFox it works to switch to this window using browser.switchWindow(windowName), but in Chrome it does not seem to switch to the window as it is then unable to find the form to fill out in the new window.

Anyone run into anything like this and have a possible solution? Thanks!

Edit:

This is a small code snippet I found showing what I did.

browser
  .click('selector') // Button click to open new window
  .pause(1000)
  .switchWindow('newWindowID')

Upvotes: 2

Views: 2705

Answers (3)

Govind
Govind

Reputation: 683

if it is not working for some of you, specially in mac machine then try below thing : Starting with version 75, Chromedriver has W3C Webdriver protocol enabled by default. If you'd like to stick to the JSONWire for now adjust the chromeOptions:

chromeOptions: { w3c: false }

into nightwatch.json file

Upvotes: 0

Andy Pohl
Andy Pohl

Reputation: 253

I can't leave a comment because of not a high enough reputation, but I was wondering if you could show your code for the solution to this. I am trying to figure out how to get this same scenario to work, and am stumped. Thanks

Upvotes: 0

David C
David C

Reputation: 389

I got it to work, for me it was as simple as putting a short pause() before trying to switchWindow(). It seems it tried to switch to the new window before it actually opened.

Upvotes: 1

Related Questions