-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23b18af
commit 2099342
Showing
11 changed files
with
209 additions
and
12 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
...ne-shop-it/src/test/java/com/yashmerino/online/shop/selenium/it/pages/BaseHeaderPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.yashmerino.online.shop.selenium.it.pages; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
/** | ||
* Base class for pages that have the header component. | ||
*/ | ||
public class BaseHeaderPage extends BasePage { | ||
/** | ||
* My Profile header button. | ||
*/ | ||
private final By profileButton = By.id("profile-button"); | ||
|
||
/** | ||
* My Cart header button. | ||
*/ | ||
private final By myCartButton = By.id("my-cart-button"); | ||
|
||
/** | ||
* My Products header button. | ||
*/ | ||
private final By myProductsButton = By.id("my-products-button"); | ||
|
||
/** | ||
* Add Product header button. | ||
*/ | ||
private final By addProductsButton = By.id("add-products-button"); | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param driver web driver to perform browser actions. | ||
* @param wait wait web driver to wait until certain conditions met. | ||
*/ | ||
public BaseHeaderPage(WebDriver driver, WebDriverWait wait) { | ||
super(driver, wait); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...e-shop-it/src/test/java/com/yashmerino/online/shop/selenium/it/pages/cart/MyCartPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.yashmerino.online.shop.selenium.it.pages.cart; | ||
|
||
import com.yashmerino.online.shop.selenium.it.pages.BaseHeaderPage; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.NoSuchElementException; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
/** | ||
* Page Object Model that represents my cart page. | ||
*/ | ||
public class MyCartPage extends BaseHeaderPage { | ||
/** | ||
* Constructor. | ||
* | ||
* @param driver web driver to perform browser actions. | ||
* @param wait wait web driver to wait until certain conditions met. | ||
*/ | ||
public MyCartPage(final WebDriver driver, final WebDriverWait wait) { | ||
super(driver, wait); | ||
} | ||
|
||
/** | ||
* Checks if a product exists. | ||
* | ||
* @param productName is the product's name. | ||
* @return <code>true</code> or <code>false</code>. | ||
*/ | ||
public boolean productExists(final String productName) { | ||
try { | ||
driver.findElement(By.xpath(String.format("//h6[contains(string(), %s)]", productName))); | ||
return true; | ||
} catch (NoSuchElementException e) { | ||
return false; | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...t/src/test/java/com/yashmerino/online/shop/selenium/it/pages/products/AddProductPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.yashmerino.online.shop.selenium.it.pages.products; | ||
|
||
import com.yashmerino.online.shop.selenium.it.pages.BaseHeaderPage; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
/** | ||
* Page Object Model that represents add product page. | ||
*/ | ||
public class AddProductPage extends BaseHeaderPage { | ||
/** | ||
* Name field. | ||
*/ | ||
private final By nameField = By.id("name-field"); | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param driver web driver to perform browser actions. | ||
* @param wait wait web driver to wait until certain conditions met. | ||
*/ | ||
public AddProductPage(final WebDriver driver, final WebDriverWait wait) { | ||
super(driver, wait); | ||
} | ||
|
||
/** | ||
* Adds a product. | ||
* | ||
* @param productName is the product's name. | ||
*/ | ||
public void addProductToCard(final String productName) { | ||
driver.findElement(nameField).sendKeys(productName); | ||
driver.findElement(submitButton).click(); | ||
|
||
wait.until(ExpectedConditions.visibilityOfElementLocated(successAlert)); | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...t/src/test/java/com/yashmerino/online/shop/selenium/it/pages/products/MyProductsPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.yashmerino.online.shop.selenium.it.pages.products; | ||
|
||
import com.yashmerino.online.shop.selenium.it.pages.BaseHeaderPage; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.NoSuchElementException; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
/** | ||
* Page Object Model that represents my products page. | ||
*/ | ||
public class MyProductsPage extends BaseHeaderPage { | ||
/** | ||
* Constructor. | ||
* | ||
* @param driver web driver to perform browser actions. | ||
* @param wait wait web driver to wait until certain conditions met. | ||
*/ | ||
public MyProductsPage(final WebDriver driver, final WebDriverWait wait) { | ||
super(driver, wait); | ||
} | ||
|
||
/** | ||
* Checks if a product exists. | ||
* | ||
* @param productName is the product's name. | ||
* @return <code>true</code> or <code>false</code>. | ||
*/ | ||
public boolean productExists(final String productName) { | ||
try { | ||
driver.findElement(By.xpath(String.format("//h6[contains(string(), %s)]", productName))); | ||
return true; | ||
} catch (NoSuchElementException e) { | ||
return false; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...-it/src/test/java/com/yashmerino/online/shop/selenium/it/pages/products/ProductsPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.yashmerino.online.shop.selenium.it.pages.products; | ||
|
||
import com.yashmerino.online.shop.selenium.it.pages.BaseHeaderPage; | ||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.support.ui.ExpectedConditions; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
/** | ||
* Page Object Model that represents products page. | ||
*/ | ||
public class ProductsPage extends BaseHeaderPage { | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param driver web driver to perform browser actions. | ||
* @param wait wait web driver to wait until certain conditions met. | ||
*/ | ||
public ProductsPage(final WebDriver driver, final WebDriverWait wait) { | ||
super(driver, wait); | ||
} | ||
|
||
/** | ||
* Adds a product to the card. | ||
* | ||
* @param productId is the product's id. | ||
*/ | ||
public void addProductToCard(final String productId) { | ||
driver.findElement(By.id("add-product-" + productId)).click(); | ||
|
||
wait.until(ExpectedConditions.visibilityOfElementLocated(successAlert)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters