Skip to content

Commit

Permalink
MOSIP-35667 fix ui automation for 0.13.x (#1604)
Browse files Browse the repository at this point in the history
* MOSIP-35667

Signed-off-by: Anup Nehe <[email protected]>

* resolve conflicts

Signed-off-by: Anup Nehe <[email protected]>

* resolve conflicts

Signed-off-by: Anup Nehe <[email protected]>

---------

Signed-off-by: Anup Nehe <[email protected]>
  • Loading branch information
anup-nehe authored Sep 10, 2024
1 parent a7d91c2 commit 94a0289
Show file tree
Hide file tree
Showing 40 changed files with 373 additions and 253 deletions.
4 changes: 2 additions & 2 deletions injitest/androidRegression.xml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
<include name="noCardsAvailableToShare"/>
<include name="verifyReceivedCardTabPresent"/>
<include name="verifyPopupsForShareWithSelfie"/>
<include name="rejectingCameraAccessesOnShareScreen"/>
<!--<include name="rejectingCameraAccessesOnShareScreen"/>-->
</methods>
</class>
<class name="androidTestCases.UnlockWithPasscodeTest">
Expand Down Expand Up @@ -128,7 +128,7 @@
<include name="verifyWelcomePagesContent"/>
<include name="verifyWelcomePagesFromInjiTourGuide"/>
<include name="verifyGoBackFromInjiTourGuide"/>
<include name="verifyClickOnBackFromInjiTourGuide"/>
<!--<include name="verifyClickOnBackFromInjiTourGuide"/> //invalid testcase-->
</methods>
</class>
<class name="androidTestCases.MosipOtpAlternativeFlow">
Expand Down
11 changes: 6 additions & 5 deletions injitest/src/main/java/inji/api/AdminTestUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public static String buildaddIdentityRequestBody(String schemaJson, String uin,

requestJson.put("id", propsMap.getProperty("id"));
requestJson.put("request", new HashMap<>());
requestJson.getJSONObject("request").put("registrationId", rid);
requestJson.getJSONObject("request").put("registrationId", rid);
JSONObject identityJson = new JSONObject();
identityJson.put("UIN", uin);

Expand Down Expand Up @@ -131,7 +131,7 @@ else if (eachRequiredProp.equals("IDSchemaVersion")) {
if (eachRequiredProp.equals("phone")) {
uinPhone = propsMap.getProperty(eachRequiredProp);
}
}
}
}
}

Expand Down Expand Up @@ -168,14 +168,15 @@ public static int getOtpExpTimeFromActuator() {

for (int i = 0, size = responseArray.length(); i < size; i++) {
JSONObject eachJson = responseArray.getJSONObject(i);
System.out.println("eachJson is :" +eachJson.toString());
logger.info("eachJson is :" + eachJson.toString());
if (eachJson.get("name").toString().contains(section)) {

JSONObject otpExpiryTime = (JSONObject) eachJson
.getJSONObject(GlobalConstants.PROPERTIES).get("mosip.kernel.otp.expiry-time");
otpExpTime = otpExpiryTime.getString(GlobalConstants.VALUE);
if (ConfigManager.IsDebugEnabled())
logger.info("Actuator: " +url +" otpExpTime: "+otpExpTime);
// if (ConfigManager.IsDebugEnabled())
// logger.info("Actuator: " +url +" otpExpTime: "+otpExpTime);
break;
}
}
Expand Down Expand Up @@ -211,7 +212,7 @@ public static String generateUIN() {
if (!AdminTestUtil.activateUIN(requestjson, tokenRoleIdRepo)) {
// UIN activation failed
return "";
}
}

return uin;
}
Expand Down
13 changes: 9 additions & 4 deletions injitest/src/main/java/inji/api/BaseTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class BaseTestCase {
UinGenerationUtil.getResourcePath() + "/config/application.properties");
public static Properties propsKernel = getproperty(
UinGenerationUtil.getResourcePath() + "/config/"+ UinGenerationUtil.getKernalFilename());


