Switch to frame with Nightwatch.js

The UI I'm testing uses an iframe. I am trying to switch to this iframe with the call ".frame (0)".

module.exports = {
    "test" : function (browser) {
    browser
        .url("my_url")
        .waitForElementVisible(".frame-application-scroll-wrapper", 30000)
        .frame(0)
        .waitForElementPresent("#page-content", 30000)
        .end();
    }
};

      

However, # page-content has never been seen, which leads me to believe that the frame change command is not working (but does not return any errors).

Any ideas?

Thanks Paul

+3


source to share


2 answers


as Neoaptt mentioned (thanks!) the problem was that the iframe was either not or not loaded. Adding a pause solved my problem.

By the way, if you want to exit the selected frame, you must use ".frame (null)"

module.exports = {
    "test" : function (browser) {
    browser
        .url("my_url")
        .waitForElementVisible(".frame-application-scroll-wrapper", 30000)
        // give time to the iframe to be available
        .pause(5000)
        .frame(0)
                .waitForElementPresent("#page-content", 30000)
                .frame(null)
         // we are now back to the main page
         // ... more code here ...
         .end();
    }
};

      

Which also helped me debug using the --verbose option, for example:



nightwatch -t tests/test4.js --verbose

      

This will display in your terminal all the data that is exchanged between the nodes and selenium.

Thanks Paul

+6


source


The latest version of nightwatch - .frameParent()

instead of .frame(0)

in case anyone else finds this post :)



+1


source







All Articles