Can't interact with browser pop-up with nightwatch.js

21 Views Asked by At

This is the last I've tried, but the problem is that once the popup is on the screen, I can't use the Console to get any of the selectors, I only see the html and body tags. PLEASE HELP!

module.exports = { 'Demo test Google' : function (client) { client .url('https://practice.expandtesting.com/#examples') client.pause(1000) client.click('#examples > div:nth-child(4) > div:nth-child(3) > div > div > h3 > a') client.pause(2000) client.setValue('Username', 'testuser') client.keys.TAB client.setValue('Password', 'testpass') client.end(); } }

1

There are 1 best solutions below

1
Vladislav Bulanov On

Selenium can't interact with a native JS Alert popup (browser popup you mentioned). Consequently, it is necessary to switch to the JS Alert and utilize the appropriate methods.

Fortunately, Nightwatch methods seamlessly handle the switch to JS Alerts, leaving us only to employ the following methods:

enter image description here

In your case you will need to use setAlertText() and then accept the JS Alert after you're done using acceptAlert();

Source: https://nightwatchjs.org/v26/api/setAlertText.html