var checkout = function(done) {
  async.series([
    print('Checking out...'),
    $.go(false, 'waitForElement', 'a#gotoCheckoutBtn'),
    $('a#gotoCheckoutBtn').go(false, 'click'),
    $.go(false, 'waitForElement', '#selectPaymentType'),
    selectVal('#selectPaymentType', 'Credit Card', true),
    $.go(false, 'waitForElement', 'div#cards'),
    selectCard,
    selectVal('#selectPaymentType', 'Credit Card', true),
    enterCardNumber,
    enterCardExpire,
    enterCardCode,
    enterCardName,
    setInput('#tipAmount', 'tip'),
    setInput('#billingAddress', 'billing_address'),
    setInput('#billingCity', 'billing_city'),
    selectVal('#stateSelect', 'billing_state'),
    setInput('#billingZip', 'billing_zip'),
    $('*:contains("Review Order")').go(false, 'click'),
    $.go(false, 'waitForElement', '*:contains("Review & Place Order")'),
    setInput('#companyInput', 'company', true),
    setInput('#aptNoInput', 'apt/suite', true),
    setInput('#gateCode', 'gate_code', true),
    setInput('#deliveryInstructions', 'delivery_instructions', true),
    sleep(1000),
    print('Placing order...'),
    $('*:contains("Place Order")').go(false, 'click'),
    $.go(false, 'waitForElement', '*:contains("Thank you for your order")'),
    $.go('capture', __dirname + '/complete.png'),
    print('Delivery on its way! Order details at ' + __dirname + '/complete.png')
  ], done);
};
var newDelivery = function(done) {
  async.series([
    print('Filling out delivery information.'),
    $.go(false, 'visit', 'https://online.jimmyjohns.com/#/deliveryaddress'),
    debugCapture('delivery1'),
    $.go(false, 'waitForElement', '#companyInput'),
    debugCapture('delivery2'),
    setInput('#companyInput', 'company', true),
    debugCapture('delivery3'),
    setInput('#addressInput', 'address'),
    debugCapture('delivery4'),
    setInput('#aptNoInput', 'apt/suite', true),
    debugCapture('delivery5'),
    setInput('#cityInput', 'city'),
    debugCapture('delivery6'),
    selectVal('#stateSelect', 'state'),
    debugCapture('delivery7'),
    setInput('#zip', 'zip'),
    debugCapture('delivery8'),
    sleep(1000),
    $('#verifyAddressBtn').go(false, 'click'),
    $.go(false, 'waitForElement', '#confirmDeliveryAddressBtn'),
    debugCapture('delivery9'),
    sleep(1000),
    $('#confirmDeliveryAddressBtn').go(false, 'click'),
    debugCapture('delivery10'),
    $.go(false, 'waitForElement', 'a.menuTab'),
    debugCapture('delivery11'),
    print('Sucessfully filled out delivery information.'),
  ], done);
};
Exemplo n.º 3
0
  login: function(user, pass, done) {
    // Make sure we handle the case where no args are provided to login.
    if (typeof user=='function') {
      done = user;
      user = null;
    }

    var self = this;
    async.series([
      this.go('visit', '/user'),
      this.go('get', 'user', user),
      this.go('get', {name: 'pass', hidden: true}, pass),
      $('#edit-name').go('val', function() {
        return self.settings.get('user');
      }),
      $('#edit-pass').go(false, 'val', function() {
        return self.settings.get('pass');
      }),
      $('#edit-submit').go('click'),
      this.go('waitForPage'),
      function(done) {
        self.debug('Logged in as ' + self.settings.get('user') + '.');
        done();
      }
    ], done);
   },
Exemplo n.º 4
0
   createContent: function(node, done) {

    // Create the series and go add the content.
    var series = [this.go('visit', '/node/add/' + node.type)];

    // Add the title value to the text field.
    series.push($('#edit-title').go('val', node.title));

    // If they provide the body, then go ahead and add that to the fields.
    if (node.body) {
      node.fields = node.fields || {};
      node.fields['textarea[name="body[und][0][value]"]'] = {
        action: 'val',
        value: node.body
      };
    }

    // If they provide some fields.
    if (node.fields) {

      // Initialize the variables.
      var info = null, args = [];

      // Iterate through the fields.
      for (var selector in node.fields) {

        // Initialize the args
        args = [];

        // Get the selector value.
        info = node.fields[selector];

        // Get the action
        args.push(info.action ? info.action : 'val');
        if (typeof info.value !== 'undefined') {
          args.push(info.value);
        }

        // Add this field to the series.
        var element = $(selector);
        series.push(element.go.apply(element, args));
      }
    }

    // Press the submit button to create the content.
    this.debug('Creating node ' + node.title);
    series.push($('#edit-submit').go('click'));
    series.push(this.go('waitForPage'));

    // Execute the series.
    async.series(series, done);
   },
