Skip to content

Instantly share code, notes, and snippets.

@idrissov
Created August 17, 2019 15:57
Show Gist options
  • Select an option

  • Save idrissov/4e56f862358d0280a72eda5ef0365e34 to your computer and use it in GitHub Desktop.

Select an option

Save idrissov/4e56f862358d0280a72eda5ef0365e34 to your computer and use it in GitHub Desktop.
var webdriver = require ('selenium-webdriver'),
By = webdriver.By,
until = webdriver.until;
var driver = new webdriver.Builder().forBrowser('chrome').build();
async function waitForElement(cssSelector, timeOut) {
await driver.wait(until.elementLocated(By.css(cssSelector)), timeOut);
await driver.wait(until.elementIsVisible(driver.findElement(By.css(cssSelector))), timeOut);
}
async function shopStyleTest(){
await driver.get('https://www.shopstyle.com/');
await driver.manage().window().maximize();
await driver.findElement(By.css('button.button.button-login.button--secondary.button--small')).click();
await waitForElement('form > div > input:nth-child(1)', 5000);
await driver.findElement(By.css('form > div > input:nth-child(1)')).click();
await driver.findElement(By.css('form > div > input:nth-child(1)')).sendKeys('shopstyleasanar@gmail.com');
await driver.findElement(By.css('form > div > input:nth-child(2)')).sendKeys('epamtest1');
await driver.findElement(By.css('web-auth-modal-form > form > button')).click();
await waitForElement('body > web-root > web-header > web-header-ui > div > div > web-mega-menu > div > div > a:nth-child(5)', 5000);
let women = await driver.findElement(By.css('body > web-root > web-header > web-header-ui > div > div > web-mega-menu > div > div > a:nth-child(5)'));
await driver.executeScript("arguments[0].click();", women);
await driver.executeScript("arguments[0].click();", women);
await waitForElement('web-category-tree > div > div:nth-child(4) > span > a > span', 5000);
await driver.findElement(By.css('web-category-tree > div > div:nth-child(4) > span > a > span')).click();
await driver.findElement(By.css('web-sort-filter > div > select > option:nth-child(2)')).click();
await waitForElement('span:nth-child(1) > web-product-cell > div > div.product-cell__actions.product-cell__actions--unfavorite-cashback.product-cell__actions--favorite-hover-member > a > div > div > span.product-cell__favorite', 5000);
await driver.findElement(By.css('span:nth-child(1) > web-product-cell > div > div.product-cell__actions.product-cell__actions--unfavorite-cashback.product-cell__actions--favorite-hover-member > a > div > div > span.product-cell__favorite')).click();
await waitForElement('span:nth-child(1) > web-product-cell > div > div.product-cell__actions.product-cell__actions--unfavorite-cashback.product-cell__actions--unfavorite-non-cashback > a > div > div > span.product-cell__unfavorite-non-cashback', 5000);
await driver.findElement(By.css('span:nth-child(2) > web-product-cell > div > div.product-cell__actions.product-cell__actions--unfavorite-cashback.product-cell__actions--favorite-hover-member > a > div > div > span.product-cell__favorite')).click();
await waitForElement('span:nth-child(2) > web-product-cell > div > div.product-cell__actions.product-cell__actions--unfavorite-cashback.product-cell__actions--unfavorite-non-cashback > a > div > div > span.product-cell__unfavorite-non-cashback', 5000);
await driver.findElement(By.css('span:nth-child(3) > web-product-cell > div > div.product-cell__actions.product-cell__actions--unfavorite-cashback.product-cell__actions--favorite-hover-member > a > div > div > span.product-cell__favorite')).click();
await waitForElement('span:nth-child(3) > web-product-cell > div > div.product-cell__actions.product-cell__actions--unfavorite-cashback.product-cell__actions--unfavorite-non-cashback > a > div > div > span.product-cell__unfavorite-non-cashback', 5000);
await driver.findElement(By.id('header-favorite-button')).click();
await waitForElement('#favorites-on-sale-checkbox', 5000);
await driver.findElement(By.id('favorites-on-sale-checkbox')).click();
}
shopStyleTest();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment