Skip to content

Commit

Permalink
Test script updated for new apk (#977)
Browse files Browse the repository at this point in the history
Signed-off-by: kamalsingh <[email protected]>
  • Loading branch information
kamalsinghthoughtworks authored Oct 31, 2023
1 parent e82599f commit 6e9fe5c
Show file tree
Hide file tree
Showing 70 changed files with 159 additions and 66 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package io.mosip.test.mob.inji.pages;

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

public class AddNewCardPage extends BasePage{

@AndroidFindBy(accessibility = "issuersScreenHeader")
private WebElement addNewCardHeader;

@AndroidFindBy(accessibility = "issuerHeading-Mosip")
private WebElement downloadViaUin;
public AddNewCardPage(AppiumDriver driver) {
super(driver);
}

public boolean isAddNewCardPageLoaded() {
return this.isElementDisplayed(addNewCardHeader, "Home page");
}

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

public class AppUnlockMethodPage extends BasePage {

@AndroidFindBy(xpath = "//*[contains(@text,'Select App Unlock Method')]")
@AndroidFindBy(accessibility = "selectAppUnlockMethod")
@iOSXCUITFindBy(accessibility = "Select App Unlock Method")
private WebElement selectAppUnlockMethodText;

@AndroidFindBy(xpath = "//*[contains(@text,'Use Passcode')]")
@AndroidFindBy(accessibility = "usePasscode")
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeButton[`label == \"Use Passcode\"`]")
private WebElement usePasscodeButton;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import io.mosip.test.mob.inji.utils.CommonMethods;

import static java.time.Duration.ofSeconds;

Expand All @@ -31,7 +30,7 @@ protected boolean isElementDisplayed(By locator, long seconds, String elementNam
ExtentLogger.pass(elementName + " is displayed");
return true;
} catch (Exception e) {
ExtentLogger.fail(elementName + " is not displayed");
//ExtentLogger.fail(elementName + " is not displayed");
return false;
}
}
Expand All @@ -42,7 +41,7 @@ protected boolean isElementDisplayed(WebElement element, String elementName) {
ExtentLogger.pass(elementName + " is displayed");
return true;
} catch (Exception e) {
ExtentLogger.fail(elementName + " is not displayed");
//ExtentLogger.fail(elementName + " is not displayed");
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.appium.java_client.pagefactory.iOSXCUITFindBy;
import org.openqa.selenium.WebElement;
import io.mosip.test.mob.inji.utils.CommonMethods;
import utils.CommonMethods;


public class ChooseLanguagePage extends BasePage {

@AndroidFindBy(xpath = "//*[contains(@text,'Choose Language')]")
@AndroidFindBy(accessibility = "chooseLanguage")
@iOSXCUITFindBy(accessibility = "Choose Language")
private WebElement chooseLanguageText;

@AndroidFindBy(xpath = "//*[contains(@text,'Save Preference')]")
@AndroidFindBy(accessibility = "savePreference")
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeButton[`label == \"Save Preference\"`]")
private WebElement savePreferenceText;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public GenerateUinOrVidPage enterApplicationID(String applicationId) {
return this;
}

public OtpVerification clickOnGetUinOrVidButton() {
public OtpVerificationPage clickOnGetUinOrVidButton() {
clickOnElement(getUinOrVidButton);
return new OtpVerification(driver);
return new OtpVerificationPage(driver);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class HelpPage extends BasePage {

@AndroidFindBy(xpath = "//*[contains(@text,'Help')]")
@AndroidFindBy(accessibility = "helpScreen")
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeStaticText[`label == \"Help\"`]")
private WebElement helpText;

Expand Down
18 changes: 13 additions & 5 deletions injitest/src/main/java/io/mosip/test/mob/inji/pages/HomePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.openqa.selenium.WebElement;

public class HomePage extends BasePage {
@AndroidFindBy(xpath = "//*[contains(@text,'Download Card')]")
@AndroidFindBy(uiAutomator = "new UiSelector().resourceId(\"downloadIcon\")")
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeButton[`label == \"Download Card\"`]")
private WebElement downloadCardButton;

Expand All @@ -34,27 +34,35 @@ public class HomePage extends BasePage {
@AndroidFindBy(xpath = "//*[contains(@text,'Secure Key Storage not found')]")
private WebElement secureKeyStoragePopup;

@AndroidFindBy(xpath = "//*[contains(@text,'Some security features will be unavailable')]")
private WebElement securityFeatureUnavailablePopup;

@AndroidFindBy(xpath = "//*[contains(@text,'OK, I')]")
private WebElement riskItButton;

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

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


public HomePage(AppiumDriver driver) {
super(driver);
}

public boolean isHomePageLoaded() {
if (isElementDisplayed(secureKeyStoragePopup, "secure key storage popup")) {
/*if (isElementDisplayed(secureKeyStoragePopup, "secure key storage popup")) {
clickOnElement(riskItButton);
}*/
if (isElementDisplayed(securityFeatureUnavailablePopup, "security features will be unavailable popup")) {
clickOnElement(okButton);
}
return this.isElementDisplayed(homeButton, "Home page");
}

public RetrieveIdPage downloadCard() {
public AddNewCardPage downloadCard() {
this.clickOnElement(downloadCardButton);
return new RetrieveIdPage(driver);
return new AddNewCardPage(driver);
}

public boolean isNameDisplayed(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@

public class MoreOptionsPage extends BasePage {

@AndroidFindBy(xpath = "//*[contains(@text,'Remove from Wallet')]")
@AndroidFindBy(accessibility = "removeFromWallet")
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeStaticText[`name == \"listItemTitle\"`][4]")
private WebElement removeFromWalletButton;

@AndroidFindBy(xpath = "//*[contains(@text,'More Options')]")
@AndroidFindBy(accessibility = "kebabTitle")
@iOSXCUITFindBy(accessibility = "More Options")
private WebElement moreOptionsText;

@AndroidFindBy(xpath = "//*[contains(@text,'Pin Card')]")
@AndroidFindBy(accessibility = "pinOrUnPinCard")
private WebElement pinOrUnPinCardButton;

@AndroidFindBy(xpath = "//*[contains(@text,'Activation pending for online login!')]")
@AndroidFindBy(accessibility = "pendingActivationOrActivated")
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeStaticText[`label == \"Activation pending for online login!\"`]")
private WebElement activationPending;

@AndroidFindBy(xpath = "//*[contains(@text,'Activated for online login!')]")
@AndroidFindBy(accessibility = "profileAuthenticated")
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeOther[`label == \"\uE8E8 Activated for online login!\"`][4]")
private WebElement activatedForOnlineLoginButton;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
import io.appium.java_client.pagefactory.iOSXCUITFindBy;
import org.openqa.selenium.WebElement;

public class OtpVerification extends BasePage {
public class OtpVerificationPage extends BasePage {

@AndroidFindBy(xpath = "//*[contains(@text,'OTP Verification')]")
@iOSXCUITFindBy(accessibility = "OTP Verification")
private WebElement otpVerificationText;

public OtpVerification(AppiumDriver driver) {
public OtpVerificationPage(AppiumDriver driver) {
super(driver);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public boolean isPleaseConfirmPopupPageLoaded() {
return this.isElementDisplayed(yesButton, "Popup confirmation page");
}

public void clickOnConfirmButton() {
public OtpVerificationPage clickOnConfirmButton() {
clickOnElement(yesButton);
return new OtpVerificationPage(driver);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public RetrieveIdPage setEnterIdTextBox(String uinOrVid) {
return this;
}

public OtpVerification clickOnGenerateCardButton() {
public OtpVerificationPage clickOnGenerateCardButton() {
this.clickOnElement(generateCardButton);
return new OtpVerification(driver);
return new OtpVerificationPage(driver);
}

public GenerateUinOrVidPage clickOnGetItNowText() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.mosip.test.mob.inji.pages;

import io.mosip.test.mob.inji.constants.Target;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.appium.java_client.pagefactory.iOSXCUITFindBy;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import io.mosip.test.mob.inji.constants.Target;

public class SetPasscode extends BasePage {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

public class SettingsPage extends BasePage {

@AndroidFindBy(xpath = "//*[contains(@text,'Settings')]")
@AndroidFindBy(accessibility = "settingsScreen")
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeStaticText[`label == \"Settings\"`]")
private WebElement settingsTittle;

@AndroidFindBy(xpath = "//*[contains(@text,'Logout')]")
@AndroidFindBy(accessibility = "logout")
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeStaticText[`label == \"Logout\"`]")
private WebElement logoutButton;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public class UnlockApplicationPage extends BasePage {

@AndroidFindBy(xpath = "//*[contains(@text,'Unlock application')]")
@AndroidFindBy(accessibility = "unlockApplication")
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeButton[`label == \"Unlock application\"`]")
private WebElement unlockApplicationButton;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@

public class WelcomePage extends BasePage {

@AndroidFindBy(xpath = "//*[contains(@text,'Welcome!')]")
@AndroidFindBy(accessibility = "introTitle")
@iOSXCUITFindBy(accessibility = "Welcome!")
private WebElement welcomeText;

@AndroidFindBy(xpath = "(//*[@class='android.widget.TextView'])[3]")
@AndroidFindBy(accessibility = "introText")
@iOSXCUITFindBy(xpath = "//*[contains(@value,'Keep your digital')]")
private WebElement welcomeTextDescription;

@AndroidFindBy(xpath = "//*[contains(@text,'Skip')]")
@AndroidFindBy(accessibility = "skip")
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeButton[`label == \"Skip\"`][1]")
private WebElement skipButton;

@AndroidFindBy(xpath = "//*[@text='Next']")
@AndroidFindBy(accessibility = "next")
@iOSXCUITFindBy(iOSClassChain = "**/XCUIElementTypeOther[`label == \"Next\"`][4]")
private WebElement nextButton;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package io.mosip.test.mob.inji.testcases;

import org.testng.annotations.Test;
import io.mosip.test.mob.inji.pages.*;
import io.mosip.test.mob.inji.utils.TestDataReader;
import org.testng.annotations.Test;


import static org.testng.Assert.assertTrue;

public class ActivateVcTest extends BaseTest {
@Test(groups = "AVT")
@Test
public void activateVc() throws InterruptedException {
ChooseLanguagePage chooseLanguagePage = new ChooseLanguagePage(driver);

Expand All @@ -27,10 +28,13 @@ public void activateVc() throws InterruptedException {
HomePage homePage = confirmPasscode.confirmPasscode(TestDataReader.readData("passcode"), target);

assertTrue(homePage.isHomePageLoaded(), "Verify if home page is displayed");
RetrieveIdPage retrieveIdPage = homePage.downloadCard();
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");
OtpVerification otpVerification = retrieveIdPage.setEnterIdTextBox(TestDataReader.readData("uin")).clickOnGenerateCardButton();
OtpVerificationPage otpVerification = retrieveIdPage.setEnterIdTextBox(TestDataReader.readData("uin")).clickOnGenerateCardButton();

assertTrue(otpVerification.isOtpVerificationPageLoaded(), "Verify if otp verification page is displayed");
otpVerification.enterOtp(TestDataReader.readData("otp"), target);
Expand All @@ -42,7 +46,10 @@ public void activateVc() throws InterruptedException {
PleaseConfirmPopupPage pleaseConfirmPopupPage = moreOptionsPage.clickOnActivationPending();

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

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

assertTrue(moreOptionsPage.isVcActivatedForOnlineLogin(), "Verify if VC is activated");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package io.mosip.test.mob.inji.testcases;


import io.appium.java_client.AppiumDriver;
import io.mosip.test.mob.inji.constants.Target;
import io.mosip.test.mob.inji.driver.DriverManager;
import io.mosip.test.mob.inji.exceptions.PlatformNotSupportException;
import io.appium.java_client.AppiumDriver;
import org.testng.annotations.*;


import java.net.MalformedURLException;

public class BaseTest {
Expand All @@ -26,10 +28,12 @@ public void setup(String platformName) {
} catch (MalformedURLException | PlatformNotSupportException | InterruptedException e) {
throw new RuntimeException(e);
}
//ScreenRecording.startScreenRecording(driver);
}

@AfterMethod(alwaysRun = true)
public void teardown() {
//ScreenRecording.stopScreenRecording(driver);
driver.quit();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class ChangeLanguageTest extends BaseTest {

@Test(groups = "CLT")
@Test
public void changeLanguage() {
ChooseLanguagePage chooseLanguagePage = new ChooseLanguagePage(driver);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import static org.testng.Assert.assertTrue;

public class DeletingVcTest extends BaseTest {
@Test(groups = "DVT")
@Test
public void deleteVc() throws InterruptedException {
ChooseLanguagePage chooseLanguagePage = new ChooseLanguagePage(driver);

Expand All @@ -28,10 +28,13 @@ public void deleteVc() throws InterruptedException {
HomePage homePage = confirmPasscode.confirmPasscode(TestDataReader.readData("passcode"), target);

assertTrue(homePage.isHomePageLoaded(), "Verify if home page is displayed");
RetrieveIdPage retrieveIdPage = homePage.downloadCard();
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");
OtpVerification otpVerification = retrieveIdPage.setEnterIdTextBox(TestDataReader.readData("uin")).clickOnGenerateCardButton();
OtpVerificationPage otpVerification = retrieveIdPage.setEnterIdTextBox(TestDataReader.readData("uin")).clickOnGenerateCardButton();

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

0 comments on commit 6e9fe5c

Please sign in to comment.