-
Notifications
You must be signed in to change notification settings - Fork 30
/
ShoppingCartPage.java
51 lines (41 loc) · 1.6 KB
/
ShoppingCartPage.java
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
package pages;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.testng.TestException;
import utils.CommonUtils;
import java.util.List;
/**
* Created by tmaher on 12/21/2015.
*/
public class ShoppingCartPage extends CommonUtils {
private final By SHOPPING_CART_HEADER = By.cssSelector("h1");
private final By DELETE_BUTTONS = By.cssSelector("input[value='Delete']");
private final String SHOPPING_CART_EMPTY_MSG = "Your Shopping Cart is empty.";
public void verifyOnShoppingCartPage(){
String url = getCurrentURL();
System.out.println("SHOPPING_CART_PAGE: Verifying that we are on SHOPPING_CART_PAGE.");
if (!url.contains("cart")){
throw new TestException("ERROR: Not on SHOPPING_CART_PAGE! URL: " + url);
}
}
public void verifyOnShoppingCartReviewPage(){
String url = getCurrentURL();
System.out.println("SHOPPING_CART_PAGE: Verifying that we are on SHOPPING_CART_REVIEW_PAGE.");
if (!url.contains("view")){
throw new TestException("ERROR: Not on SHOPPING_CART_PAGE! URL: " + url);
}
}
public String getShoppingCartMessage(){
return getElementText(SHOPPING_CART_HEADER);
}
boolean checkIfShoppingCartHeaderListsEmptyMessage(){
String actualMessage = getShoppingCartMessage();
return (actualMessage.equals(SHOPPING_CART_EMPTY_MSG));
}
public void deleteAllItemsInCart(){
List<WebElement> deleteButtons = getElements(DELETE_BUTTONS);
for ( WebElement button : deleteButtons ){
button.click();
}
}
}