|
| 1 | +package runner; |
| 2 | + |
| 3 | + |
| 4 | +import org.openqa.selenium.By; |
| 5 | +import org.openqa.selenium.WebDriver; |
| 6 | +import org.openqa.selenium.WebElement; |
| 7 | +import org.openqa.selenium.chrome.ChromeDriver; |
| 8 | +import org.openqa.selenium.support.ui.ExpectedConditions; |
| 9 | +import org.openqa.selenium.support.ui.WebDriverWait; |
| 10 | +import org.testng.Assert; |
| 11 | +import org.testng.annotations.*; |
| 12 | + |
| 13 | +import java.time.Duration; |
| 14 | + |
| 15 | +public class BuzzPageTest { |
| 16 | + private WebDriver driver; |
| 17 | + private WebDriverWait wait; |
| 18 | + |
| 19 | + @BeforeClass |
| 20 | + public void setUp() { |
| 21 | + driver = new ChromeDriver(); |
| 22 | + driver.manage().window().maximize(); |
| 23 | + driver.get("https://opensource-demo.orangehrmlive.com/"); |
| 24 | + wait = new WebDriverWait(driver, Duration.ofSeconds(10)); |
| 25 | + } |
| 26 | + @Test |
| 27 | + public void LoginInAccount() { |
| 28 | + |
| 29 | + WebElement usernameField = wait.until(ExpectedConditions.presenceOfElementLocated( |
| 30 | + By.name("username"))); |
| 31 | + usernameField.sendKeys("Admin"); |
| 32 | + WebElement passwordField = wait.until(ExpectedConditions.presenceOfElementLocated( |
| 33 | + By.name("password"))); |
| 34 | + passwordField.sendKeys("admin123"); |
| 35 | + |
| 36 | + WebElement loginButton = wait.until(ExpectedConditions.elementToBeClickable( |
| 37 | + By.xpath("//button[@type='submit']"))); |
| 38 | + loginButton.click(); |
| 39 | + |
| 40 | + WebElement profilePicture = wait.until(ExpectedConditions.presenceOfElementLocated( |
| 41 | + By.xpath("//img[@alt='profile picture']"))); |
| 42 | + Assert.assertTrue(profilePicture.isDisplayed(), "Profile picture is not displayed!"); |
| 43 | + } |
| 44 | + @AfterClass |
| 45 | + public void tearDown() { |
| 46 | + if (driver != null) { |
| 47 | + driver.quit(); |
| 48 | + } |
| 49 | + } |
| 50 | +} |
0 commit comments