Exemplo n.º 5
0
var checkout = function(done) {
  async.series([
    print('Checking out...'),
    debugCapture('checkout1'),
    $.go(false, 'waitForElement', '#btn_order'),
    $('#btn_order').go(false, 'click'),
    sleep(2000),
    debugCapture('checkout2'),
    $(':input[value="Confirmez votre commande"]').go(false, 'click'),
    $.go(false, 'waitForPage'),
    debugCapture('complete'),
    print('Delivery on its way! Order details at ' + __dirname + '/../screenshots/complete.png')
  ], done);
};
var customizeOrder = function(done) {
  async.series([
    print('Customizing order...'),
    sleep(2000),
    $.go(false, 'waitForElement', '#textInput'),
    debugCapture('customize1'),
    setInput('#textInput', 'who'),
    debugCapture('customize2'),
    selectVal('#select_2944', 'bread'),
    debugCapture('customize3'),
    $.go(false, 'waitForElement', 'span:contains("Cut in half")'),
    debugCapture('customize4'),
    function(done) {
      if (config.get('cut')) {
        $('#chk_3894').click(done);
      }
    },
    debugCapture('customize5'),
    selectVal('#select_3963', 'drink'),
    debugCapture('customize6'),
    selectVal('#select_3882', 'chips'),
    debugCapture('customize7'),
    selectVal('#select_3992', 'cookie'),
    debugCapture('customize8'),
    selectVal('#select_3943', 'pickle'),
    debugCapture('customize9'),
    selectIngredient('Tomato'),
    debugCapture('customize10'),
    $('*:contains("Add To Order")').go(false, 'click'),
    $.go(false, 'waitForElement', '*:contains("Your Order For Delivery")'),
    debugCapture('customize11'),
    print('Done customizing order.'),
  ], done);
};
Exemplo n.º 7
0
 $(query).each(function(index, item, eachDone) {
     $(query + ':eq(' + index + ') em[title]').attr('title', function(title) {
     if (title.toLowerCase() == sandwich) {
       selection = index;
       found = true;
     }
     eachDone();
   });
 }, function() {
 prompt.get(['card'], function (err, result) {
   switch (result.card) {
     case '1':
       $('a#radio_Amex').click(done);
       break;
     case '2':
       $('a#radio_Visa').click(done);
       break;
     case '3':
       $('a#radio_Mastercard').click(done);
       break;
     case '4':
       $('a#radio_Discover').click(done);
       break;
     default:
       done(true);
       break;
   }
 });
var select = function(selector, value, done) {
  if (value) {
    $(selector + ' li:contains("' + value + '") a:eq(0)').click(function() {
      this.blur(done);
    });
  }
  else {
    done();
  }
};
Exemplo n.º 10
0
 $('input[placeholder="Search"]').val('each', function() {
   $('button.icon-search').click(function() {
     $.waitForElement('div.entry-summary:eq(0) p', function() {
       $('div.entry-summary:eq(0) p').text(function(summary) {
         console.log(summary);
         $.close();
       });
     });
   });
 });
Exemplo n.º 11
0
 $.visit("http://whatthecommit.com/", function() {
     $("#content p:first-child").text(function(text) {
         if (text) {
             callback(text);
         } else {
             callback("Sorry. Something went wrong :disappointed:");
         }
         $.close();
     });
 });
var login = function(done) {
  async.series([
    print('Logging in.'),
    $.go(false, 'visit', 'https://online.jimmyjohns.com/#/login'),
    $.go(false, 'waitForElement', '#email'),
    setInput('#email', 'email'),
    setInput('#loginPassword', {name: 'pass', hidden: true}),
    $('#loginButton').go(false, 'click'),
    $.go(false, 'waitForElement', 'p.welcomeMsg'),
    print('Successfully logged in.')
  ], done);
};
 get(param, function(err, value) {
   if (value) {
     var query = 'div.includedIngredientsWrap ';
     query += 'h4:contains("' + param + '") ';
     query += '~ span:contains("' + value + '")';
     $(query).click(function() {
       this.blur(done);
     });
   }
   else {
     done();
   }
 });
Exemplo n.º 14
0
 function() {
   // Get the next pager.
   $(context + ' .pager-next a', function(length) {
     if (length > 0) {
       this.attr('href', function(href) {
         self.visit(href, function() {
           self.eachViewItem(context, item, callback, done);
         });
       });
     }
     else {
       done();
     }
   });
 }
Exemplo n.º 15
0
 }, function() {
   if (!found) {
     console.log('Could not find your sandwich.');
     done();
   }
   else {
     // Select this sandwich.
     query += ':eq(' + selection + ') .order-input :input';
     console.log('Sandwich found at index ' + selection);
     $(query).click(function() {
         console.log('element clicked');
         done();
     });
   }
 });
    }, function() {
      if (!found) {
        console.log('Could not find your sandwich.');
        done();
      }
      else {

        // Select this sandwich.
        query += ':eq(' + selection + ')';
        console.log('Sandwich found...');
        $(query).click(function() {
          $.waitForElement('*:contains("Customize Your Order")', done);
        });
      }
    });
