From 0b1fc938182bc23a28e7e77a01e3a1a200df8789 Mon Sep 17 00:00:00 2001 From: Burhan PEKTAS Date: Thu, 18 Jan 2024 02:04:40 +0100 Subject: [PATCH 1/2] =?UTF-8?q?ManageUsers=20AllUsers=20en=20g=C3=BCncel?= =?UTF-8?q?=20durumu.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/easybusticket/pages/AllUsersPage.java | 94 +++++++++---------- .../easybusticket/tests/AllUsers_US23.java | 57 +---------- 2 files changed, 49 insertions(+), 102 deletions(-) diff --git a/src/test/java/com/easybusticket/pages/AllUsersPage.java b/src/test/java/com/easybusticket/pages/AllUsersPage.java index 07605656..dd5d9529 100644 --- a/src/test/java/com/easybusticket/pages/AllUsersPage.java +++ b/src/test/java/com/easybusticket/pages/AllUsersPage.java @@ -1,73 +1,69 @@ 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; - +@Slf4j +public class AllUsersPage extends BasePage { - @FindBy(xpath = "//table[@class='your-table-class']//tbody//tr[1]//td[7]//a") - public WebElement detailActionButtonLink; + public AllUsersPage() { + PageFactory.initElements(Driver.get("stage"), this); + } - @FindBy(xpath = "//form[@class='your-form-class']//input[@class='your-input-class']") - public WebElement formControlButtonLink; + @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/div/button") - public WebElement searchButtonLink; + @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; - 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 - } + @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 searchUserByEmailAndUsername(String email) { - emailLink.sendKeys(email); - searchButtonLink.click(); + public void allUsersTest() { + // Click on the "All Users" link + waitAndClick(allUsersLink); - } - public void clearSearchBar() { - WebElement searchBar = driver.findElement(By.xpath("/html/body/div/div[2]/div/div[1]/div[2]/form/div/input")); - searchBar.clear(); - } + // Perform a search with an email + performSearch("wilburn.green@gmail.com"); - 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(); + // Delete the email (replace this with the actual logic to delete the email) + deleteEmail("wilburn.green@gmail.com"); - WebElement usernameInput = driver.findElement(By.xpath("/html/body/div/div[2]/div/div[1]/div[2]/form/div/input")); + // Perform a search with a username + performSearch("ugurcan"); - // Clear any existing text in the input field (optional, depending on your needs) - usernameInput.clear(); + // Asserts will be collected when the method is called in the test class + softAssert.assertAll(); + } - // Enter the username using sendKeys - usernameInput.sendKeys(username); + private void performSearch(String searchText) { + // Click on the email or username text box + waitAndClick(emailOrUsernameLink); - WebElement searchIcon = driver.findElement(By.xpath("/html/body/div/div[2]/div/div[1]/div[2]/form/div/div/button")); + // Assert that the usernameOrEmailText is displayed + softAssert.assertTrue(usernameOrEmailText.isDisplayed()); - // Click the search icon - searchIcon.click(); - } + // 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 90bb2af2..207092c9 100644 --- a/src/test/java/com/easybusticket/tests/AllUsers_US23.java +++ b/src/test/java/com/easybusticket/tests/AllUsers_US23.java @@ -2,67 +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(); - ManageUsersPage manageUsersPage = new ManageUsersPage(); - - manageUsersPage.clickToAllUsersPage(); - - - // 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. - + AllUsersPage allUsersPage = new AllUsersPage(); + allUsersPage.allUsersTest(); } -} \ No newline at end of file +} From cc734a66ec9f34d1d634a355ea02b7ec55c14efc Mon Sep 17 00:00:00 2001 From: Burhan PEKTAS Date: Thu, 18 Jan 2024 22:25:21 +0100 Subject: [PATCH 2/2] degisiklik --- .../pages/{AllUsersPage.java => AllUsersPages.java} | 4 ++-- .../java/com/easybusticket/tests/AllUsers_US23.java | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) rename src/test/java/com/easybusticket/pages/{AllUsersPage.java => AllUsersPages.java} (96%) diff --git a/src/test/java/com/easybusticket/pages/AllUsersPage.java b/src/test/java/com/easybusticket/pages/AllUsersPages.java similarity index 96% rename from src/test/java/com/easybusticket/pages/AllUsersPage.java rename to src/test/java/com/easybusticket/pages/AllUsersPages.java index dd5d9529..d66726fa 100644 --- a/src/test/java/com/easybusticket/pages/AllUsersPage.java +++ b/src/test/java/com/easybusticket/pages/AllUsersPages.java @@ -7,9 +7,9 @@ import org.openqa.selenium.support.PageFactory; @Slf4j -public class AllUsersPage extends BasePage { +public class AllUsersPages extends BasePage { - public AllUsersPage() { + public AllUsersPages() { PageFactory.initElements(Driver.get("stage"), this); } diff --git a/src/test/java/com/easybusticket/tests/AllUsers_US23.java b/src/test/java/com/easybusticket/tests/AllUsers_US23.java index 9a88e70c..56858579 100644 --- a/src/test/java/com/easybusticket/tests/AllUsers_US23.java +++ b/src/test/java/com/easybusticket/tests/AllUsers_US23.java @@ -4,7 +4,16 @@ import lombok.extern.slf4j.Slf4j; import org.testng.annotations.Test; - @Slf4j public class AllUsers_US23 extends BaseTestAdmin { + + @Test + public void AllUsersTest() { + AdminDashboardPage adminDashboardPage = new AdminPage().adminLogin(); + adminDashboardPage.manageUsersDropdown.click(); + + AllUsersPages allUsersPage = new AllUsersPages(); + allUsersPage.allUsersTest(); // Call the updated allUsersTest method + } + } \ No newline at end of file