Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Nightmare = require('nightmare');
- var faker = require('faker');
- var url = 'http://celebratemydrive.com/Commit';
- var successUrl = 'http://celebratemydrive.com/CommitThanks';
- vote(process.argv[2], 1);
- function vote(max, count) {
- var page = new Nightmare();
- var success = false;
- page.goto(url);
- page.type('#txtEmail', faker.internet.email());
- page.type('#txtDOB', '10/23/1997');
- page.evaluate(function() {
- document.querySelector('option[value=student]').selected = 'selected';
- // Turn off stupid dialog on the site
- close_confirm = false;
- });
- page.click('#btnNext');
- page.wait();
- page.screenshot('test.png');
- page.type('#txtName2', 'William Mason High School');
- page.type('#txtZip', '45040');
- page.evaluate(function() { close_confirm = false; });
- page.click('#btnNext');
- page.wait();
- page.evaluate(function() {
- document.getElementById('cphBody_cphBody_rptSearchResultsReg_radResult_0').checked = true;
- close_confirm = false;
- });
- page.click('#btnNext2');
- page.wait();
- page.evaluate(function() {
- document.getElementById('radAnswer4').checked = true;
- close_confirm = false;
- });
- page.click('#btnSubmit');
- page.wait();
- page.evaluate(function() { close_confirm = false; });
- page.click('#btnNext');
- page.wait();
- page.evaluate(function() { close_confirm = false; });
- page.click('#cphBody_cphBody_divAnswerA');
- page.wait();
- page.evaluate(function() { close_confirm = false; });
- page.click('#btnNext');
- page.wait();
- // Check the url
- page.url(function(url) {
- success = url == successUrl;
- });
- page.run(function() {
- if (success) {
- console.log('Vote ' + count + ' sent ' + new Date());
- } else {
- console.log('Voting failed');
- }
- if (count < max) vote(max, ++count);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement