-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutomationEx_19.java
60 lines (56 loc) · 3.26 KB
/
AutomationEx_19.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
52
53
54
55
56
57
58
59
60
package tests.automationExCases;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebElement;
import org.testng.Assert;
import org.testng.annotations.Test;
import pages.AutomationExPage;
import utilities.ConfigReader;
import utilities.Driver;
import utilities.ReusableMethods;
import utilities.TestBaseRapor;
import java.time.Duration;
import java.util.List;
public class AutomationEx_19 extends TestBaseRapor {
AutomationExPage automationExPage;
@Test
public void test19_View_Cart_Brand_Products() throws InterruptedException {
automationExPage = new AutomationExPage();
extentTest = extentReports.createTest("test19_View_Cart_Brand_Products", "automationexercise.com UI testcase 19");
extentTest.info("1. Launch browser and Navigate to url 'http://automationexercise.com , 2. Verify that home page is visible successfully");
Driver.getDriver().get(ConfigReader.getProperty("autExUrl"));
ReusableMethods.waitForPageToLoad(10);
Assert.assertTrue(ReusableMethods.verifyURLorText(Driver.getDriver().getCurrentUrl(), "https://automationexercise.com/"));
List<WebElement> mainPageTumResimler = Driver.getDriver().findElements(By.xpath("//div[@class='productinfo text-center']"));
for (WebElement element : mainPageTumResimler) {
element.isDisplayed();
element.isEnabled();
}
extentTest.info("4. Verify that Brands are visible on left side bar");
automationExPage.mainPageCategoryBrandBar.isDisplayed();
extentTest.info("5. Click on any brand name");
Thread.sleep(500);
JavascriptExecutor js=(JavascriptExecutor)Driver.getDriver();
js.executeScript("arguments[0].scrollIntoView();", automationExPage.mainPageBrandsPolo);
automationExPage.mainPageBrandsPolo.click();
extentTest.info("6. Verify that user is navigated to brand page and brand products are displayed");
Assert.assertTrue(ReusableMethods.verifyURLorText(Driver.getDriver().getCurrentUrl(), "https://automationexercise.com/brand_products/Polo"));
List<WebElement> poloBrandPageTumResimler = Driver.getDriver().findElements(By.xpath("//div[@class='productinfo text-center']"));
for (WebElement element : poloBrandPageTumResimler) {
element.isDisplayed();
element.isEnabled();
}
extentTest.info("7. On left side bar, click on any other brand link");
Thread.sleep(500);
js.executeScript("arguments[0].scrollIntoView();", automationExPage.mainPageBrandsHarbour);
automationExPage.mainPageBrandsHarbour.click();
extentTest.info("8. Verify that user is navigated to that brand page and can see products");
Assert.assertTrue(ReusableMethods.verifyURLorText(Driver.getDriver().getCurrentUrl(), "https://automationexercise.com/brand_products/Mast%20&%20Harbour"));
List<WebElement> harbourBrandPageTumResimler = Driver.getDriver().findElements(By.xpath("//div[@class='productinfo text-center']"));
for (WebElement element : harbourBrandPageTumResimler) {
element.isDisplayed();
element.isEnabled();
}
extentTest.pass("View cart and different brand products functions are works as expectedly!");
}
}