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";
- function commonSteps() {
- 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("Already log in")
- });
- this.wait(2000);
- this.waitAndClick(ex("//a[contains(text(),'MISCAREA')]/following::a[contains(text(),'FORTA')]"));
- this.waitAndClick(ex(parameters.fileName));
- }
- var files1 = genie.files();
- files1.blacklist(blacklist)
- .retry(5)
- .add({
- 'file1.html': {
- 'fileName': "//a[contains(text(),'AMG157H')]"
- },
- 'file4.html': {
- 'fileName': "//a[contains(text(),'FOM105E')]"
- },
- 'file5.html': {
- 'fileName': "//a[contains(text(),'AMG155A')]"
- },
- 'file12.html': {
- 'fileName': "//a[contains(text(),'FOM103D')]"
- },
- 'file13.html': {
- 'fileName': "//a[contains(text(),'FOM111C')]"
- }
- })
- .steps(function (parameters) {
- this.thenOpen("http://statistici.insse.ro/shop/?lang=ro");
- // this.then(function(){
- // commonSteps.call(this);
- // })
- commonSteps.call(this);
- this.then(function(){
- var html_url = this.getElementsAttribute(ex("//a[starts-with(@onclick,'selectAllInSelect')]"), "href");
- console.log("================ " +html_url.length)
- this.evaluate(function(){
- selectAllInSelect("pos1");
- selectAllInSelect("pos2");
- selectAllInSelect("pos3");
- });
- if (html_url==4){
- this.evaluate(function(){
- selectAllInSelect("pos4");
- });
- }
- else if (html_url==5){
- this.evaluate(function(){
- selectAllInSelect("pos4");
- selectAllInSelect("pos5");
- });
- }
- });
- this.wait(2000);
- this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
- this.wait(5000);
- });
- var files2 = genie.files();
- files2.blacklist(blacklist)
- .retry(5)
- .add({
- 'file15.html': {
- 'fileName': "//a[contains(text(),'FOM104F')]"
- },
- 'file16.html': {
- 'fileName': "//a[contains(text(),'FOM105F')]"
- }
- })
- .steps(function (parameters) {
- this.thenOpen("http://statistici.insse.ro/shop/?lang=ro");
- commonSteps.call(this);
- // 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.then(function(){
- // this.capture("downloads/input.png")
- // })
- // this.evaluate(function(){
- // $(document).xpath("//input[contains(@value,'Login')]").click().change()
- // })
- // },
- // function fail() {
- // console.log("Already log in")
- // });
- // this.wait(2000);
- // this.waitAndClick(ex("//a[contains(text(),'MISCAREA')]/following::a[contains(text(),'FORTA')]"));
- // this.waitAndClick(ex(parameters.fileName));
- this.wait(5000);
- this.then(function(){
- this.evaluate(function(){
- selectAllInSelect("pos1");
- selectAllInSelect("pos4");
- });
- });
- this.wait(2000);
- this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
- this.wait(5000);
- });
- var files3 = genie.files();
- files3.blacklist(blacklist)
- .retry(5)
- .add({
- 'file6.html': {
- 'fileName': "//a[contains(text(),'AMG155B')]"
- },
- 'file8.html': {
- 'fileName': "//a[contains(text(),'AMG156B')]"
- }
- })
- .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.then(function(){
- this.capture("downloads/input.png")
- })
- this.evaluate(function(){
- $(document).xpath("//input[contains(@value,'Login')]").click().change()
- })
- },
- function fail() {
- console.log("Already log in")
- });
- this.wait(2000);
- this.waitAndClick(ex("//a[contains(text(),'MISCAREA')]/following::a[contains(text(),'FORTA')]"));
- this.waitAndClick(ex(parameters.fileName));
- this.wait(2000);
- this.then(function(){
- this.evaluate(function(){
- $(document).xpath("//option[contains(text(),'Total ')]").attr('selected', false)
- $(document).xpath("//option[contains(text(),'Urban')]").attr('selected', true)
- $(document).xpath("//option[contains(text(),'Rural')]").attr('selected', true)
- selectAllInSelect("pos3");
- });
- });
- this.wait(2000);
- this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
- this.wait(5000);
- });
- genie.run(files1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement