package ru.stqa.selenium.example;

import org.junit.Test;
import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.ExpectedConditions;

public class shoppingCart extends TestBase {

    @Test
    public void cart() {
        driver.get("http://localhost/litecart/en/");

        WebElement content = driver.findElement(By.cssSelector("div.content ul.listing-wrapper"));
        WebElement product = content.findElement(By.tagName("a"));
        product.click();

        WebElement quantity = driver.findElement(By.className("quantity"));
        System.out.println(quantity.getText());
        driver.findElement(By.name("add_cart_product")).click();
        wait.until(ExpectedConditions.stalenessOf(quantity));
        quantity = driver.findElement(By.className("quantity"));

        driver.findElement(By.cssSelector("#breadcrumbs a")).click();
    }
}

@@ -28,16 +28,41 @@
 ample;%0A%0A
+import org.junit.Assert;%0A
 import o
@@ -165,16 +165,40 @@
 tions;%0A%0A
+import java.util.List;%0A%0A
 public c
@@ -323,17 +323,58 @@
 /en/%22);%0A
-%0A
+        for (int i = 1; i %3C 4; i++) %7B%0A    
         
@@ -464,32 +464,36 @@
 per%22));%0A        
+    
 WebElement produ
@@ -543,16 +543,20 @@
         
+   
+ 
 product.
@@ -561,24 +561,28 @@
 t.click();%0A%0A
+    
         WebE
@@ -645,24 +645,27 @@
 ity%22));%0A
+%0A  
         
 System.o
@@ -660,48 +660,189 @@
     
-System.out.println(quantity.getText());%0A
+  List%3CWebElement%3E size = driver.findElements(By.cssSelector(%22td.options select option%22));%0A            if (size.size() %3E 0) %7B%0A                size.get(2).click();%0A            %7D%0A    
     
@@ -910,16 +910,20 @@
         
+    
 wait.unt
@@ -948,19 +948,32 @@
 ons.
-stalenessOf
+textToBePresentInElement
 (qua
@@ -977,28 +977,39 @@
 quantity
+, %22%22 + i
 ));%0A
+%0A  
         
 quantity
@@ -1004,73 +1004,496 @@
     
-quantity = driver.findElement(By.className(%22quantity
+  driver.findElement(By.cssSelector(%22#breadcrumbs a%22)).click();%0A        %7D%0A        WebElement cart = driver.findElement(By.id(%22cart%22));%0A        cart.findElement(By.className(%22link%22)).click();%0A%0A        for (int i = 1; i %3C 4; i++) %7B%0A            if (isElementPresent(driver, By.cssSelector(%22#checkout-cart-wrapper em%22))) %7B%0A                break;%0A            %7D%0A            WebElement duckInCartForm = driver.findElement(By.cssSelector(%22form div a
 %22));%0A
-%0A
+    
        
+ List%3CWebElement%3E duckInTable =
  dri
@@ -1499,32 +1499,33 @@
 iver.findElement
+s
 (By.cssSelector(
@@ -1529,34 +1529,321 @@
 or(%22
-#breadcrumbs a%22)).click();
+.dataTable tr%22));%0A%0A            Assert.assertTrue(duckInCartForm.getText().equals(duckInTable.get(1).findElement(By.className(%22item%22)).getText()));%0A            driver.findElement(By.cssSelector(%22p:last-child button%22)).click();%0A%0A            wait.until(ExpectedConditions.stalenessOf(duckInTable.get(1)));%0A        %7D%0A
 %0A   

Done the task №13