Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var genie = require('genie').create({ xpathVersion: '2.0' });
- var x = require('casper').selectXPath;
- var ex = genie.extendedXpath(x);
- var blacklist = ['.css', '.png', '.gif', '.jpeg', 'google-analytics', 'yandex'];
- var USERNAME = "mbaltova@ceicdata.com";
- var PASSWORD = "ceicdata";
- var files1 = genie.files();
- files1.blacklist(blacklist)
- .retry(5)
- .add({
- 'file7.html': {
- 'fileName': "//a[contains(text(),'AMG156A')]"
- },
- 'file9.html': {
- 'fileName': "//a[contains(text(),'LMV102B')]"
- }
- })
- .steps(function (parameters) {
- this.thenOpen("http://statistici.insse.ro/shop/?lang=ro");
- this.wait(5000);
- this.waitForSelector(ex("//input[contains(@value,'Login')]"),function success(){
- this.sendKeys(ex("//input[contains(@name,'Login')]"), USERNAME);
- this.wait(2000);
- this.sendKeys(ex("//input[contains(@name,'Password')]"), PASSWORD);
- this.wait(2000);
- this.evaluate(function(){
- $(document).xpath("//input[contains(@value,'Login')]").click().change()
- })
- },
- function fail() {
- console.log("It is log in")
- });
- this.wait(2000);
- this.waitAndClick(ex("//strong[contains(text(),'STATISTICA')]/following::*/a[contains(text(),'FORTA ')]"));
- this.waitAndClick(ex(parameters.fileName));
- this.wait(2000);
- this.then(function(){
- this.evaluate(function(){
- selectAllInSelect("pos2");
- selectAllInSelect("pos3");
- });
- });
- this.wait(2000);
- this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
- this.wait(5000);
- });
- var files2 = genie.files();
- files2.blacklist(blacklist)
- .retry(5)
- .add({
- 'file2.html': {
- 'fileName': "//a[contains(text(),'SOM103B')]"
- },
- 'file3.html': {
- 'fileName': "//a[contains(text(),'SOM101E')]"
- }
- })
- .steps(function (parameters) {
- this.thenOpen("http://statistici.insse.ro/shop/?lang=ro");
- this.wait(5000);
- this.waitForSelector(ex("//input[contains(@value,'Login')]"),function success(){
- this.sendKeys(ex("//input[contains(@name,'Login')]"), USERNAME);
- this.wait(2000);
- this.sendKeys(ex("//input[contains(@name,'Password')]"), PASSWORD);
- this.wait(2000);
- this.evaluate(function(){
- $(document).xpath("//input[contains(@value,'Login')]").click().change()
- })
- },
- function fail() {
- console.log("It is log in")
- });
- this.wait(2000);
- this.waitAndClick(ex("//strong[contains(text(),'STATISTICA')]/following::*/a[contains(text(),'FORTA ')]"));
- this.waitAndClick(ex(parameters.fileName));
- this.wait(2000);
- this.then(function(){
- this.evaluate(function(){
- selectAllInSelect("pos1");
- });
- });
- this.wait(2000);
- this.then(function() {
- this.capture("downloads/beforeCauta.png")
- })
- this.waitAndClick(ex("//option[contains(text(),'Luna')]/following::a[contains(@onclick,'All')]"))
- this.wait(2000);
- this.then(function() {
- this.capture("downloads/beforeCauta2.png")
- })
- this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
- this.wait(5000);
- });
- var files3 = genie.files();
- files3.blacklist(blacklist)
- .retry(5)
- .add({
- 'file10.html': {
- 'fileName': "//a[contains(text(),'SOM103A')]"
- },
- 'file11.html': {
- 'fileName': "//a[contains(text(),'SOM101B')]"
- }
- })
- .steps(function (parameters) {
- this.thenOpen("http://statistici.insse.ro/shop/?lang=ro");
- this.wait(5000);
- this.waitForSelector(ex("//input[contains(@value,'Login')]"),function success(){
- this.sendKeys(ex("//input[contains(@name,'Login')]"), USERNAME);
- this.wait(2000);
- this.sendKeys(ex("//input[contains(@name,'Password')]"), PASSWORD);
- this.wait(2000);
- this.evaluate(function(){
- $(document).xpath("//input[contains(@value,'Login')]").click().change()
- })
- },
- function fail() {
- console.log("It is log in")
- });
- this.wait(2000);
- this.waitAndClick(ex("//strong[contains(text(),'STATISTICA')]/following::*/a[contains(text(),'FORTA ')]"));
- this.waitAndClick(ex(parameters.fileName));
- this.wait(2000);
- this.waitAndClick(ex("//option[contains(text(),'Feminin ')]/following::a[contains(@onclick,'All')]"))
- this.waitAndClick(ex("//option[contains(text(),'Anul ')]/following::a[contains(@onclick,'All')]"))
- // this.exist doesnt work uhmmm i guess wait for selector just to check if it exist
- this.waitForSelector(ex("//option[contains(text(),'Beneficiari ')]"),function success(){
- this.thenEvaluate(function(){
- selectAllInSelect("pos1");
- });
- }, function fail() {
- console.log("this is file10")
- });
- this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
- this.wait(5000);
- });
- var file14 = genie.files();
- file14.blacklist(blacklist)
- .retry(5)
- .add("file14.html")
- .steps(function (parameters) {
- this.thenOpen("http://statistici.insse.ro/shop/?lang=ro");
- this.wait(5000);
- this.waitForSelector(ex("//input[contains(@value,'Login')]"),function success(){
- this.sendKeys(ex("//input[contains(@name,'Login')]"), USERNAME);
- this.wait(2000);
- this.sendKeys(ex("//input[contains(@name,'Password')]"), PASSWORD);
- this.wait(2000);
- this.evaluate(function(){
- $(document).xpath("//input[contains(@value,'Login')]").click().change()
- })
- },
- function fail() {
- console.log("It is log in")
- });
- this.wait(2000);
- this.waitAndClick(ex("//strong[contains(text(),'STATISTICA')]/following::*/a[contains(text(),'FORTA ')]"));
- this.waitAndClick(ex("//a[contains(text(),'FOM104G')]"));
- this.wait(2000);
- this.then(function(){
- this.evaluate(function(){
- selectAllInSelect("pos4");
- selectAllInSelect("pos5");
- });
- });
- this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
- this.wait(5000);
- });
- var file17 = genie.files();
- file17.blacklist(blacklist)
- .retry(5)
- .add("file17.html")
- .steps(function (parameters) {
- this.thenOpen("http://statistici.insse.ro/shop/?lang=ro");
- this.wait(5000);
- this.waitForSelector(ex("//input[contains(@value,'Login')]"),function success(){
- this.sendKeys(ex("//input[contains(@name,'Login')]"), USERNAME);
- this.wait(2000);
- this.sendKeys(ex("//input[contains(@name,'Password')]"), PASSWORD);
- this.wait(2000);
- this.evaluate(function(){
- $(document).xpath("//input[contains(@value,'Login')]").click().change()
- })
- },
- function fail() {
- console.log("It is log in")
- });
- this.wait(2000);
- this.waitAndClick(ex("//strong[contains(text(),'STATISTICA')]/following::*/a[contains(text(),'FORTA ')]"));
- this.waitAndClick(ex("//a[contains(text(),'FOM110A')]"));
- this.waitAndClick(ex("(//select[contains(@name,'pos1')]/option)[last()-1]"))
- this.waitAndClick(ex("(//select[contains(@name,'pos2')]/option)[last()]"))
- this.then(function(){
- this.evaluate(function(){
- $(document).xpath("//select[contains(@name,'pos1')]/option").attr('selected', false)
- $(document).xpath("//select[contains(@name,'pos2')]/option").attr('selected', false)
- $(document).xpath("(//select[contains(@name,'pos1')]/option)[last()-1]").attr('selected', true)
- $(document).xpath("(//select[contains(@name,'pos2')]/option)[last()]").attr('selected', true)
- });
- });
- this.then(function(){
- this.capture("downloads/input.png")
- })
- this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
- this.wait(5000);
- });
- genie.run(files1,files2,files3,file14,file17);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement