Search code examples
javascripttestingautomated-testsnightwatch.jswindow-handles

Use Window_handles to click button in location pop-up, with nightwatch


I have a test in nightwatch for a function that requires you to share your location in order to show some results. Everytime i interact with that button, the geoiplocation default pop-up of the browser shows up and i need to interact with it (accept or dismiss it) in order to move on with the test.

In order to do this, i have tried acceptAlert mentioned in the Nightwatch api documentation, with no success. I read in several places that in this case you can use the command to switch to the new window, like here :

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

My problem is, how do i click that button, when i cannot view source of that pop-up to get the html for it? Or is there other way i can dismiss it?


Solution

  • so, in the end, i've got this answer from github, which says that you cannot do that, but you can set your browser to not ask for approval anymore. not very satisfying but...there you go, a workaround.