Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 0 additions & 73 deletions src/test/java/com/easybusticket/pages/AllUsersPage.java

This file was deleted.

69 changes: 69 additions & 0 deletions src/test/java/com/easybusticket/pages/AllUsersPages.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
53 changes: 4 additions & 49 deletions src/test/java/com/easybusticket/tests/AllUsers_US23.java
Original file line number Diff line number Diff line change
Expand Up @@ -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

}
}
}