Skip to content

Commit

Permalink
MOSIP-28901 | Regression test cases added for android (#1001)
Browse files Browse the repository at this point in the history
* Test script updated for new apk

Signed-off-by: kamalsingh <[email protected]>

* new test cases added

Signed-off-by: kamalsingh <[email protected]>

* new test cases added from master sheet

Signed-off-by: kamalsingh <[email protected]>

* Test cases added from regression sheet

Signed-off-by: kamalsingh <[email protected]>

---------

Signed-off-by: kamalsingh <[email protected]>
  • Loading branch information
kamalsinghthoughtworks authored Nov 10, 2023
1 parent 1ce89cb commit 2152c98
Show file tree
Hide file tree
Showing 14 changed files with 563 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,42 @@ public class DetailedVcViewPage extends BasePage{
@AndroidFindBy(xpath = "//*[contains(@text,'ID Details')]")
private WebElement detailedVcViewPageTitle;

@AndroidFindBy(accessibility = "fullNameValue")
private WebElement fullNameValue;

@AndroidFindBy(accessibility = "genderValue")
private WebElement genderValue;

@AndroidFindBy(accessibility = "dateOfBirthValue")
private WebElement dateOfBirthValue;

@AndroidFindBy(accessibility = "nationalCard")
private WebElement idTypeValue;

@AndroidFindBy(accessibility = "valid")
private WebElement statusValue;

@AndroidFindBy(accessibility = "uinNumber")
private WebElement uinNumberValue;

@AndroidFindBy(accessibility = "generatedOnValue")
private WebElement generatedOnValue;

@AndroidFindBy(accessibility = "phoneNumberValue")
private WebElement phoneNumberValue;

@AndroidFindBy(accessibility = "emailIdValue")
private WebElement emailIdValue;

@AndroidFindBy(accessibility = "enableVerification")
private WebElement activateButton;

@AndroidFindBy(accessibility = "profileAuthenticated")
private WebElement profileAuthenticated;

@AndroidFindBy(accessibility = "close")
private WebElement crossIcon;

public DetailedVcViewPage(AppiumDriver driver) {
super(driver);
}
Expand All @@ -18,8 +54,57 @@ public boolean isDetailedVcViewPageLoaded() {
return this.isElementDisplayed(detailedVcViewPageTitle, "detailed Vc view page title page");
}

public boolean isDetailedVcViewLoaded(String name) {
By fullName = By.xpath("//*[contains(@name,'" + name + "') or contains(@text,'" + name + "')]");
return this.isElementDisplayed(fullName, 60, "Name on downloaded card");
public String getNameInDetailedVcView() {
return getTextFromLocator(fullNameValue);
}

public String getGenderInDetailedVcView() {
return getTextFromLocator(genderValue);
}

public String getDateOfBirthInDetailedVcView() {
return getTextFromLocator(dateOfBirthValue);
}

public String getIdTypeValueInDetailedVcView() {
return getTextFromLocator(idTypeValue);
}

public String getStatusInDetailedVcView() {
return getTextFromLocator(statusValue);
}

public String getUinInDetailedVcView() {
return getTextFromLocator(uinNumberValue);
}

public String getGeneratedOnValueInDetailedVcView() {
return getTextFromLocator(generatedOnValue);
}

public String getPhoneInDetailedVcView() {
return getTextFromLocator(phoneNumberValue);
}

public String getEmailInDetailedVcView() {
return getTextFromLocator(emailIdValue);
}

public boolean isActivateButtonDisplayed() {
return this.isElementDisplayed(activateButton, "activate button");
}

public PleaseConfirmPopupPage clickOnActivateButton(){
clickOnElement(activateButton);
return new PleaseConfirmPopupPage(driver);
}

public boolean isProfileAuthenticatedDisplayed() {
return this.isElementDisplayed(profileAuthenticated, "Credentials are enabled for online authentication");
}

public HomePage clickOnCrossIcon(){
clickOnElement(crossIcon);
return new HomePage(driver);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ private boolean verifyHistoryIos(String vcNumber) {
By locator = By.xpath("//*[contains(@name,'" + vcNumber + " downloaded')]");
return this.isElementDisplayed(locator, "Downloaded VC in ios");
}



private boolean verifyHistoryAndroid(String vcNumber) {
By locator = By.xpath("//*[contains(@text,'" + vcNumber + " downloaded')]");
Expand Down Expand Up @@ -87,4 +85,44 @@ public boolean verifyDeleteHistory(String vcNumber, Target os) {
}
return false;
}

public boolean verifyActivationFailedRecordInHistory(String vcNumber, Target os) {
switch (os) {
case ANDROID:
return verifyActivationFailedRecordAndroid(vcNumber);
case IOS:
return verifyActivationFailedRecordIos(vcNumber);
}
return false;
}

private boolean verifyActivationFailedRecordIos(String vcNumber) {
By locator = By.xpath("//*[contains(@name,'" + vcNumber + " Activation failed')]");
return this.isElementDisplayed(locator, "Downloaded VC in ios");
}

private boolean verifyActivationFailedRecordAndroid(String vcNumber) {
By locator = By.xpath("//*[contains(@text,'" + vcNumber + " Activation failed')]");
return this.isElementDisplayed(locator, "Downloaded VC in android");
}

public boolean verifyActivationSuccessfulRecordInHistory(String vcNumber, Target os) {
switch (os) {
case ANDROID:
return verifyActivationFailedRecordAndroid(vcNumber);
case IOS:
return verifyActivationFailedRecordIos(vcNumber);
}
return false;
}

private boolean verifyActivationSuccessfulRecordIos(String vcNumber) {
By locator = By.xpath("//*[contains(@name,'" + vcNumber + " Activation successful')]");
return this.isElementDisplayed(locator, "Downloaded VC in ios");
}

private boolean verifyActivationSuccessfulRecordAndroid(String vcNumber) {
By locator = By.xpath("//*[contains(@text,'" + vcNumber + " Activation successful')]");
return this.isElementDisplayed(locator, "Downloaded VC in android");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public class HomePage extends BasePage {
@AndroidFindBy(xpath = "//*[contains(@text,'Scan')]")
private WebElement scanButton;

@AndroidFindBy(accessibility = "nationalCard")
private WebElement idTypeValue;


public HomePage(AppiumDriver driver) {
super(driver);
Expand Down Expand Up @@ -130,5 +133,8 @@ public ScanPage clickOnScanButton(){
clickOnElement(scanButton);
return new ScanPage(driver);
}
public boolean isIdTypeDisplayed() {
return this.isElementDisplayed(idTypeValue, "Name on downloaded card");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ public class OtpVerificationPage extends BasePage {
@AndroidFindBy(xpath = "//*[contains(@text,'OTP is invalid')]")
private WebElement invalidOtpMessage;

@AndroidFindBy(xpath = "//*[contains(@text,'Something is wrong. Please try again later!')]")
private WebElement invalidOtpMessageInVcActivation;

@AndroidFindBy(xpath = "//*[contains(@text,'Cancel')]")
private WebElement cancelButton;

@AndroidFindBy(accessibility = "close")
private WebElement crossIcon;

public OtpVerificationPage(AppiumDriver driver) {
super(driver);
}
Expand All @@ -32,4 +41,20 @@ public HomePage enterOtp(String otp, Target os) {
public boolean invalidOtpMessageDisplayed() {
return this.isElementDisplayed(invalidOtpMessage, "OTP is invalid");
}

public boolean somethingWetWrongInVcActivationDisplayed() {
return this.isElementDisplayed(invalidOtpMessageInVcActivation, "Something is wrong. Please try again later!");
}

public boolean isCancelButtonDisplayed() {
return this.isElementDisplayed(cancelButton, "Cancel button");
}

public MoreOptionsPage clickOnCancelButton(){
clickOnElement(cancelButton);
return new MoreOptionsPage(driver);
}
public void clickOnCrossIcon(){
clickOnElement(crossIcon);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public boolean isRetrieveIdPageLoaded() {
}

public RetrieveIdPage setEnterIdTextBox(String uinOrVid) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
sendKeysToTextBox(enterIdTextBox, uinOrVid, "uin or vid textbox");
return this;
}
Expand Down
15 changes: 11 additions & 4 deletions injitest/src/main/java/io/mosip/test/mob/inji/pages/ScanPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ public class ScanPage extends BasePage{

@AndroidFindBy(uiAutomator = "new UiSelector().textContains(\"Allow\")")
private WebElement allowButton;


@AndroidFindBy(uiAutomator = "new UiSelector().textContains(\"No shareable cards are available.\")")
private WebElement noShareableCards;

@AndroidFindBy(className = "android.widget.ImageView")
private WebElement flipCamera;

@AndroidFindBy(xpath = "//*[contains(@text,'Hold the phone steady and scan the QR code')]")
private WebElement holdCameraSteady;

Expand All @@ -38,11 +41,15 @@ public ScanPage acceptPermissionPopup(){
public boolean isCameraOpen(){
return isElementDisplayed(camera, "camera");
}


public boolean isNoShareableCardsMessageDisplayed(){
return isElementDisplayed(noShareableCards, "No shareable cards are available.");
}

public boolean isCameraPageLoaded() {
return this.isElementEnabled(holdCameraSteady);
}

public boolean isFlipCameraClickable() {
return this.isElementEnabled(flipCamera);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void noPreDownloadedVCAndNoHistoryInFreshInstallation() {
}

@Test
public void verifyInvalidUinErrorMessage() {
public void verifyInvalidOtpMessage() {
ChooseLanguagePage chooseLanguagePage = new ChooseLanguagePage(driver);

assertTrue(chooseLanguagePage.isChooseLanguagePageLoaded(), "Verify if choose language page is displayed");
Expand All @@ -113,13 +113,17 @@ public void verifyInvalidUinErrorMessage() {
RetrieveIdPage retrieveIdPage = addNewCardPage.clickOnDownloadViaUin();

assertTrue(retrieveIdPage.isRetrieveIdPageLoaded(), "Verify if retrieve id page is displayed");
retrieveIdPage.setEnterIdTextBox("00").clickOnGenerateCardButton();
OtpVerificationPage otpVerification = retrieveIdPage.setEnterIdTextBox(BaseTestCase.uin).clickOnGenerateCardButton();

assertTrue(otpVerification.isOtpVerificationPageLoaded(), "Verify if otp verification page is displayed");
otpVerification.enterOtp(TestDataReader.readData("invalidOtp"), target);

assertTrue(otpVerification.invalidOtpMessageDisplayed(), "Verify if OTP is invalid message is displayed");

assertTrue(retrieveIdPage.isIncorrectInputFormatErrorMessageDisplayed());
}

@Test
public void verifyInvalidOtpMessage() {
public void activateVcFromDetailedViewPage() throws InterruptedException {
ChooseLanguagePage chooseLanguagePage = new ChooseLanguagePage(driver);

assertTrue(chooseLanguagePage.isChooseLanguagePageLoaded(), "Verify if choose language page is displayed");
Expand All @@ -145,12 +149,23 @@ public void verifyInvalidOtpMessage() {
RetrieveIdPage retrieveIdPage = addNewCardPage.clickOnDownloadViaUin();

assertTrue(retrieveIdPage.isRetrieveIdPageLoaded(), "Verify if retrieve id page is displayed");
OtpVerificationPage otpVerification = retrieveIdPage.setEnterIdTextBox(BaseTestCase.uin).clickOnGenerateCardButton();
OtpVerificationPage otpVerification = retrieveIdPage.setEnterIdTextBox(TestDataReader.readData("uin")).clickOnGenerateCardButton();

assertTrue(otpVerification.isOtpVerificationPageLoaded(), "Verify if otp verification page is displayed");
otpVerification.enterOtp(TestDataReader.readData("invalidOtp"), target);
otpVerification.enterOtp(GetOtp(), target);

assertTrue(otpVerification.invalidOtpMessageDisplayed(), "Verify if OTP is invalid message is displayed");
assertTrue(homePage.isNameDisplayed(TestDataReader.readData("fullName")), "Verify if full name is displayed");

DetailedVcViewPage detailedVcViewPage = homePage.openDetailedVcView(TestDataReader.readData("fullName"));
assertTrue(detailedVcViewPage.isDetailedVcViewPageLoaded(), "Verify if detailed Vc view page is displayed");
PleaseConfirmPopupPage pleaseConfirmPopupPage = detailedVcViewPage.clickOnActivateButton();

assertTrue(pleaseConfirmPopupPage.isPleaseConfirmPopupPageLoaded(), "Verify if pop up page is displayed");
OtpVerificationPage otpVerificationPage = pleaseConfirmPopupPage.clickOnConfirmButton();

assertTrue(otpVerificationPage.isOtpVerificationPageLoaded(), "Verify if otp verification page is displayed");
otpVerificationPage.enterOtp(TestDataReader.readData("passcode"), target);

assertTrue(detailedVcViewPage.isProfileAuthenticatedDisplayed(), "Verify if VC is activated");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,42 @@ public void generateUinOrVidUsingAid() {
assertTrue(homePage.isNameDisplayed(TestDataReader.readData("fullName")), "Verify if full name is displayed");

}

@Test
public void goBackToGenerateUinOrVidUsingAidFromOtpVerificationPage() {
ChooseLanguagePage chooseLanguagePage = new ChooseLanguagePage(driver);

assertTrue(chooseLanguagePage.isChooseLanguagePageLoaded(), "Verify if choose language page is displayed");
WelcomePage welcomePage = chooseLanguagePage.clickOnSavePreference();

assertTrue(welcomePage.isWelcomePageLoaded(), "Verify if welcome page is loaded");
AppUnlockMethodPage appUnlockMethodPage = welcomePage.clickOnSkipButton();

assertTrue(appUnlockMethodPage.isAppUnlockMethodPageLoaded(), "Verify if app unlocked page is displayed");
SetPasscode setPasscode = appUnlockMethodPage.clickOnUsePasscode();

assertTrue(setPasscode.isSetPassCodePageLoaded(), "Verify if set passcode page is displayed");
ConfirmPasscode confirmPasscode = setPasscode.enterPasscode(TestDataReader.readData("passcode"), target);

assertTrue(confirmPasscode.isConfirmPassCodePageLoaded(), "Verify if confirm passcode page is displayed");
HomePage homePage = confirmPasscode.confirmPasscode(TestDataReader.readData("passcode"), target);

assertTrue(homePage.isHomePageLoaded(), "Verify if home page is displayed");
AddNewCardPage addNewCardPage = homePage.downloadCard();

assertTrue(addNewCardPage.isAddNewCardPageLoaded(), "Verify if add new card page is displayed");
RetrieveIdPage retrieveIdPage = addNewCardPage.clickOnDownloadViaUin();

assertTrue(retrieveIdPage.isRetrieveIdPageLoaded(), "Verify if retrieve id page is displayed");
GenerateUinOrVidPage generateUinOrVidPage = retrieveIdPage.clickOnGetItNowText();

assertTrue(generateUinOrVidPage.isGenerateUinOrVidPageLoaded(), "Verify if generate uin or vid page page is displayed");
OtpVerificationPage otpVerification = generateUinOrVidPage.enterApplicationID(TestDataReader.readData("aid")).clickOnGetUinOrVidButton();

assertTrue(otpVerification.isOtpVerificationPageLoaded(), "Verify if otp verification page is displayed");
otpVerification.clickOnCrossIcon();
assertTrue(generateUinOrVidPage.isGenerateUinOrVidPageLoaded(), "Verify if generate uin or vid page page is displayed");

}

}
Loading

0 comments on commit 2152c98

Please sign in to comment.