How to correctly waitFor() a saveScreenShot() end of execution.
Posted
by
Alain
on Stack Overflow
See other posts from Stack Overflow
or by Alain
Published on 2013-10-17T21:51:20Z
Indexed on
2013/10/17
21:53 UTC
Read the original article
Hit count: 285
Here is my full first working test:
var expect = require('chai').expect;
var assert = require('assert');
var webdriverjs = require('webdriverjs');
var client = {};
var webdriverOptions = {
desiredCapabilities: {
browserName: 'phantomjs'
},
logLevel: 'verbose'
};
describe('Test mysite', function(){
before(function() {
client = webdriverjs.remote( webdriverOptions );
client.init();
});
var selector = "#mybodybody";
it('should see the correct title', function(done) {
client.url('http://localhost/mysite/')
.getTitle( function(err, title){
expect(err).to.be.null;
assert.strictEqual(title, 'My title page' );
})
.waitFor( selector, 2000, function(){
client.saveScreenshot( "./ExtractScreen.png" );
})
.waitFor( selector, 7000, function(){ })
.call(done);
});
after(function(done) {
client.end(done);
});
});
Ok, it does not do much, but after working many hours to get the environement correctly setup, it passed. Now, the only way I got it working is by playing with the waitFor() method and adjust the delays. It works, but I still do not understand how to surely wait for a png file to be saved on disk. As I will deal with tests orders, I will eventually get hung up from the test script before securely save the file.
Now, How can I improve this screen save sequence and avoid loosing my screenshot ?
Thanks.
© Stack Overflow or respective owner