navigateToReschedule() {
    this.spooky.waitForSelector('a[href="/main/goes/HomePagePreAction.do"]',
      function() {
        this.click('a[href="/main/goes/HomePagePreAction.do"]');
      });

    this.spooky.waitForSelector('input[name="manageAptm"]',
      function() {
        this.click('input[name="manageAptm"]');
      });

    this.spooky.waitForSelector('input[name="reschedule"]',
      function() {
        this.click('input[name="reschedule"]');
      });
  }
 login(username, password) {
   this.spooky.waitForSelector('input[name="username"]',
     [{ username: config.USERNAME, password: config.PASSWORD },
       function() {
         this.fillSelectors('form[action="/pkmslogin.form"]', {
           'input[name="username"]': username,
           'input[name="password"]': password,
         }, true);
       },
     ]);
 }
Beispiel #3
0
        }, function askVladimirVladimirovich(err) {
            if (err) {
                e = new Error('Failed to initialize SpookyJS');
                e.details = err;
                reject(e);
            }
            spooky.start('http://sprosi-putina.ru/');

            spooky.then([{question: question}, function() {
                this.fill('form[name="askmore"]', { questionask: question}, false);
            }]);

            spooky.then(function clickSend() {
                this.mouse.click("#send");
            });

            spooky.waitForSelector('.answer', function readAnswer() {
                this.emit('answerisready', this.evaluate(function () {
                    return document.querySelector('.answer').textContent;
                }));
            });

            spooky.run();
        });
Beispiel #4
0
  }, function(err) {
    if(err) {
      e = new Error('Failed to initialize SpookyJS');
      e.details = err;
      throw e;
    }

    spooky.start('https://www.lifemiles.com/index.aspx');
    //spooky.viewport(1500,1500);
    spooky.then(function() {
      this.fill('#status-bar', {
        'txtUser': '******',
        'username-pass': '******',
        'txtPassword': '******'
      }, false);
      this.wait(1000);
    });

    spooky.then(function clickButton() {
      this.click('#botonlogin');
      this.wait(1000);
    });

    spooky.waitForSelector('#botonlogin', function() {
      this.click('#botonlogin');
    });

    spooky.thenOpen('https://www.lifemiles.com/eng/use/red/dynredpar.aspx');
    
    spooky.then([{
      departure: departure,
      arrival: arrival,
      depTime: depTime,
      arrTime: arrTime,
      depCode: depCode,
      arrCode: arrCode
    }, function() {

      this.emit('clog', 'reach login');
      this.evaluate(function(
        departure,
        arrival,
        depTime,
        arrTime,
        depCode,
        arrCode
        ) {
        $("#cmbOrigen option:selected")[0].text = departure;
        $("#cmbOrigen option:selected")[0].value = depCode;
        $('#textOrigen').val(departure);
        $('#textDestino').val(arrival);

        $("#cmbDestino option:selected")[0].text = arrival;
        $("#cmbDestino option:selected")[0].value = arrCode;
        $('#fechaSalida').val(depTime);
        $('#fechaRegreso').val(arrTime);
        
        //sample date: 9/18-9/26

        submitForm();
      }, {
        departure: departure,
        arrival: arrival,
        depTime: depTime,
        arrTime: arrTime,
        depCode: depCode,
        arrCode: arrCode
      });

    }]);

    spooky.then(function clickButton() {
      this.capture('filled.png');
    });

    spooky.waitForSelector('#aspnetForm', function() {
      
      this.echo(this.getCurrentUrl());
      this.capture('success.png');
      this.evaluate(function() {
        submitForm();
      });
      this.emit('page.loaded',this.getHTML('html', true));
//      this.capture('success2.png');
    }, function() {
      this.echo("Timeout reached");
      this.echo(this.getCurrentUrl());
      this.capture('fail.png');
      this.emit('page.loaded',this.getHTML('html', true));
      // do something
    }, 30000);

    spooky.then(function() {
      this.emit('clog', 'finished');
    });

    spooky.run();
  });