Just struggled with this for a while. The key, for me at least, was to remove the var casper = require('casper').create(...)
altogether. Apparently, it's not required when running tests with "casperjs test myfile.js".
casperjs test script not exporting XML file properly
Question
i have an upload.js test script that looks like this --
casper.test.comment('upload test!');
var casper=require('casper').create({
waitTimeout: 30000, //max out upload time
});
var fileName='/Users/steven/test.png';
casper.start('http://steven.dev/', function () {
casper.thenClick('#btn_upload', function () {
this.test.assertUrlMatch ('http://steven.dev/upload', 'on upload page ');
});
casper.then(function(){
this.evaluate(function(fileName)
{__utils__.findOne('input[type="file"]').setAttribute('value',fileName)},
{fileName:fileName});
this.echo('Name='+this.evaluate(function() {return
__utils__.findOne('input[type="file"]').getAttribute('name')}));
this.echo('Value='+this.evaluate(function() {return
__utils__.findOne('input[type="file"]').getAttribute('value')}));
this.page.uploadFile('input[type="file"]',fileName);
});
casper.then(function() {
this.click('#submit_button');
});
casper.waitForSelector('.upload_progress', function() {
this.echo('uploading...');
});
casper.waitForText("Done!", function() {
this.echo('success!');
});
casper.then(function() {
this.test.assertVisible ('#tools','see tools');
});
casper.run(function() {
this.test.done(2);
this.exit();
});
when i run this test with the --xunit
parameter, like casperjs test upload.js --xunit=log.xml
, it just runs the test and doesn't export the log file. i have 2 other tests in my suite that export the file just fine. wtf!
La solution
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow