Last active
December 20, 2018 18:39
-
-
Save michimau/8133381c32c874637d8bc6a350a9352f to your computer and use it in GitHub Desktop.
deleting undesired harvest sources of sds. usage: casperjs test casperjs-delete-harvesting-sources.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var x = require('casper').selectXPath; | |
casper.options.viewportSize = {width: 1920, height: 982}; | |
casper.on('page.error', function(msg, trace) { | |
this.echo('Error: ' + msg, 'ERROR'); | |
for(var i=0; i<trace.length; i++) { | |
var step = trace[i]; | |
this.echo(' ' + step.file + ' (line ' + step.line + ')', 'ERROR'); | |
} | |
}); | |
casper.test.begin('Resurrectio test', function(test) { | |
casper.start('http://semantic.eea.europa.eu/'); | |
casper.waitForSelector(x("//a[normalize-space(text())='Login']"), | |
function success() { | |
test.assertExists(x("//a[normalize-space(text())='Login']")); | |
this.click(x("//a[normalize-space(text())='Login']")); | |
}, | |
function fail() { | |
test.assertExists(x("//a[normalize-space(text())='Login']")); | |
}); | |
casper.waitForSelector("input[name='username']", | |
function success() { | |
this.sendKeys("input[name='username']", "myUsername"); | |
}, | |
function fail() { | |
test.assertExists("input[name='username']"); | |
}); | |
casper.waitForSelector("#login", | |
function success() { | |
test.assertExists("#login"); | |
this.click("#login"); | |
}, | |
function fail() { | |
test.assertExists("#login"); | |
}); | |
casper.waitForSelector("input[name='password']", | |
function success() { | |
this.sendKeys("input[name='password']", "myPassword"); | |
}, | |
function fail() { | |
test.assertExists("input[name='password']"); | |
}); | |
casper.waitForSelector(".row.btn-row", | |
function success() { | |
test.assertExists(".row.btn-row"); | |
this.click(".row.btn-row"); | |
}, | |
function fail() { | |
test.assertExists(".row.btn-row"); | |
}); | |
casper.waitForSelector("form#fm1 input[type=submit][value='LOGIN']", | |
function success() { | |
test.assertExists("form#fm1 input[type=submit][value='LOGIN']"); | |
this.click("form#fm1 input[type=submit][value='LOGIN']"); | |
}, | |
function fail() { | |
test.assertExists("form#fm1 input[type=submit][value='LOGIN']"); | |
}); | |
/* submit form */ | |
casper.waitForSelector(x("//a[normalize-space(text())='Harvesting sources']"), | |
function success() { | |
test.assertExists(x("//a[normalize-space(text())='Harvesting sources']")); | |
this.click(x("//a[normalize-space(text())='Harvesting sources']")); | |
}, | |
function fail() { | |
test.assertExists(x("//a[normalize-space(text())='Harvesting sources']")); | |
}); | |
casper.waitForSelector("form#filterForm input[name='searchString']", | |
function success() { | |
test.assertExists("form#filterForm input[name='searchString']"); | |
this.click("form#filterForm input[name='searchString']"); | |
}, | |
function fail() { | |
test.assertExists("form#filterForm input[name='searchString']"); | |
}); | |
casper.waitForSelector("input[name='searchString']", | |
function success() { | |
this.sendKeys("input[name='searchString']", "http://www.eea.europa.eu/acl_users/credentials_cookie_auth"); | |
}, | |
function fail() { | |
test.assertExists("input[name='searchString']"); | |
}); | |
casper.waitForSelector("form#filterForm input[type=submit][value='Filter']", | |
function success() { | |
test.assertExists("form#filterForm input[type=submit][value='Filter']"); | |
this.click("form#filterForm input[type=submit][value='Filter']"); | |
}, | |
function fail() { | |
test.assertExists("form#filterForm input[type=submit][value='Filter']"); | |
}); | |
casper.waitForSelector("#resultSetForm div:nth-child(2)", | |
function success() { | |
test.assertExists("#resultSetForm div:nth-child(2)"); | |
this.click("#resultSetForm div:nth-child(2)"); | |
}, | |
function fail() { | |
test.assertExists("#resultSetForm div:nth-child(2)"); | |
}); | |
casper.waitForSelector("form#resultSetForm input[type=button][value='Select all']", | |
function success() { | |
test.assertExists("form#resultSetForm input[type=button][value='Select all']"); | |
this.click("form#resultSetForm input[type=button][value='Select all']"); | |
}, | |
function fail() { | |
test.assertExists("form#resultSetForm input[type=button][value='Select all']"); | |
}); | |
casper.waitForSelector("form#resultSetForm input[type=submit][value='Delete']", | |
function success() { | |
test.assertExists("form#resultSetForm input[type=submit][value='Delete']"); | |
this.click("form#resultSetForm input[type=submit][value='Delete']"); | |
}, | |
function fail() { | |
test.assertExists("form#resultSetForm input[type=submit][value='Delete']"); | |
}); | |
/* submit form */ | |
casper.run(function() {test.done();}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment