forked from ageoldpun/amazon_gifts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buy_card.js
26 lines (24 loc) · 1.39 KB
/
buy_card.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
var webdriver = require('selenium-webdriver'),
By = require('selenium-webdriver').By,
until = require('selenium-webdriver').until;
var driver = new webdriver.Builder()
.forBrowser('chrome')
.build();
driver.get('http://www.amazon.com/');
driver.findElement(By.linkText('Sign in')).click();
driver.findElement(By.id('ap_email')).sendKeys(process.env.AMAZON_USERNAME);
driver.findElement(By.id('ap_password')).sendKeys(process.env.AMAZON_PASSWORD);
driver.findElement(By.id('signInSubmit')).click();
driver.findElement(By.linkText('Gift Cards')).click();
driver.findElement(By.linkText('Amazon.com Gift Cards - E-mail Delivery')).click();
driver.findElement(By.id('gc-order-form-custom-amount')).sendKeys('0.5');
driver.findElement(By.id('gc-order-form-recipients')).sendKeys(process.env.AMAZON_USERNAME);
driver.findElement(By.id('gc-order-form-senderName')).sendKeys(process.env.AMAZON_USERNAME);
driver.findElement(By.id('gc-mini-cart-proceed-to-checkout')).click();
driver.findElement(By.id('payment-change-link')).click();
driver.wait(until.titleIs('Select a Payment Method - Amazon.com Checkout'), 3000);
driver.findElement(By.xpath("//strong[contains(text(), 'Debit Card')]")).click();
driver.findElement(By.id('continue-top')).click();
driver.wait(until.titleIs('Place Your Order - Amazon.com Checkout'), 3000);
driver.findElement(By.xpath("//input[@name='placeYourOrder1']")).click();
driver.quit();