-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
112 lines (95 loc) · 4.54 KB
/
index.js
File metadata and controls
112 lines (95 loc) · 4.54 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const { Builder, By, until } = require('selenium-webdriver');
const driver = new Builder().forBrowser('chrome').build();
const credentials = {
email: 'selenium_test_email_3@mail.com',
password: 'SeleniumTestPassword3',
signUp:{
name: 'Selenium Test Name 3',
surname: 'Selenium Test SurName 3',
phone: '+38063123123124'
},
shop: {
name: 'seleniumTestShopName3',
domain: 'seleniumtestshopDomain3',
about: 'Selenium Test Shop Description 3',
city: 'Rapture',
street: 'Sander Cohen St.',
house: '0451',
facebook: 'facebook.com',
instagram: 'instagram.com',
youtube: 'youtube.com'
}
};
async function clickSignUpButton() {
driver.manage().window().maximize() ;
await driver.get('https://wstore.pro');
const signUpButtonPromise = driver.wait(until.elementLocated(By.css(`.header-links a[href='/signup']`))).then(element => driver.wait(until.elementIsVisible(element)));
signUpButtonPromise.then(element => {
element.click();
driver.wait(until.urlContains('signup')).then(() => fillAndSubmitSignupForm());
});
}
// clickSignUpButton();
async function fillAndSubmitSignupForm() {
driver.findElement(By.id('signup-name')).sendKeys(credentials.signUp.name);
driver.findElement(By.id('signup-surname')).sendKeys(credentials.signUp.surname);
driver.findElement(By.id('signup-phone')).sendKeys(credentials.signUp.phone);
driver.findElement(By.id('signup-email')).sendKeys(credentials.email);
driver.findElement(By.id('signup-password')).sendKeys(credentials.password);
driver.findElement(By.css('.signup-form-button')).click();
}
async function signIn() {
await driver.manage().window().maximize();
await driver.get('https://wstore.pro');
const signInButtonPromise = driver.wait(until.elementLocated(By.css(`.header-links a[href='/signin']`))).then(element => driver.wait(until.elementIsVisible(element)));
signInButtonPromise.then(element => {
element.click();
driver.wait(until.urlContains('signin')).then(() => fillAndSubmitSigninForm());
});
driver.wait(until.titleIs());
}
signIn();
async function fillAndSubmitSigninForm() {
driver.findElement(By.id('signin-email')).sendKeys(credentials.email);
driver.findElement(By.id('signin-password')).sendKeys(credentials.password);
driver.findElement(By.css('.signin-form-button')).click();
driver.wait(until.urlContains('dashboard')).then(() => navigateToShopCreationWizard());
}
async function navigateToShopCreationWizard() {
findShadowDomElement('dash-board', '.shop-name', driver).then(element => {
element.click();
driver.wait(until.urlContains('wizard')).then(() => fillAndSubmitWizardForm(driver));
});
}
async function getExtShadowRoot(selector) {
await (shadowHost = driver.findElement(By.css(selector)));
return driver.executeScript('return arguments[0].shadowRoot', shadowHost);
}
async function findShadowDomElement(shadowHost, shadowDomElement) {
await (shadowRoot = getExtShadowRoot(shadowHost));
await shadowRoot.then(async result => await (element = result.findElement(By.css(shadowDomElement)))
);
return element;
}
async function fillAndSubmitWizardForm() {
driver.findElement(By.id('store-name')).sendKeys(credentials.shop.name);
driver.findElement(By.id('store-domain')).sendKeys(credentials.shop.domain);
driver.findElement(By.id('store-about')).sendKeys(credentials.shop.about);
driver.findElement(By.css('.next-step-button')).click();
driver.findElement(By.id('store-city')).sendKeys(credentials.shop.city);
driver.findElement(By.id('store-street')).sendKeys(credentials.shop.street);
driver.findElement(By.id('store-house')).sendKeys(credentials.shop.house);
driver.findElement(By.css('.next-step-button')).click();
driver.findElements(By.css('input[type="checkbox"]')).then(elements => elements.forEach(element => element.click()));
driver.findElement(By.id('store-facebook')).sendKeys(credentials.shop.facebook);
driver.findElement(By.id('store-instagram')).sendKeys(credentials.shop.instagram);
driver.findElement(By.id('store-youtube')).sendKeys(credentials.shop.youtube);
driver.findElement(By.css('.next-step-button')).click();
driver.wait(until.urlContains('dashboard')).then(() => navigateToCreatedShop());
}
async function navigateToCreatedShop(driver) {
const createdShop = findShadowDomElement('dash-board', 'shop-tile', driver).then(element => {
element.click();
});
driver.wait(until.titleIs());
}