Exemplo n.º 17
0
var login = function(done) {
  async.series([
    print('Logging in.'),
    $.go(false, 'visit', '/glitter/index.asp'),
    $.go(false, 'waitForElement', '#txtUserName'),
    debugCapture('login1'),
    setInput('#txtUserName', 'email'),
    debugCapture('login2'),
    setInput('#txtPassword', { name: 'password', hidden: true}),
    debugCapture('login3'),
    $('#btnGo').go(false, 'click'),
    sleep(3000),
    debugCapture('login4'),
    print('Successfully logged in.'),
  ], done);
};
Exemplo n.º 18
0
 eachViewItem: function(context, item, callback, done) {
   var self = this;
   $(context + ' ' + item).each(
     function(index, element, done) {
       callback(element, done);
     },
     function() {
       // Get the next pager.
       $(context + ' .pager-next a', function(length) {
         if (length > 0) {
           this.attr('href', function(href) {
             self.visit(href, function() {
               self.eachViewItem(context, item, callback, done);
             });
           });
         }
         else {
           done();
         }
       });
     }
   );
 }
var selectSandwich = function(done) {
  console.log('Selecting sandwich.');
  var sandwich = config.get('sandwich');
  if (!sandwich) {
    console.log('No sandwich specified in your config file.');
    done(true);
  }
  else {
    sandwich = sandwich.toLowerCase();
    var found = false, selection = 0, query = 'a.menuItem span.displayName';

    // Iterate over each sandwich.
    $(query).each(function(index, item, done) {
      item.text(function(text) {
        if (text.toLowerCase().indexOf(sandwich) != -1) {
          selection = index;
          found = true;
        }
        done();
      });
    }, function() {
      if (!found) {
        console.log('Could not find your sandwich.');
        done();
      }
      else {

        // Select this sandwich.
        query += ':eq(' + selection + ')';
        console.log('Sandwich found...');
        $(query).click(function() {
          $.waitForElement('*:contains("Customize Your Order")', done);
        });
      }
    });
  }
};
Exemplo n.º 20
0
var selectSandwich = function(done) {
  var sandwich = config.get('sandwich');
  if (!sandwich) {
    console.log('No sandwich specified in your config file.');
    done(true);
  }
  else {
    sandwich = sandwich.toLowerCase();
    var found = false, selection = 0, query = '.order-line';

    // Iterate over each sandwich.
    $(query).each(function(index, item, eachDone) {
        $(query + ':eq(' + index + ') em[title]').attr('title', function(title) {
        if (title.toLowerCase() == sandwich) {
          selection = index;
          found = true;
        }
        eachDone();
      });
    }, function() {
      if (!found) {
        console.log('Could not find your sandwich.');
        done();
      }
      else {
        // Select this sandwich.
        query += ':eq(' + selection + ') .order-input :input';
        console.log('Sandwich found at index ' + selection);
        $(query).click(function() {
            console.log('element clicked');
            done();
        });
      }
    });
  }
};
Exemplo n.º 21
0
	$.visit("http://whatthecommit.com/", function() {
		$("#content p:first-child").text(function(text) {
			console.log(chalk.bgGreen(text.trim()));
			$.close();
		});
	});
Exemplo n.º 22
0
 $.waitForElement('div.entry-summary:eq(0) p', function() {
   $('div.entry-summary:eq(0) p').text(function(summary) {
     console.log(summary);
     $.close();
   });
 });
var input = function(selector, value, done) {
  $(selector).val(value, function() {
    this.blur(done);
  });
};
 function(done) {
   if (config.get('cut')) {
     $('#chk_3894').click(done);
   }
 },