Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.support.ui.WebDriverWait;
- import org.testng.annotations.AfterMethod;
- import org.testng.annotations.BeforeMethod;
- import org.testng.annotations.Test;
- import java.util.List;
- import java.util.concurrent.TimeUnit;
- public class RozetkaHW31 {
- WebDriver driver;
- WebDriverWait wait;
- @BeforeMethod
- public void start() {
- driver = new ChromeDriver();
- wait = (new WebDriverWait(driver, 5));
- driver.manage().window().maximize();
- driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
- driver.get("https://rozetka.com.ua");
- }
- @Test
- public void RozetkaNoteBook() {
- WebElement noteBooksAndComps = driver.findElement(By.xpath("//a[@class='menu-categories__link']"));
- noteBooksAndComps.click();
- WebElement noteBooks = driver.findElement(By.xpath("//a[@class='menu__link menu__link_background_gray']"));
- noteBooks.click();
- WebElement addToBasket = driver.findElement(By.xpath("//button[@class='buy-button goods-tile__buy-button']"));
- addToBasket.click();
- List<WebElement> basket = driver.findElements(By.xpath("//div[@class='js-rz-cart']//span[@class='header-actions__button-counter']"));
- WebElement inBasket = driver.findElement(By.xpath("//div[@class='js-rz-cart']"));
- inBasket.click();
- if (basket.size() == 1) {
- System.out.println("В корзину добавился товар");
- } else {
- System.out.println("В корзине ничего нет");
- }
- WebElement title = driver.findElement(By.xpath("//a[@class='cart-product__title']"));
- String titleText = title.getAttribute("title");
- if (titleText.equals("Ноутбук Acer Swift 3 SF314-58-52DU (NX.HPMEU.00L) Sparkly Silver Суперцена!!! ")) {
- System.out.println("Нужный товар в корзине");
- } else {
- System.out.println("В корзине не тот товар");
- }
- }
- @AfterMethod
- public void after() {
- driver.quit();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment