Skip to content

Instantly share code, notes, and snippets.

@batmi02
Created December 2, 2019 20:50
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save batmi02/6c87ed5531cd0035605c890730142331 to your computer and use it in GitHub Desktop.
// ------------------------------------------------------------------
// Legacy code based testing
// ------------------------------------------------------------------
@Test
public void productListTest() {
// ----- Check the 1st Item -----
By firstItem = By.id("__item0-container-cart---category--productList-0-titleText-inner");
waitForExistence(firstItem);
// ----- Assert the 1st Item's label in the list -----
assertEquals("10\ Portable DVD Player", driver.findElement(firstItem).getText());
// ----- Assert the 1st Item's Price -----
assertEquals("449.99", driver.findElement(By.xpath(
"//div[@id='__item0-container-cart---category--productList-0-ObjectNumber']//span[@class='sapMObjectNumberText']"))
.getText());
// ----- Assert the 1st Item's Availability -----
assertEquals("Available",
driver.findElement(By.xpath("//span[@id='status0-container-cart---category--productList-0-text']"))
.getText());
// ----- Assert if Availability is green in color (i.e. sapMObjStatusSuccess class) -----
assertThat(
driver.findElement(By.id("__status0-container-cart---category-productList-0")).getAttribute("class"),
containsString("sapMObjStatusSuccess"));
// ----- Assert the 1st Item's currency (Euro) -----
assertEquals("EUR", driver.findElement(By.xpath(
"//div[@id='__item0-container-cart---category--productList-o-ObjectNumber']//span[@class='sapMObjectNumberUnit']"))
.getText());
// ----- Assert the 1st Item has the correct image -----
assertThat(
driver.findElement(By.id("__item0-container-cart---category--productList-o-text")).getAttribute("src"),
containsString("HT-2001.jpg"));
// ----- Assert the 1st Item's has "Compare" link
assertEquals("Compare",
driver.findElement(By.id("__attribute1-container-cart---category--productList-0-text")).getText());
// ----- Assert if the txt Titanium exists
assertEquals("Titanium", driver.findElement(By.id("__text20")).getText());
// ----- Check the 2nd Item -----
// TODO Repeat the above for the rest of the items
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment