diff --git a/src/test/java/com/easybusticket/pages/AllUsersPage.java b/src/test/java/com/easybusticket/pages/AllUsersPage.java deleted file mode 100644 index 07605656..00000000 --- a/src/test/java/com/easybusticket/pages/AllUsersPage.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.easybusticket.pages; - - -import com.easybusticket.utilities.Driver; -import lombok.extern.slf4j.Slf4j; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.FindBy; -import org.openqa.selenium.support.PageFactory; - - @Slf4j - public class AllUsersPage extends BasePage { - - public AllUsersPage() { - PageFactory.initElements(Driver.get("stage"), this); - } - - @FindBy(xpath = "//*[@id=\"sidebar__menuWrapper\"]/ul/li[2]/div/ul/li[2]/a") - public WebElement allUsersButtonLink; - - - @FindBy(xpath = "/html/body/div/div[2]/div/div[1]/div[2]/form/div/input") - public WebElement emailLink; - - - @FindBy(xpath = "//table[@class='your-table-class']//tbody//tr[1]//td[7]//a") - public WebElement detailActionButtonLink; - - @FindBy(xpath = "//form[@class='your-form-class']//input[@class='your-input-class']") - public WebElement formControlButtonLink; - - @FindBy(xpath = "/html/body/div/div[2]/div/div[1]/div[2]/form/div/div/button") - public WebElement searchButtonLink; - - - public void titleAllUsersPage() { - String expectedTitle = "Easy Bus Ticket - All Users"; - String actualTitle = Driver.get(env).getTitle(); - softAssert.assertEquals(actualTitle, expectedTitle, "Incorrect page title on All Users page"); - // assertAll should not be called here - } - - - public void searchUserByEmailAndUsername(String email) { - emailLink.sendKeys(email); - searchButtonLink.click(); - - } - public void clearSearchBar() { - WebElement searchBar = driver.findElement(By.xpath("/html/body/div/div[2]/div/div[1]/div[2]/form/div/input")); - searchBar.clear(); - } - - public void searchByUsername(String username) { - WebElement searchBar = driver.findElement(By.xpath("/html/body/div/div[2]/div/div[1]/div[2]/form/div/input")); - searchBar.click(); - - WebElement usernameInput = driver.findElement(By.xpath("/html/body/div/div[2]/div/div[1]/div[2]/form/div/input")); - - // Clear any existing text in the input field (optional, depending on your needs) - usernameInput.clear(); - - // Enter the username using sendKeys - usernameInput.sendKeys(username); - - WebElement searchIcon = driver.findElement(By.xpath("/html/body/div/div[2]/div/div[1]/div[2]/form/div/div/button")); - - // Click the search icon - searchIcon.click(); - } - - -} diff --git a/src/test/java/com/easybusticket/pages/AllUsersPages.java b/src/test/java/com/easybusticket/pages/AllUsersPages.java new file mode 100644 index 00000000..d66726fa --- /dev/null +++ b/src/test/java/com/easybusticket/pages/AllUsersPages.java @@ -0,0 +1,69 @@ +package com.easybusticket.pages; + +import com.easybusticket.utilities.Driver; +import lombok.extern.slf4j.Slf4j; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.PageFactory; + +@Slf4j +public class AllUsersPages extends BasePage { + + public AllUsersPages() { + PageFactory.initElements(Driver.get("stage"), this); + } + + @FindBy(xpath = "//*[@id='sidebar__menuWrapper']/ul/li[2]/div/ul/li[1]/a/span[1]") + public WebElement allUsersLink; + + @FindBy(xpath = "/html/body/div/div[2]/div/div[1]/div[2]/form/div/input") + public WebElement emailOrUsernameLink; + + @FindBy(xpath = "/html/body/div/div[2]/div/div[1]/div[2]/form/div/div/button") + public WebElement searchButtonLink; + + @FindBy(xpath = "/html/body/div[1]/div[2]/div/div[1]/div[2]/form/div/input") + public WebElement usernameOrEmailText; + + @FindBy(xpath = "/html/body/div[1]/div[2]") + public WebElement manageUsersLink; + + public void allUsersTest() { + // Click on the "All Users" link + waitAndClick(allUsersLink); + + // Perform a search with an email + performSearch("wilburn.green@gmail.com"); + + // Delete the email (replace this with the actual logic to delete the email) + deleteEmail("wilburn.green@gmail.com"); + + // Perform a search with a username + performSearch("ugurcan"); + + // Asserts will be collected when the method is called in the test class + softAssert.assertAll(); + } + + private void performSearch(String searchText) { + // Click on the email or username text box + waitAndClick(emailOrUsernameLink); + + // Assert that the usernameOrEmailText is displayed + softAssert.assertTrue(usernameOrEmailText.isDisplayed()); + + // Enter the search text and click the search button + emailOrUsernameLink.sendKeys(searchText); + waitAndClick(searchButtonLink); + + // Clear the email or username text box + emailOrUsernameLink.clear(); + } + + private void deleteEmail(String email) { + // Implement the logic to delete the email associated with the given email address + // This might involve navigating to the user's profile, deleting the email, etc. + // For demonstration purposes, you can print a log message. + log.info("Deleted email: {}", email); + } +} \ No newline at end of file diff --git a/src/test/java/com/easybusticket/tests/AllUsers_US23.java b/src/test/java/com/easybusticket/tests/AllUsers_US23.java index be1b840b..56858579 100644 --- a/src/test/java/com/easybusticket/tests/AllUsers_US23.java +++ b/src/test/java/com/easybusticket/tests/AllUsers_US23.java @@ -2,63 +2,18 @@ import com.easybusticket.pages.*; import lombok.extern.slf4j.Slf4j; -import org.openqa.selenium.By; -import org.openqa.selenium.WebElement; -import org.openqa.selenium.support.ui.ExpectedConditions; -import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.annotations.Test; -import java.time.Duration; - -import static com.easybusticket.pages.BasePage.driver; - @Slf4j public class AllUsers_US23 extends BaseTestAdmin { @Test - public void allUsersTest() { - // Log in as an administrator and navigate to the admin Dashboard. + public void AllUsersTest() { AdminDashboardPage adminDashboardPage = new AdminPage().adminLogin(); - - // Navigate to the "All Users" page. - AllUsersPage allUsersPage = new AllUsersPage(); - adminDashboardPage.manageUsersDropdown.click(); - - // Verify that the "All Users" page is loaded successfully. - - adminDashboardPage.allUsersDropdown.click(); - - WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(15)); - WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='sidebar__menuWrapper']/ul/li[2]/div/ul/li[1]/a/span[1]"))); - element.click(); - - WebElement searchBar = driver.findElement(By.xpath("/html/body/div/div[2]/div/div[1]/div[2]/form/div/input")); - searchBar.click(); - - WebElement emailInput = driver.findElement(By.xpath("/html/body/div/div[2]/div/div[1]/div[2]/form/div/input")); - - // Clear any existing text in the input field (optional, depending on your needs) - emailInput.clear(); - - // Enter the email using sendKeys - emailInput.sendKeys("wilburn.green@gmail.com"); - - WebElement searchIcon = driver.findElement(By.xpath("/html/body/div/div[2]/div/div[1]/div[2]/form/div/div/button")); - - // Click the search icon - searchIcon.click(); - // Optionally add waits or assertions after searching by email. - - // Clear the search bar - allUsersPage.clearSearchBar(); - - // Perform a new search by username - allUsersPage.searchByUsername("ugurcan"); - - // Optionally add waits or assertions after searching by username. - + AllUsersPages allUsersPage = new AllUsersPages(); + allUsersPage.allUsersTest(); // Call the updated allUsersTest method } -} + } \ No newline at end of file