Created
January 6, 2021 15:35
-
-
Save pragmatictesters/9d43409d98a62fa55cb87714565f3cb8 to your computer and use it in GitHub Desktop.
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
package com.pragmatic.sevenstar; | |
import io.github.bonigarcia.wdm.WebDriverManager; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import org.testng.Assert; | |
import org.testng.annotations.AfterMethod; | |
import org.testng.annotations.BeforeClass; | |
import org.testng.annotations.BeforeMethod; | |
import org.testng.annotations.Test; | |
import java.util.ArrayList; | |
import java.util.List; | |
/** | |
* Created by Pragmatic Test Labs (Private) Limited | |
* | |
* @Author Janesh Kodikara | |
*/ | |
public class TestAdminUserLogin { | |
private static final String BASE_URL = "http://seven-star-supermarket.herokuapp.com/"; | |
private WebDriver driver; | |
@BeforeClass | |
public void beforeClass() { | |
WebDriverManager.chromedriver().setup(); | |
} | |
@BeforeMethod | |
public void beforeMethod() { | |
driver = new ChromeDriver(); | |
driver.manage().window().maximize(); | |
driver.get(BASE_URL); | |
} | |
@AfterMethod | |
public void afterMethod() { | |
//driver.close(); | |
} | |
@Test | |
public void testAdminUserLogin() { | |
ArrayList<String> dashboard_items = new ArrayList<>(); | |
dashboard_items.add("TOTAL PRODUCTS"); | |
dashboard_items.add("AVAILABLE INVENTORY"); | |
dashboard_items.add("NET WORTH"); | |
dashboard_items.add("TOTAL CUSTOMERS COUNT"); | |
dashboard_items.add("TOTAL STAFF COUNT"); | |
dashboard_items.add("PENDING ORDERS"); | |
dashboard_items.add("READY TO SHIP ORDERS"); | |
driver.findElement(By.xpath("//a/li[text()='Sign-in']")).click(); | |
driver.findElement(By.xpath("//input[@name='u-email']")).sendKeys("[email protected]"); | |
driver.findElement(By.xpath("//input[@name='u-pass']")).sendKeys("12345678"); | |
driver.findElement(By.xpath("//button[contains(text(),'Sign in')]")).click(); | |
List<WebElement> list = driver.findElements(By.cssSelector("label.dashitemsname")); | |
for (WebElement element : list){ | |
System.out.println(element.getText()); | |
Assert.assertTrue(dashboard_items.contains(element.getText())); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment