Saturday 20 May 2017

How to Get Window Variable Using WebdriverIO

I am trying to run webdriverio with PhantomJS/Chrome to load a page and then grab the window object for use with other scripts. For some reason I am unable to get the window object. Everytime I get, I end up seeing output like this:

Title is: XXXXX
{ state: 'pending' }

Using the following script:

var webdriverio = require('webdriverio');
var options = {
    desiredCapabilities: {
        browserName: 'chrome',
        logLevel: 'verbose'
    }
};

var client = webdriverio.remote(options);

client
     .init()
     .url('https://xxxx.com')
     .waitUntil(function () {
         return client.execute(function () {
             return Date.now() - window.performance.timing.loadEventEnd > 40000;
        }).then(function (result) {
             console.log(window);
             return window;
         });
     })
     .end();

Does anyone know how I can fix my code so that the window object is returned to my NodeJS console app after the page is completely loaded?

Thanks!



via user2476265

No comments:

Post a Comment