public static Properties propsMap = getproperty(
UinGenerationUtil.getResourcePath() + "/config/valueMapping.properties");
public static Properties propsBio = getproperty(
Expand Down Expand Up @@ -179,10 +181,13 @@ private static Properties getLoggerPropertyConfig() {

//ToDo - Need to address this
public static String getOtp() {
/*String otp="";
String externalemail = TestDataReader.readData("externalemail");
otp = MockSMTPListener.getOtp(externalemail);*/
return "111111";
// ConfigManager.init();
// mockSMTPListener = new MockSMTPListener();
// mockSMTPListener.run();
String otp="111111";
// String externalemail = TestDataReader.readData("externalemail");
// otp = MockSMTPListener.getOtp(externalemail);
return otp;
}

public static JSONObject getRequestJson(String filepath) {
Expand Down
1 change: 1 addition & 0 deletions injitest/src/main/java/inji/api/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public static void init() {
// Loading Kernel property
//LOGGER.info("file location"+TestRunner.getResourcePath() + "/config/));
propsKernel = getproperty(UinGenerationUtil.getResourcePath() + "/config/"+ UinGenerationUtil.getKernalFilename());
System.out.println(propsKernel);

idrepo_client_secret = getValueForKey(MOSIP_IDREPO_CLIENT_SECRET);
idrepo_client_id = getValueForKey(MOSIP_IDREPO_CLIENT_ID);
Expand Down
8 changes: 7 additions & 1 deletion injitest/src/main/java/inji/pages/AboutInjiPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@ public boolean isAppIdVisible() {

public boolean isTuvaliVesionVisible() {
String tuvaliVersion = getTextFromLocator(tuvaliVesion);
return tuvaliVersion.length() == 21;
if(tuvaliVersion.contains("0.5.0")){
return true;
}
else if(tuvaliVersion.contains("0.5.1")){
return true;
}else
return false;
}

public AboutInjiPage(AppiumDriver driver) {
Expand Down
20 changes: 20 additions & 0 deletions injitest/src/main/java/inji/pages/AddNewCardPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,18 @@ public class AddNewCardPage extends BasePage{
@iOSXCUITFindBy(accessibility = "issuerHeading-Sunbird")
private WebElement downloadViaSunbird;

@AndroidFindBy(accessibility = "iissuerHeading-StayProtected")
@iOSXCUITFindBy(accessibility = "issuerHeading-StayProtected")
private WebElement downloadViaStayProtected;

@AndroidFindBy(accessibility = "credentialTypeHeading-InsuranceCredential")
@iOSXCUITFindBy(accessibility = "credentialTypeHeading-InsuranceCredential")
private WebElement credentialTypeHeadingInsuranceCredential;

@AndroidFindBy(accessibility = "credentialTypeHeading-MOSIPVerifiableCredential")
@iOSXCUITFindBy(accessibility = "credentialTypeHeading-MOSIPVerifiableCredential")
private WebElement credentialTypeHeadingMOSIPVerifiableCredential;

public AddNewCardPage(AppiumDriver driver) {
super(driver);
}
Expand All @@ -71,6 +79,9 @@ public boolean isAddNewCardPageLoaded() {

public RetrieveIdPage clickOnDownloadViaUin(){
clickOnElement(downloadViaUin);
if(isElementDisplayed(credentialTypeHeadingMOSIPVerifiableCredential)){
clickOnElement(credentialTypeHeadingMOSIPVerifiableCredential);
}
return new RetrieveIdPage(driver);
}

Expand Down Expand Up @@ -104,6 +115,15 @@ public boolean isDownloadViaEsignetDisplayedinFillpino() {

public EsignetLoginPage clickOnDownloadViaEsignet(){
clickOnElement(downloadViaEsignet);

try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
if(isElementDisplayed(credentialTypeHeadingMOSIPVerifiableCredential)) {
clickOnElement(credentialTypeHeadingMOSIPVerifiableCredential);
}
return new EsignetLoginPage(driver);
}

Expand Down
13 changes: 6 additions & 7 deletions injitest/src/main/java/inji/pages/BackupAndRestorePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.appium.java_client.pagefactory.iOSXCUITFindBy;
import org.openqa.selenium.WebElement;

public class BackupAndRestorePage extends BasePage {
Expand Down Expand Up @@ -155,12 +154,12 @@ public void enterEmailTextBox(String fullname) {

public void enterPasswordTextBox(String fullname) {
try {
basePage.retrieToGetElement(enterPassword);
basePage.retryToGetElement(enterPassword);
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
basePage.retrieToGetElement(enterPassword);
basePage.retryToGetElement(enterPassword);
sendKeysToTextBox(enterPassword, fullname);
}

Expand All @@ -181,15 +180,15 @@ public boolean islastBackupTimeDisplayed() {
}

public boolean isDataBackupSuccessPopupDisplayed() {
return this.retrieIsElementVisible(dataBackupSuccessPopup);
return this.retryElementVisible(dataBackupSuccessPopup);
}

public void clickOnCloseButton() {
clickOnElement(closeButton);
}

public void clickOnArrowLeftButton() {
basePage.retrieToGetElement(arrowLeftButton);
basePage.retryToGetElement(arrowLeftButton);
clickOnElement(arrowLeftButton);
}

Expand All @@ -206,7 +205,7 @@ public boolean isAssociatedAccountEmailDisplayed() {
}

public boolean isRestoreBackupSuccessPopUpDisplayed() {
return this.retrieIsElementVisible(restoreBackupSuccessPopUp);
return this.retryElementVisible(restoreBackupSuccessPopUp);
}

public boolean isPermissionDeniedHeaderDisplayed() {
Expand Down Expand Up @@ -292,7 +291,7 @@ public void clickOnEmailHeader() {
}

public boolean isBackupFQADisplayed() throws InterruptedException {
Thread.sleep(5000);
Thread.sleep(2000);
String context= driver.getPageSource();
return context.contains("Why should I take a backup?") && context.contains("What is data backup? ") && context.contains("How to backup to your google account?");
}
Expand Down
4 changes: 2 additions & 2 deletions injitest/src/main/java/inji/pages/BackupDataTourPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public BackupDataTourPage(AppiumDriver driver) {
BasePage basePage = new BasePage(driver);

public String verifyLanguageforBackupDataPageLoaded(){
basePage.retrieToGetElement(backupDataText);
basePage.retryToGetElement(backupDataText);
return getTextFromLocator(backupDataText);
}

public String getBackupDataPageDescription() {

basePage.retrieToGetElement(backupDataDescription);
basePage.retryToGetElement(backupDataDescription);
return this.getTextFromLocator(backupDataDescription);
}

Expand Down
15 changes: 8 additions & 7 deletions injitest/src/main/java/inji/pages/BasePage.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package inji.pages;

import inji.utils.UinGenerationUtil;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import org.openqa.selenium.By;
import org.openqa.selenium.StaleElementReferenceException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.SessionId;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.io.IOException;

import static java.time.Duration.ofSeconds;

public class BasePage {
Expand Down Expand Up @@ -124,11 +120,16 @@ protected void sendKeysToTextBox(WebElement element, String text) {
}

protected String getTextFromLocator(WebElement element) {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
this.waitForElementToBeVisible(element);
return element.getText();
}

protected String retrieToGetElement(WebElement element) {
protected String retryToGetElement(WebElement element) {
int maxRetries = 3;
String text = null;
for (int i = 0; i < maxRetries; i++) {
Expand All @@ -144,7 +145,7 @@ protected String retrieToGetElement(WebElement element) {
return text;

}
public boolean retrieIsElementVisible(WebElement element) {
public boolean retryElementVisible(WebElement element) {
int maxRetries = 3;
for (int i = 0; i < maxRetries; i++) {
try {
Expand All @@ -156,7 +157,7 @@ public boolean retrieIsElementVisible(WebElement element) {
return false;
}

public void retrieClickOnElemet(WebElement element) {
public void retryClickOnElemet(WebElement element) {
int maxRetries = 3;
for (int i = 0; i < maxRetries; i++) {
try {
Expand Down
9 changes: 9 additions & 0 deletions injitest/src/main/java/inji/pages/DetailedVcViewPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public class DetailedVcViewPage extends BasePage{
@iOSXCUITFindBy(accessibility = "goBack")
public WebElement backArrow;

@AndroidFindBy(accessibility = "arrow-left")
@iOSXCUITFindBy(accessibility = "arrow-left")
public WebElement arrowleft;

@AndroidFindBy(accessibility = "KebabIcon")
@iOSXCUITFindBy(accessibility = "KebabIcon")
public WebElement moreOptionsButton;
Expand Down Expand Up @@ -164,6 +168,11 @@ public HomePage clickOnBackArrow() {
return new HomePage(driver);
}

public HomePage clickOnArrowleft() {
clickOnElement(arrowleft);
return new HomePage(driver);
}

public HomePage clickOnQrCrossIcon() {
if (isElementDisplayed(qrCloseIcon)){
clickOnElement(qrCloseIcon);
Expand Down
Loading

0 comments on commit 94a0289

Please sign in to comment.