forked from getgauge-examples/java-maven-selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlaceOrder.java
More file actions
33 lines (27 loc) · 1.07 KB
/
Copy pathPlaceOrder.java
File metadata and controls
33 lines (27 loc) · 1.07 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
import com.thoughtworks.gauge.Step;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import utils.driver.Driver;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class PlaceOrder {
@Step("Add item <item> to the cart.")
public void addItemToTheBasket(String item) {
WebDriver webDriver = Driver.webDriver;
webDriver.findElement(By.linkText(item)).click();
webDriver.findElement(By.linkText("Add to Card")).click();
}
@Step("Checkout now")
public void placeTheOrder() {
WebDriver webDriver = Driver.webDriver;
webDriver.findElement(By.xpath("//input[@value='Checkout Now!']")).click();
}
@Step("Cart now contains <itemCount> number of items")
public void cartNowContains(int numberOfItems) {
WebDriver webDriver = Driver.webDriver;
List<WebElement> products = webDriver.findElements(By.xpath("//table/tbody/tr"));
assertEquals(numberOfItems,products.size()-2);
}
}