Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var genie = require('genie').create({ xpathVersion: '2.0' });
  2.  
  3. var x = require('casper').selectXPath;
  4. var ex = genie.extendedXpath(x);
  5.  
  6. var blacklist = ['.css', '.png', '.gif', '.jpeg', 'google-analytics', 'yandex'];
  7.  
  8. var USERNAME = "mbaltova@ceicdata.com";
  9. var PASSWORD = "ceicdata";
  10.  
  11. var files1 = genie.files();
  12.  
  13. files1.blacklist(blacklist)
  14.     .retry(5)
  15.     .add({
  16.         'file7.html': {
  17.             'fileName': "//a[contains(text(),'AMG156A')]"
  18.         },
  19.         'file9.html': {
  20.             'fileName': "//a[contains(text(),'LMV102B')]"
  21.         }
  22.     })
  23.  
  24.     .steps(function (parameters) {
  25.         this.thenOpen("http://statistici.insse.ro/shop/?lang=ro");
  26.         this.wait(5000);
  27.         this.waitForSelector(ex("//input[contains(@value,'Login')]"),function success(){
  28.                 this.sendKeys(ex("//input[contains(@name,'Login')]"), USERNAME);
  29.                 this.wait(2000);
  30.                 this.sendKeys(ex("//input[contains(@name,'Password')]"), PASSWORD);
  31.                 this.wait(2000);
  32.                 this.evaluate(function(){
  33.                     $(document).xpath("//input[contains(@value,'Login')]").click().change()
  34.                 })
  35.             },
  36.             function fail() {
  37.                 console.log("It is log in")
  38.          });
  39.         this.wait(2000);
  40.         this.waitAndClick(ex("//strong[contains(text(),'STATISTICA')]/following::*/a[contains(text(),'FORTA ')]"));
  41.         this.waitAndClick(ex(parameters.fileName));
  42.         this.wait(2000);
  43.         this.then(function(){
  44.             this.evaluate(function(){
  45.                 selectAllInSelect("pos2");
  46.                 selectAllInSelect("pos3");
  47.             });
  48.         });
  49.         this.wait(2000);
  50.         this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
  51.         this.wait(5000);
  52.     });
  53.  
  54. var files2 = genie.files();
  55.  
  56. files2.blacklist(blacklist)
  57.     .retry(5)
  58.     .add({
  59.         'file2.html': {
  60.             'fileName': "//a[contains(text(),'SOM103B')]"
  61.         },
  62.         'file3.html': {
  63.             'fileName': "//a[contains(text(),'SOM101E')]"
  64.         }
  65.     })
  66.  
  67.     .steps(function (parameters) {
  68.         this.thenOpen("http://statistici.insse.ro/shop/?lang=ro");
  69.         this.wait(5000);
  70.         this.waitForSelector(ex("//input[contains(@value,'Login')]"),function success(){
  71.                 this.sendKeys(ex("//input[contains(@name,'Login')]"), USERNAME);
  72.                 this.wait(2000);
  73.                 this.sendKeys(ex("//input[contains(@name,'Password')]"), PASSWORD);
  74.                 this.wait(2000);
  75.                 this.evaluate(function(){
  76.                     $(document).xpath("//input[contains(@value,'Login')]").click().change()
  77.                 })
  78.             },
  79.             function fail() {
  80.                 console.log("It is log in")
  81.          });
  82.         this.wait(2000);
  83.         this.waitAndClick(ex("//strong[contains(text(),'STATISTICA')]/following::*/a[contains(text(),'FORTA ')]"));
  84.         this.waitAndClick(ex(parameters.fileName));
  85.         this.wait(2000);
  86.         this.then(function(){
  87.             this.evaluate(function(){
  88.                 selectAllInSelect("pos1");
  89.             });
  90.         });
  91.         this.wait(2000);
  92.         this.then(function() {
  93.               this.capture("downloads/beforeCauta.png")
  94.         })
  95.         this.waitAndClick(ex("//option[contains(text(),'Luna')]/following::a[contains(@onclick,'All')]"))
  96.         this.wait(2000);
  97.         this.then(function() {
  98.               this.capture("downloads/beforeCauta2.png")
  99.         })
  100.         this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
  101.         this.wait(5000);
  102.     });
  103.  
  104. var files3 = genie.files();
  105.  
  106. files3.blacklist(blacklist)
  107.     .retry(5)
  108.     .add({
  109.         'file10.html': {
  110.             'fileName': "//a[contains(text(),'SOM103A')]"
  111.         },
  112.         'file11.html': {
  113.             'fileName': "//a[contains(text(),'SOM101B')]"
  114.         }
  115.     })
  116.     .steps(function (parameters) {
  117.         this.thenOpen("http://statistici.insse.ro/shop/?lang=ro");
  118.         this.wait(5000);
  119.         this.waitForSelector(ex("//input[contains(@value,'Login')]"),function success(){
  120.                 this.sendKeys(ex("//input[contains(@name,'Login')]"), USERNAME);
  121.                 this.wait(2000);
  122.                 this.sendKeys(ex("//input[contains(@name,'Password')]"), PASSWORD);
  123.                 this.wait(2000);
  124.                 this.evaluate(function(){
  125.                     $(document).xpath("//input[contains(@value,'Login')]").click().change()
  126.                 })
  127.             },
  128.             function fail() {
  129.                 console.log("It is log in")
  130.          });
  131.         this.wait(2000);
  132.         this.waitAndClick(ex("//strong[contains(text(),'STATISTICA')]/following::*/a[contains(text(),'FORTA ')]"));
  133.         this.waitAndClick(ex(parameters.fileName));
  134.         this.wait(2000);
  135.         this.waitAndClick(ex("//option[contains(text(),'Feminin ')]/following::a[contains(@onclick,'All')]"))
  136.         this.waitAndClick(ex("//option[contains(text(),'Anul ')]/following::a[contains(@onclick,'All')]"))
  137.         // this.exist doesnt work uhmmm i guess wait for selector just to check if it exist
  138.         this.waitForSelector(ex("//option[contains(text(),'Beneficiari ')]"),function success(){
  139.             this.thenEvaluate(function(){
  140.                 selectAllInSelect("pos1");
  141.             });
  142.         }, function fail() {
  143.             console.log("this is file10")
  144.         });
  145.         this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
  146.         this.wait(5000);
  147.     });
  148.  
  149.  
  150. var file14 = genie.files();
  151.  
  152. file14.blacklist(blacklist)
  153.     .retry(5)
  154.     .add("file14.html")
  155.     .steps(function (parameters) {
  156.         this.thenOpen("http://statistici.insse.ro/shop/?lang=ro");
  157.         this.wait(5000);
  158.         this.waitForSelector(ex("//input[contains(@value,'Login')]"),function success(){
  159.                 this.sendKeys(ex("//input[contains(@name,'Login')]"), USERNAME);
  160.                 this.wait(2000);
  161.                 this.sendKeys(ex("//input[contains(@name,'Password')]"), PASSWORD);
  162.                 this.wait(2000);
  163.                 this.evaluate(function(){
  164.                     $(document).xpath("//input[contains(@value,'Login')]").click().change()
  165.                 })
  166.             },
  167.             function fail() {
  168.                 console.log("It is log in")
  169.          });
  170.         this.wait(2000);
  171.         this.waitAndClick(ex("//strong[contains(text(),'STATISTICA')]/following::*/a[contains(text(),'FORTA ')]"));
  172.         this.waitAndClick(ex("//a[contains(text(),'FOM104G')]"));
  173.         this.wait(2000);
  174.         this.then(function(){
  175.             this.evaluate(function(){
  176.                 selectAllInSelect("pos4");
  177.                 selectAllInSelect("pos5");
  178.             });
  179.         });
  180.         this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
  181.         this.wait(5000);
  182.     });
  183.  
  184. var file17 = genie.files();
  185.  
  186. file17.blacklist(blacklist)
  187.     .retry(5)
  188.     .add("file17.html")
  189.     .steps(function (parameters) {
  190.         this.thenOpen("http://statistici.insse.ro/shop/?lang=ro");
  191.         this.wait(5000);
  192.         this.waitForSelector(ex("//input[contains(@value,'Login')]"),function success(){
  193.                 this.sendKeys(ex("//input[contains(@name,'Login')]"), USERNAME);
  194.                 this.wait(2000);
  195.                 this.sendKeys(ex("//input[contains(@name,'Password')]"), PASSWORD);
  196.                 this.wait(2000);
  197.                 this.evaluate(function(){
  198.                     $(document).xpath("//input[contains(@value,'Login')]").click().change()
  199.                 })
  200.             },
  201.             function fail() {
  202.                 console.log("It is log in")
  203.          });
  204.         this.wait(2000);
  205.         this.waitAndClick(ex("//strong[contains(text(),'STATISTICA')]/following::*/a[contains(text(),'FORTA ')]"));
  206.         this.waitAndClick(ex("//a[contains(text(),'FOM110A')]"));
  207.         this.waitAndClick(ex("(//select[contains(@name,'pos1')]/option)[last()-1]"))
  208.         this.waitAndClick(ex("(//select[contains(@name,'pos2')]/option)[last()]"))
  209.         this.then(function(){
  210.             this.evaluate(function(){
  211.                 $(document).xpath("//select[contains(@name,'pos1')]/option").attr('selected', false)
  212.                 $(document).xpath("//select[contains(@name,'pos2')]/option").attr('selected', false)
  213.                 $(document).xpath("(//select[contains(@name,'pos1')]/option)[last()-1]").attr('selected', true)
  214.                 $(document).xpath("(//select[contains(@name,'pos2')]/option)[last()]").attr('selected', true)
  215.             });
  216.         });
  217.         this.then(function(){
  218.              this.capture("downloads/input.png")
  219.         })
  220.         this.waitAndClick(ex("//input[contains(@value,'Cauta')]"))
  221.         this.wait(5000);
  222.     });
  223. genie.run(files1,files2,files3,file14,file17);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement