-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
53 lines (45 loc) · 2.05 KB
/
Copy pathtest.js
File metadata and controls
53 lines (45 loc) · 2.05 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
const {Builder, By, Key, until} = require('selenium-webdriver');
let faker = require('faker');
let firstName = faker.name.firstName();
let lastName = faker.name.lastName();
let password = faker.internet.password();
let address = faker.address.streetAddress();
let email = faker.internet.email();
let city = faker.address.city();
let zipcode = faker.address.zipCode();
let arr;
if (zipcode.charAt(5) == "-") {
arr = zipcode.split("-");
zipcode = arr[0]
}
else {
zipcode = zipcode
}
let mobilePhone = faker.phone.phoneNumberFormat();
console.log("%c===CREATED USER===", "color:green");
console.log("%cNAME/EMAIL: " + firstName + " " + lastName + " " + email, "color:green");
console.log("%cPASSWORD: " + password, "color:green");
(async function example() {
let driver = await new Builder().forBrowser('chrome').build();
try {
await driver.get('http://automationpractice.com/index.php');
await driver.findElement(By.xpath('//a[@class="login"]')).click();
await driver.manage().setTimeouts( { implicit: 10000 } );
await driver.findElement(By.id('email_create')).sendKeys(email, Key.RETURN);
await driver.findElement(By.id('customer_firstname')).sendKeys(firstName);
await driver.findElement(By.id('customer_lastname')).sendKeys(lastName);
await driver.findElement(By.id('passwd')).sendKeys(password);
await driver.findElement(By.id('firstname')).sendKeys(firstName);
await driver.findElement(By.id('lastname')).sendKeys(lastName);
await driver.findElement(By.id('address1')).sendKeys(address);
await driver.findElement(By.id('city')).sendKeys(city);
await driver.findElement(By.id('postcode')).sendKeys(zipcode);
await driver.findElement(By.id('id_state')).click();
await driver.findElement(By.xpath('//select[@id="id_state"]/option[@value="9"]')).click();
await driver.findElement(By.id('phone_mobile')).sendKeys(mobilePhone, Key.RETURN);
await driver.wait(until.titleIs('My account - My Store'), 1000);
} finally {
await driver.manage().setTimeouts( { implicit: 10000 } );
await driver.quit();
}
})();