@Test public void testAppleWatch() throws InterruptedException { String SearchWord = "apple watch"; String refinedSearch = "Smart Watches"; String ratingVerify = "3.8 out of 5 stars"; HomePage home = new HomePage(driver); ResultsPage resultList = home.searchText(SearchWord); RefinedSearchPage refinedPage = resultList.getToRefinedSearchPage(refinedSearch); org.junit.Assert.assertTrue(refinedPage != null); /* Get the first link */ ProductPage prdPage = refinedPage.getFirstResult(); org.junit.Assert.assertTrue(prdPage != null); /* Assert on rating.*/ ; org.junit.Assert.assertEquals(ratingVerify, prdPage.getRating()); }
@Test public void createStoryForEachBooks() throws UnsupportedDriverException, InterruptedException { List<BuchDO> buecherList = readBooks(); assertTrue(numOfBooks == buecherList.size()); createProductForMissingBooks(); for (BuchDO buch : buecherList) { createStory(buch); } // and check existence in the product logger.info("Checking product: " + product.title); ProductPage productPage = startPage.navigateToProduct(product.title, 0); for (BuchDO buch : buecherList) { productPage.storyIsShown(buch.getTitel()); } }
@Test(groups = {"WEB", "Tablet"}) public void CTTCM_2498_WEB() throws AssertionError, ExceptionHandler { try { logger.info("Start CTTCM - 1635 Test Case"); HomePage home = new HomePage(driver); home.header.search(searchData.searchItem("TA276136")); ProductPage productPage = new ProductPage(driver); productPage.waitUntilLoaderImageDisappear(); Assert.assertTrue(productPage.detailLink.isDisplayed()); Assert.assertFalse(productPage.addCheckBox.isSelected()); Assert.assertTrue(productPage.checkItemAvailability().equalsIgnoreCase("In Stock")); productPage.detailLink.click(); // Storing parent window reference into a String variable String parentWindow = driver.getWindowHandle(); // Switching from parent window to child window for (String childWindow : driver.getWindowHandles()) { driver.switchTo().window(childWindow); } Assert.assertTrue(driver.getTitle().equalsIgnoreCase("Engraving Information")); productPage.clickCloseEngravingWindow(); // Switching back to Parent Window driver.switchTo().window(parentWindow); // Change zip code and verify city and date productPage.waitUntilElementIsVisible(productPage.enterZipCodeLink); productPage.enterZipCode(llBeanTexts.productPage.getProperty("zipCode")); productPage.waitUntilElementIsVisible(productPage.enterZipCodeLink); String previousCity = productPage.getZipCode(); DateHandler dateHandler = new DateHandler(); productPage.waitUntilLoaderImageDisappear(); Date previousDate = dateHandler.stringToDate(productPage.getAdqDate()); productPage.enterZipCode(llBeanTexts.productPage.getProperty("secondZipCode")); // Wait for new zip code entered appears productPage.waitUntilLoaderImageDisappear(); Assert.assertFalse(productPage.enterZipCodeLink.getText().equalsIgnoreCase(previousCity)); Assert.assertTrue(productPage.getStoreAvailability().equalsIgnoreCase("select store")); Date postDate = dateHandler.stringToDate(productPage.getAdqDate()); Assert.assertFalse((dateHandler.compareDates(previousDate, postDate))); // select a different Store and check availability productPage.moveToElementAndClick(productPage.storeAvailability); productPage.waitToBeClickableAndClick(productPage.selectStore); // Select moves inside the dropdown to click the option with the specified text productPage.selectItemByText("Freeport, ME", productPage.selectStore); productPage.moveToElementAndClick(productPage.checkStoreButton); // Verify product availability on selected Store productPage.waitUntilElementIsVisible(productPage.productAvailability); Assert.assertTrue(productPage.getProductAvailability().contains("In Stock")); productPage.addCheckBox.click(); // Make product reservation, complete mandatory fields and verify engraving productPage.waitToBeClickableAndClick(productPage.reserveButton); ReserveItemPage reserveItemPage = new ReserveItemPage(driver); reserveItemPage.waitUntilLoaderImageDisappear(); Assert.assertEquals( reserveItemPage.getReservationEngravingText1(), llBeanTexts.productPage.getProperty("engravingFirstparagraph")); Assert.assertEquals( reserveItemPage.getReservationEngravingText2(), llBeanTexts.productPage.getProperty("engravingSecondparagraph")); reserveItemPage.enterFirstName( llBeanTexts.generalUserInfoProperties.getProperty("firstName")); reserveItemPage.enterLastName(llBeanTexts.generalUserInfoProperties.getProperty("lastName")); reserveItemPage.enterPhoneNumber( llBeanTexts.generalUserInfoProperties.getProperty("userPhoneNumber")); reserveItemPage.enterEmailAddress( llBeanTexts.generalUserInfoProperties.getProperty("userEmail")); reserveItemPage.enterVerifyEmailAddress( llBeanTexts.generalUserInfoProperties.getProperty("userEmail")); reserveItemPage.clickReserveItem(); reserveItemPage.closeReserveItemDialog(); productPage.clickShoppingBagButton(); // Methods used for Engraving functionality EngravingPage engravingPage = new EngravingPage(driver); AddedToYourShoppingBagModalPage addToYourShoppingBag = engravingPage.selectEngravingOption(); Assert.assertTrue(productPage.getPrice().equals(addToYourShoppingBag.getPrice())); Assert.assertTrue(addToYourShoppingBag.getEngravingServicePlus()); Assert.assertTrue(addToYourShoppingBag.getEstimatedShippingAndHandling().equals("FREE")); addToYourShoppingBag.clickCheckoutbtn(); ShoppingBagPage shoppingBagPage = new ShoppingBagPage(driver); Assert.assertEquals( shoppingBagPage.getShoppingBag().getItemEngravingPrice(), addToYourShoppingBag.engravingTotalService); Assert.assertEquals(shoppingBagPage.getShoppingBag().getShoppingBagItems().size(), 1); Assert.assertEquals(shoppingBagPage.getOrderSummary().shippingAndHandling(), "FREE"); // Continue checkout as Guest SecureCheckoutModalPage secureCheckoutModalPage = shoppingBagPage.continueToCheckoutAsNonAuthenticatedUser(); secureCheckoutModalPage.clickCheckoutAsGuest(); // ShippingAddress form information entered ShippingAddress shippingAddress = new ShippingAddress(driver); shippingAddress.enterShippingAddress(); Assert.assertTrue(shippingAddress.getOrderSummary().shippingAndHandling().equals("FREE")); shippingAddress.clickContinueToBillingAddress(); // BillingAddress form information entered BillingAddress billingAddress = new BillingAddress(driver); billingAddress.enterBillingEmail(); billingAddress.clickContinueToPaymentOptions(); PaymentOptionsPage paymentOptions = new PaymentOptionsPage(driver); paymentOptions.enterVISACreditCardInfo(); paymentOptions.continueToReviewOrder(); paymentOptions.checkInterstitialModal(); // Review and place order page verification ReviewAndPlaceOrderPage reviewAndPlaceOrderPage = new ReviewAndPlaceOrderPage(driver); // verify if total cost contains engraving service included Assert.assertEquals( shoppingBagPage.getReviewPageShoppingBag().getItemEngravingPrice(), addToYourShoppingBag.engravingTotalService); // verify item number is still the same Assert.assertEquals( shoppingBagPage.getReviewPageShoppingBag().getShoppingBagItems().size(), 1); // verify Shipping & Handling is free Assert.assertEquals(reviewAndPlaceOrderPage.getOrderSummary().shippingAndHandling(), "FREE"); reviewAndPlaceOrderPage.clickPlaceOrderButton(); // Thank you page verification ThankYouPage thankYouPage = new ThankYouPage(driver); // verify if total cost contains engraving service included Assert.assertEquals( shoppingBagPage.getTYPageShoppingBag().getItemEngravingPrice(), addToYourShoppingBag.engravingTotalService); // verify item number is still the same Assert.assertEquals(shoppingBagPage.getTYPageShoppingBag().getShoppingBagItems().size(), 1); // verify Shipping & Handling is free Assert.assertEquals(thankYouPage.getOrderSummary().shippingAndHandling(), "FREE"); } catch (Exception e) { logger.error(e.getMessage()); throw new ExceptionHandler(e.getMessage()); } }