Advertisement
Guest User

Untitled

a guest
Oct 21st, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var Nightmare = require('nightmare');
  2. var faker = require('faker');
  3. var url = 'http://celebratemydrive.com/Commit';
  4. var successUrl = 'http://celebratemydrive.com/CommitThanks';
  5.  
  6. vote(process.argv[2], 1);
  7.  
  8. function vote(max, count) {
  9.   var page = new Nightmare();
  10.   var success = false;
  11.  
  12.   page.goto(url);
  13.  
  14.   page.type('#txtEmail', faker.internet.email());
  15.   page.type('#txtDOB', '10/23/1997');
  16.   page.evaluate(function() {
  17.     document.querySelector('option[value=student]').selected = 'selected';
  18.     // Turn off stupid dialog on the site
  19.     close_confirm = false;
  20.   });
  21.   page.click('#btnNext');
  22.   page.wait();
  23.  
  24.   page.screenshot('test.png');
  25.   page.type('#txtName2', 'William Mason High School');
  26.   page.type('#txtZip', '45040');
  27.   page.evaluate(function() { close_confirm = false; });
  28.   page.click('#btnNext');
  29.   page.wait();
  30.  
  31.   page.evaluate(function() {
  32.     document.getElementById('cphBody_cphBody_rptSearchResultsReg_radResult_0').checked = true;
  33.     close_confirm = false;
  34.   });
  35.   page.click('#btnNext2');
  36.   page.wait();
  37.  
  38.   page.evaluate(function() {
  39.     document.getElementById('radAnswer4').checked = true;
  40.     close_confirm = false;
  41.   });
  42.   page.click('#btnSubmit');
  43.   page.wait();
  44.  
  45.   page.evaluate(function() { close_confirm = false; });
  46.   page.click('#btnNext');
  47.   page.wait();
  48.  
  49.   page.evaluate(function() { close_confirm = false; });
  50.   page.click('#cphBody_cphBody_divAnswerA');
  51.   page.wait();
  52.  
  53.   page.evaluate(function() { close_confirm = false; });
  54.   page.click('#btnNext');
  55.   page.wait();
  56.  
  57.   // Check the url
  58.   page.url(function(url) {
  59.     success = url == successUrl;
  60.   });
  61.  
  62.   page.run(function() {
  63.     if (success) {
  64.       console.log('Vote ' + count + ' sent ' + new Date());
  65.     } else {
  66.       console.log('Voting failed');
  67.     }
  68.     if (count < max) vote(max, ++count);
  69.   });
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement