Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MOSIP-38316 - Added the testcases for create sbi device #1036

Merged
merged 5 commits into from
Dec 19, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import java.time.format.DateTimeFormatter;

import org.json.JSONObject;

import io.mosip.testrig.pmprevampui.authentication.fw.util.RestClient;
Expand All @@ -31,6 +34,11 @@ public class PmpTestUtil extends BaseTestCaseFunc {
public static String propsHealthCheckURL = TestRunner.getResourcePath() + "/"
+ "config/healthCheckEndpoint.properties";
public static boolean initialized = false;

public static DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("MM/dd/yyyy");
public static String todayDate = LocalDate.now().format(dateFormatter);
public static String expiryDate = LocalDate.now().plusWeeks(2).format(dateFormatter);
public static int todayDay = LocalDate.parse(todayDate, dateFormatter).getDayOfMonth();

public static String getServerComponentsDetails() {
if (serverComponentsCommitDetails != null && !serverComponentsCommitDetails.isEmpty())
Expand Down Expand Up @@ -125,5 +133,4 @@ public static void initialize() {
initialized = true;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import java.util.Properties;
import java.util.Random;

import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.NoAlertPresentException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.PageFactory;
Expand Down Expand Up @@ -201,8 +203,7 @@ protected boolean isElementDisplayed(WebElement element) {
protected boolean isElementEnabled(WebElement element) {
try {
waitForElementToBeVisible(element);
element.isEnabled();
return true;
return element.isEnabled();
} catch (Exception e) {
try {
Reporter.log("<p><img src='data:image/png;base64," + Screenshot.ClickScreenshot(driver)
Expand All @@ -213,7 +214,7 @@ protected boolean isElementEnabled(WebElement element) {
return false;
}
}

private void waitForElementToBeVisible(WebElement element) {
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(40));
wait.until(ExpectedConditions.visibilityOf(element));
Expand Down Expand Up @@ -274,5 +275,27 @@ protected String getTextFromAttribute(WebElement element, String atrr) {
public static String getTestData() {
return JsonUtil.readJsonFileText("TestData.json");
}

public void reload() {
driver.navigate().refresh();
}

public void back() {
driver.navigate().back();
}

public String acceptAlert() {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
alert.accept();
return alertText;
}

public String cancelAlert() {
Alert alert = driver.switchTo().alert();
String alertText = alert.getText();
alert.dismiss();
return alertText;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,22 @@ public class DashboardPage extends BasePage {

@FindBy(id = "dashboard_authentication_clients_list_card")
private WebElement AuthenticationServices;


@FindBy(id = "dashboard_device_provider_service_card")
private WebElement deviceProviderServices;

@FindBy(id = "welcome_msg")
private WebElement welcomeMessage;

@FindBy(id = "side_nav_device_provider_service_icon")
private WebElement sideNavDeviceProvider;

@FindBy(id = "header_hamburger_open_sidenav")
private WebElement hamburgerOpen;

@FindBy(id = "header_hamburger_close_sidenav")
private WebElement hamburgerClose;

@FindBy(id = "select_policy_group_view_text")
private WebElement selectPolicyGroupViewMoreAndLess;

Expand All @@ -68,14 +83,14 @@ public class DashboardPage extends BasePage {
@FindBy(xpath = "//*[text()='Root of Trust Certificate']")
private WebElement RootOFTrustCertText;

@FindBy(id = "root_certificate_upload_btn")
//@FindBy(id = "root_certificate_upload_btn")
//@FindBy(id = "upload_root_trust_certificate_btn")
@FindBy(id = "upload_certificate_btn")
private WebElement rootCertificateUploadButton;


@FindBy(xpath = "//*[text()='Policies']")
private WebElement policyButton;


@FindBy(xpath = "//*[text()='Partner - Policy Linking']")
private WebElement PartnerPolicyMappingTab;

Expand Down Expand Up @@ -154,6 +169,14 @@ public boolean isPoliciesTitleDisplayed() {
public boolean isAuthenticationServicesTitleDisplayed() {
return isElementDisplayed(AuthenticationServices);
}

public boolean isDeviceProviderServicesTitleDisplayed() {
return isElementDisplayed(deviceProviderServices);
}

public boolean isWelcomeMessageDisplayed() {
return isElementDisplayed(welcomeMessage);
}

public PoliciesPage clickOnPoliciesTitle() {
clickOnElement(policiesTitle);
Expand All @@ -169,6 +192,11 @@ public OidcClientPage clickOnAuthenticationServicesTitle() {
clickOnElement(AuthenticationServices);
return new OidcClientPage(driver);
}

public DeviceProviderPage clickOnDeviceProviderServicesTitle() {
clickOnElement(deviceProviderServices);
return new DeviceProviderPage(driver);
}

public boolean isSelectPolicyGroupViewMoreAndLess() {
return isElementDisplayed(selectPolicyGroupViewMoreAndLess);
Expand Down Expand Up @@ -210,4 +238,21 @@ public void clickOnPartnerPolicyMappingTab() {
clickOnElement(PartnerPolicyMappingTab);
}

public void clickOnHamburgerOpen() {
clickOnElement(hamburgerOpen);
}

public void clickOnHamburgerClose() {
clickOnElement(hamburgerClose);
}

public DeviceProviderPage clickOnSideNavDeviceProvider() {
clickOnElement(sideNavDeviceProvider);
return new DeviceProviderPage(driver);
}

public String getSideNavDeviceProviderTitle() {
return getTextFromLocator(sideNavDeviceProvider);
}

}
Loading
Loading