Skip to content

Commit

Permalink
AYS-206 | Fixing ignored tests. (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
cagla88 authored Apr 6, 2024
1 parent 3e2a5b8 commit 470701f
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 20 deletions.
8 changes: 8 additions & 0 deletions src/test/java/org/ays/browser/AysPageActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,12 @@ public void clickElementWithJavaScript(WebElement element) {
executor.executeScript("arguments[0].click();", element);
}

public void waitFor(int seconds) {
try {
Thread.sleep(seconds * 1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}

}
3 changes: 2 additions & 1 deletion src/test/java/org/ays/feature/UsersCreate.feature
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
@Ignore
@Regression
Feature: Testing Users Section

Background:
Given Open the institution login page
When Enter the username and password
And Click the Login button

@Smoke
Scenario: Create a New Users
When Click on the users tab
And Click on the create button
Expand Down
6 changes: 5 additions & 1 deletion src/test/java/org/ays/feature/UsersDelete.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@Ignore
@Smoke @Regression
Feature: Testing Users

Background:
Expand All @@ -8,6 +8,10 @@ Feature: Testing Users

Scenario: Delete the Existing Users
When Click on the users tab
And Click on the create button
And Fill out the users form using "Test" firstName
Then Click on the save button
And Click on the pop up close button
And Sort Created At column in descending order
And Click on the trash bin icon for the top users
And Click on the delete button for the top users
Expand Down
1 change: 0 additions & 1 deletion src/test/java/org/ays/feature/UsersEdit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ Feature: Testing Users

Scenario: Editing Users
When Click on the users tab
And Sort Created At column in descending order
And Click on the pencil icon
And Edit the status section in the user form
Then Click on the save edit button
Expand Down
23 changes: 14 additions & 9 deletions src/test/java/org/ays/pages/UsersPOM.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;

import java.util.List;

@Getter
public class UsersPOM {

Expand All @@ -25,7 +27,7 @@ public UsersPOM() {
@FindBy(id = "lastName")
private WebElement lastName;

@FindBy(xpath = "(//div[contains(@class, 'ant-select-show-arrow')])[2]")
@FindBy(xpath = "//div/span[@class='ant-select-selection-search']")
private WebElement countryCode;

@FindBy(xpath = "(//div[.='+90 Türkiye'])[2]")
Expand All @@ -52,25 +54,22 @@ public UsersPOM() {
@FindBy(xpath = "//h5[.='Username']")
private WebElement showUsername;

@FindBy(xpath = "(//span[contains(@class, 'anticon-edit')])[1]")
@FindBy(xpath = "//span[contains(@class, 'anticon-edit')]")
private WebElement usersEditIcon;

@FindBy(xpath = "(//span[@class='ant-select-selection-item'])[2]")
@FindBy(xpath = "(//span[@class='ant-select-selection-item'])[1]")
private WebElement statusDropdown;

@FindBy(xpath = "//div[.='Active']")
private WebElement activeOption;

@FindBy(xpath = "//span[.='Active']")
private WebElement activeStatus;

@FindBy(xpath = "//div[.='Passive']")
@FindBy(xpath = "(//div[.='Passive'])[2]")
private WebElement passiveOption;

@FindBy(xpath = "(//button[contains(@class,'refine-delete-button')])[1]")
@FindBy(xpath = "(//tr[contains(@class,'ant-table-row-level-0')])[1]/td/div/div/button")
private WebElement deleteUsersIcon;

@FindBy(xpath = "//span[text()='Delete']")
@FindBy(xpath = "//div[@class='ant-popover-content']/div/div/div/div[2]/button[2]")
private WebElement sureDeleteButton;

@FindBy(xpath = "//div[@class='ant-notification-notice-message']")
Expand All @@ -82,4 +81,10 @@ public UsersPOM() {
@FindBy(xpath = "(//span[contains(@class, 'anticon-save')])[2]")
private WebElement editSaveButton;

@FindBy(xpath = "//button[@class='ant-modal-close']")
private WebElement popupCloseButton;

@FindBy(xpath = "(//tr[contains(@class,'ant-table-row-level-0')])[1]/td/span")
private List<WebElement> firstRowData;

}
40 changes: 36 additions & 4 deletions src/test/java/org/ays/step_definitions/UsersDelete.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,60 @@
import io.cucumber.java.en.When;
import org.ays.pages.UsersPOM;
import org.ays.browser.AysPageActions;
import org.ays.utilities.AysRandomUtil;
import org.testng.Assert;

public class UsersDelete {

private final UsersPOM usersPOM = new UsersPOM();
private final AysPageActions pageActions = new AysPageActions();

@And("Fill out the users form using {string} firstName")
public void fillOutTheUsersFormUsingFirstName(String firstName) {
pageActions.waitUntilVisible(usersPOM.getFirstName());
pageActions.sendKeysMethod(usersPOM.getFirstName(), firstName + AysRandomUtil.generateFirstName());
pageActions.waitUntilVisible(usersPOM.getLastName());
pageActions.sendKeysMethod(usersPOM.getLastName(), AysRandomUtil.generateLastName());
pageActions.clickMethod(usersPOM.getCountryCode());
pageActions.clickMethod(usersPOM.getTurkeyCountryCode());
pageActions.waitUntilVisible(usersPOM.getPhoneNumber());
pageActions.sendKeysMethod(usersPOM.getPhoneNumber(), AysRandomUtil.generatePhoneNumber());

}

@And("Click on the pop up close button")
public void clickOnThePopUpCloseButton() {
pageActions.waitFor(3);
pageActions.waitUntilClickable(usersPOM.getPopupCloseButton());
pageActions.clickMethod(usersPOM.getPopupCloseButton());
}

@When("Sort Created At column in descending order")
public void sort_created_at_column_in_descending_order() {
pageActions.waitFor(3);
pageActions.waitUntilVisible(usersPOM.getCreatedAtColumn());
pageActions.waitUntilClickable(usersPOM.getCreatedAtColumn());
pageActions.doubleClick(usersPOM.getCreatedAtColumn());
}

@When("Click on the trash bin icon for the top users")
public void click_on_the_trash_bin_icon_for_the_top_users() {
pageActions.waitUntilClickable(usersPOM.getDeleteUsersIcon());
pageActions.moveToElement(usersPOM.getDeleteUsersIcon());
pageActions.clickElementWithJavaScript(usersPOM.getDeleteUsersIcon());
pageActions.waitFor(3);
pageActions.waitUntilVisible(usersPOM.getFirstRowData());

String firstName = usersPOM.getFirstRowData().get(0).getText();
if (firstName.startsWith("Test")) {
pageActions.moveToElement(usersPOM.getDeleteUsersIcon());
pageActions.clickElementWithJavaScript(usersPOM.getDeleteUsersIcon());
}
pageActions.waitFor(3);
}

@And("Click on the delete button for the top users")
public void clickOnTheDeleteButtonForTheTopUsers() {
pageActions.moveToElement(usersPOM.getSureDeleteButton());
pageActions.waitUntilClickable(usersPOM.getSureDeleteButton());
pageActions.clickMethod(usersPOM.getSureDeleteButton());
pageActions.clickElementWithJavaScript(usersPOM.getSureDeleteButton());
}

@Then("Validate the success message")
Expand All @@ -36,4 +67,5 @@ public void Validate_the_success_message() {
Assert.assertTrue(usersPOM.getSuccessMessageDelete().isDisplayed());
}


}
12 changes: 8 additions & 4 deletions src/test/java/org/ays/step_definitions/UsersEdit.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,24 @@ public void clickOnThePencilIcon() {

@When("Edit the status section in the user form")
public void editTheStatusSectionInTheUserForm() {
pageActions.waitUntilClickable(usersPOM.getStatusDropdown());
pageActions.moveToElement(usersPOM.getStatusDropdown());
pageActions.clickMethod(usersPOM.getStatusDropdown());
if (usersPOM.getStatusDropdown().getText().equalsIgnoreCase("active")) {

if (usersPOM.getStatusDropdown().getText().equals("Active")) {
pageActions.waitUntilClickable(usersPOM.getPassiveOption());
pageActions.clickMethod(usersPOM.getPassiveOption());
} else if (usersPOM.getStatusDropdown().getText().equalsIgnoreCase("passive")) {
}
if (usersPOM.getStatusDropdown().getText().equals("Passive")) {
pageActions.waitUntilClickable(usersPOM.getActiveOption());
pageActions.clickMethod(usersPOM.getActiveOption());
}
}

@Then("Click on the save edit button")
public void Click_on_the_save_edit_button() {
pageActions.clickMethod(usersPOM.getEditSaveButton());
pageActions.waitUntilVisible(usersPOM.getEditSaveButton());
pageActions.moveToElement(usersPOM.getEditSaveButton());
pageActions.clickElementWithJavaScript(usersPOM.getEditSaveButton());
}

}

0 comments on commit 470701f

Please sign in to comment.