From 00136946e9bf13ba1c71f1ff817685f2a6248213 Mon Sep 17 00:00:00 2001 From: Shridhar Kalagi Date: Tue, 11 Aug 2020 20:47:50 +0530 Subject: [PATCH] Add tests for NHA (#24) Add tests for different environments. --- .github/workflows/maven.yml | 122 +++++++++++++++++- README.md | 5 + pom.xml | 19 ++- .../Tests/APITests/APIE2E/E2EAPITest.java | 79 ++++++++++++ .../APITests/APIUtils/PropertiesCache.java | 13 +- .../ConsentManager/ResetPasswordAPITest.java | 20 +-- .../Tests/MobileAppTests/Flows/NCGFlow.java | 35 +++++ .../Tests/MobileAppTests/Flows/NHAFlow.java | 37 ++++++ .../Objects/BasePageObjects.java | 3 + .../Objects/HomePageObjects.java | 11 +- .../Objects/LoginPageObjects.java | 21 +++ .../Tests/MobileAppTests/Pages/BasePage.java | 12 +- .../Pages/ConsentArtifactPage.java | 5 +- .../Tests/MobileAppTests/Pages/HomePage.java | 19 +-- .../Pages/LinkAccountsPage.java | 11 +- .../Tests/MobileAppTests/Pages/LoginPage.java | 27 +--- .../Tests/MobileAppTests/Pages/OTPPage.java | 12 +- .../Pages/RegistrationPage.java | 14 +- .../Pages/SearchLinkProviderPage.java | 9 +- .../Tests/MobileAppTests/Tests/LoginTest.java | 5 +- .../Tests/RegistrationTest.java | 3 +- .../MobileAppTests/Utils/AppUtility.java | 29 +++-- .../MobileAppTests/Utils/BaseDriver.java | 30 +++-- .../Tests/MobileAppTests/Utils/IRunner.java | 9 ++ .../MobileAppTests/Utils/RunnerFactory.java | 23 ++++ .../Tests/MobileAppTests/Utils/WaitUtils.java | 32 ++--- src/test/resources/config-nhs-dev.properties | 8 ++ .../resources/config-nhs-sandbox.properties | 8 ++ src/test/resources/config-nhs-uat.properties | 8 ++ src/test/resources/config.properties | 4 + 30 files changed, 510 insertions(+), 123 deletions(-) create mode 100644 src/test/java/Tests/APITests/APIE2E/E2EAPITest.java create mode 100644 src/test/java/Tests/MobileAppTests/Flows/NCGFlow.java create mode 100644 src/test/java/Tests/MobileAppTests/Flows/NHAFlow.java create mode 100644 src/test/java/Tests/MobileAppTests/Utils/IRunner.java create mode 100644 src/test/java/Tests/MobileAppTests/Utils/RunnerFactory.java create mode 100644 src/test/resources/config-nhs-dev.properties create mode 100644 src/test/resources/config-nhs-sandbox.properties create mode 100644 src/test/resources/config-nhs-uat.properties diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index b5976a2..2b978ac 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -7,7 +7,7 @@ on: # Sequence of patterns matched against refs/heads branches: - master - - forget-consent-pin + - nha-tests jobs: API-test: runs-on: ubuntu-latest @@ -22,6 +22,7 @@ jobs: env: ConsentManagerSecret: ${{ secrets.ConsentManagerSecret }} # required HIPSecret: ${{ secrets.HIPSecret }} # required + env: ncg # required - name: Print Run id run: echo $GITHUB_RUN_ID - uses: 8398a7/action-slack@v2 @@ -34,7 +35,7 @@ jobs: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required if: always() - mobile-test: + mobile-test-ncg: runs-on: macOS-latest steps: - name: checkout @@ -48,19 +49,130 @@ jobs: node-version: '10.16' java-version: 1.8 - run: npm install -g appium - - name: run tests + - name: run mobile tests on NCG uses: reactivecircus/android-emulator-runner@v2 with: api-level: 29 + profile: Nexus 6 script: mvn clean "-Dtest=/**/MobileAppTests/Tests/*Test" test env: Authorization: ${{ secrets.Authorization }} + env: ncg # required - name: Notify on Slack uses: 8398a7/action-slack@v2 with: status: ${{ job.status }} - author_name: Functional Tests - text: Functional Mobile Tests + author_name: Functional Tests on NCG + text: Functional Mobile Tests on NCG + channel: '#botcave' + only_mention_fail: USXBM5WPQ,here + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required + if: always() + + mobile-test-nhs-dev: + runs-on: macOS-latest + steps: + - name: checkout + uses: actions/checkout@v2 + - name: set up node + uses: actions/setup-node@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + fetch-depth: 1 + node-version: '10.16' + java-version: 1.8 + - run: npm install -g appium + - name: run mobile tests on NHS Dev + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + profile: Nexus 6 + script: mvn clean "-Dtest=/**/MobileAppTests/Tests/LoginTest" test + env: + Authorization: ${{ secrets.Authorization }} + env: nhsDev # required + - name: Notify on Slack + uses: 8398a7/action-slack@v2 + with: + status: ${{ job.status }} + author_name: Functional Tests on NHS Dev + text: Functional Mobile Tests on NHS Dev + channel: '#botcave' + only_mention_fail: USXBM5WPQ,here + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required + if: always() + + +# mobile-test-nhs-UAT: +# runs-on: macOS-latest +# steps: +# - name: checkout +# uses: actions/checkout@v2 +# - name: set up node +# uses: actions/setup-node@v1 +# - name: Set up JDK 1.8 +# uses: actions/setup-java@v1 +# with: +# fetch-depth: 1 +# node-version: '10.16' +# java-version: 1.8 +# - run: npm install -g appium +# - name: run mobile tests on NHS Dev +# uses: reactivecircus/android-emulator-runner@v2 +# with: +# api-level: 29 +# profile: Nexus 6 +# script: mvn clean "-Dtest=/**/MobileAppTests/Tests/LoginTest" test +# env: +# Authorization: ${{ secrets.Authorization }} +# env: nhsUAT # required +# - name: Notify on Slack +# uses: 8398a7/action-slack@v2 +# with: +# status: ${{ job.status }} +# author_name: Functional Tests on NHS UAT +# text: Functional Mobile Tests on NHS UAT +# channel: '#botcave' +# only_mention_fail: USXBM5WPQ,here +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required +# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required +# if: always() + + mobile-test-nhs-Sandbox: + runs-on: macOS-latest + steps: + - name: checkout + uses: actions/checkout@v2 + - name: set up node + uses: actions/setup-node@v1 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + fetch-depth: 1 + node-version: '10.16' + java-version: 1.8 + - run: npm install -g appium + - name: run mobile tests on NHS Dev + uses: reactivecircus/android-emulator-runner@v2 + with: + api-level: 29 + profile: Nexus 6 + script: mvn clean "-Dtest=/**/MobileAppTests/Tests/LoginTest" test + env: + Authorization: ${{ secrets.Authorization }} + env: nhsSandbox # required + - name: Notify on Slack + uses: 8398a7/action-slack@v2 + with: + status: ${{ job.status }} + author_name: Functional Tests on NHS Sandbox + text: Functional Mobile Tests on NHS Sandbox channel: '#botcave' only_mention_fail: USXBM5WPQ,here env: diff --git a/README.md b/README.md index da8afa6..e671d52 100644 --- a/README.md +++ b/README.md @@ -8,3 +8,8 @@ Env variable for local debugging `Authorization` : `Bearer ` with public_repo and workflow scope `ConsentManagerSecret` : `Secret to generate JWT token with HIP service` + +Environments + +`env = ncg` +`env = nhsDev, nhsUAT, nhsSandbox ` diff --git a/pom.xml b/pom.xml index 0f96f9d..a07cfbd 100644 --- a/pom.xml +++ b/pom.xml @@ -6,12 +6,22 @@ org.projecteka.tests ProjectEKA-tets 1.0-SNAPSHOT - + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M5 + + + + org.testng testng - RELEASE + 6.9.8 io.rest-assured @@ -29,6 +39,11 @@ java-client 7.3.0 + + com.jayway.jsonpath + json-path + 2.4.0 + org.seleniumhq.selenium selenium-remote-driver diff --git a/src/test/java/Tests/APITests/APIE2E/E2EAPITest.java b/src/test/java/Tests/APITests/APIE2E/E2EAPITest.java new file mode 100644 index 0000000..b579b4d --- /dev/null +++ b/src/test/java/Tests/APITests/APIE2E/E2EAPITest.java @@ -0,0 +1,79 @@ +//package Tests.APITests.APIE2E; +// +//import Tests.APITests.APIUtils.HIUConsentRequest; +//import Tests.APITests.APIUtils.PropertiesCache; +//import io.restassured.RestAssured; +//import io.restassured.builder.RequestSpecBuilder; +//import io.restassured.http.ContentType; +//import io.restassured.path.json.JsonPath; +//import io.restassured.response.Response; +//import io.restassured.specification.RequestSpecification; +//import org.testng.Assert; +//import org.testng.annotations.BeforeClass; +//import org.testng.annotations.Test; +// +//public class E2EAPITest { +// RequestSpecification specification; +// +// @BeforeClass +// public void setup() { +// RestAssured.baseURI = PropertiesCache.getInstance().getProperty("consentManagerURL"); +// RestAssured.useRelaxedHTTPSValidation(); +// RequestSpecBuilder builder = new RequestSpecBuilder(); +// builder.setContentType(ContentType.JSON); +// specification = builder.build(); +// } +// +// @Test +// public void createPatient() throws InterruptedException { +// +// RequestSpecification request = RestAssured.given().spec(specification); +// String body = "{\n" + +// "\t\"identifierType\": \"mobile\",\n" + +// "\t\"identifier\": \"+91-8888888888\"\n" + +// "}"; +// Response response = request.body(body).post("/users/verify"); +// JsonPath jsonPathEvaluator = response.jsonPath(); +// Assert.assertEquals(response.getStatusCode(), 201); +// String id = jsonPathEvaluator.getString("sessionId"); +// System.out.println(id); +// +// String userPermitRequestBody = "{\n" + +// "\t\"sessionId\": \"" + id + "\",\n" + +// "\t\"value\": \"666666\"\n" + +// "}"; +// +// Response userPermitResponse = request.body(userPermitRequestBody).post("/users/permit"); +// jsonPathEvaluator = userPermitResponse.jsonPath(); +// System.out.println(jsonPathEvaluator.getString("temporaryToken")); +// +// +// +// } +// +// // @Test +// public void createConsentRequest() { +// +// RestAssured.baseURI = "https://hiu-dev.projecteka.in/api"; +// RestAssured.useRelaxedHTTPSValidation(); +// +// RequestSpecification request = RestAssured.given(); +// request.header("Content-Type", "application/json"); +// request.header("Authorization", "MUBuY2c=");//1@ncg +// +// HIUConsentRequest hiuConsentRequest = new HIUConsentRequest.ConsentRequestBuilder("1@ncg").buildConsentReuqest(); +// +// request.body(hiuConsentRequest.getJSONRequestBody().toString()); +// Response response = request.post("/consent-requests"); +// +// JsonPath jsonPathEvaluator = response.jsonPath(); +// +// Assert.assertEquals(response.getStatusCode(), 200); +// String id = jsonPathEvaluator.getString("id"); +// +// System.out.println(id); +// +// } +// +// +//} diff --git a/src/test/java/Tests/APITests/APIUtils/PropertiesCache.java b/src/test/java/Tests/APITests/APIUtils/PropertiesCache.java index 9855d7a..9faa57e 100644 --- a/src/test/java/Tests/APITests/APIUtils/PropertiesCache.java +++ b/src/test/java/Tests/APITests/APIUtils/PropertiesCache.java @@ -10,7 +10,18 @@ public class PropertiesCache { private PropertiesCache() { //Private constructor to restrict new instances - InputStream in = this.getClass().getClassLoader().getResourceAsStream("config.properties"); + InputStream in; + if ("ncg".equalsIgnoreCase(System.getenv("env"))) { + in = this.getClass().getClassLoader().getResourceAsStream("config.properties"); + } else if( "nhsDev".equalsIgnoreCase(System.getenv("env"))){ + in = this.getClass().getClassLoader().getResourceAsStream("config-nhs-dev.properties"); + } else if ("nhsUAT".equalsIgnoreCase(System.getenv("env"))) { + in = this.getClass().getClassLoader().getResourceAsStream("config-nhs-UAT.properties"); + } else if ("nhsSandbox".equalsIgnoreCase(System.getenv("env"))) { + in = this.getClass().getClassLoader().getResourceAsStream("config-nhs-Sandbox.properties"); + } + else + in = this.getClass().getClassLoader().getResourceAsStream("config-nhs-dev.properties"); System.out.println("Read all properties from file"); try { configProp.load(in); diff --git a/src/test/java/Tests/APITests/ConsentManager/ResetPasswordAPITest.java b/src/test/java/Tests/APITests/ConsentManager/ResetPasswordAPITest.java index 2d4e625..a2dfa84 100644 --- a/src/test/java/Tests/APITests/ConsentManager/ResetPasswordAPITest.java +++ b/src/test/java/Tests/APITests/ConsentManager/ResetPasswordAPITest.java @@ -12,51 +12,45 @@ public class ResetPasswordAPITest { - String authToken; - String sessionId; - String otpAuthToken; + private static String sessionId; + private static String otpAuthToken; + RequestSpecification request; @BeforeClass public void setup() { - authToken = new LoginUser().getCMAuthToken(); + RestAssured.baseURI = PropertiesCache.getInstance().getProperty("consentManagerURL"); + RestAssured.useRelaxedHTTPSValidation(); + request = RestAssured.given(); } @Test public void generateOTPAPI() { - //generate otp for enter phone # - RequestSpecification request = RestAssured.given(); request.header("Content-Type", "application/json"); request.body(new ResetPassword().getGenerateOTPRequestBody()); Response generateOTPResponse = request.post("/patients/generateotp"); - Assert.assertEquals(generateOTPResponse.getStatusCode(), 201); sessionId = generateOTPResponse.jsonPath().getString("sessionId"); } @Test(dependsOnMethods = "generateOTPAPI") public void verifyOTPAPI() { - //verify the otp - RequestSpecification request = RestAssured.given(); request.header("Content-Type", "application/json"); request.body(new ResetPassword().getVerifyOTPRequestBody(sessionId)); Response verifyOTPResponse = request.post("/patients/verifyotp"); - Assert.assertEquals(verifyOTPResponse.getStatusCode(), 200); otpAuthToken = verifyOTPResponse.jsonPath().getString("temporaryToken"); } @Test(dependsOnMethods = "verifyOTPAPI") public void resetPasswordAPI() { - //reset-password after otp confirmation - RequestSpecification request = RestAssured.given(); request.header("Content-Type", "application/json"); request.header("Authorization", otpAuthToken); request.body(new ResetPassword().getResetPasswordRequestBody()); - Response resetPasswordResponse = request.put("/patients/profile/reset-password"); + Assert.assertEquals(resetPasswordResponse.getStatusCode(), 200); } diff --git a/src/test/java/Tests/MobileAppTests/Flows/NCGFlow.java b/src/test/java/Tests/MobileAppTests/Flows/NCGFlow.java new file mode 100644 index 0000000..a55f54b --- /dev/null +++ b/src/test/java/Tests/MobileAppTests/Flows/NCGFlow.java @@ -0,0 +1,35 @@ +package Tests.MobileAppTests.Flows; + + +import Tests.MobileAppTests.Objects.BasePageObjects; +import Tests.MobileAppTests.Objects.LoginPageObjects; +import Tests.MobileAppTests.Utils.BaseDriver; +import Tests.MobileAppTests.Utils.IRunner; +import Tests.MobileAppTests.Utils.WaitUtils; +import io.appium.java_client.AppiumDriver; + +public class NCGFlow extends WaitUtils implements IRunner { + + public NCGFlow(AppiumDriver driver) { + super(driver); + System.out.println("In NCG flow"); + } + + @Override + public void moveSplashScreens(BasePageObjects basePageObjects) { + if (isElementPresent(basePageObjects.nextButton)) { + refreshAndwaitForElementToBeVisible(basePageObjects.nextButton).click(); + refreshAndwaitForElementToBeVisible(basePageObjects.nextButton).click(); + refreshAndwaitForElementToBeVisible(basePageObjects.nextButton).click(); + refreshAndwaitForElementToBeVisible(basePageObjects.nextButton).click(); + } + } + + @Override + public void login(LoginPageObjects loginPageObjects, String username, String password) { + loginPageObjects.userName.sendKeys(username); + waitForElementToBeEnabled(loginPageObjects.nextButton).click(); + waitForElement(loginPageObjects.password).sendKeys(password); + loginPageObjects.loginButton.click(); + } +} diff --git a/src/test/java/Tests/MobileAppTests/Flows/NHAFlow.java b/src/test/java/Tests/MobileAppTests/Flows/NHAFlow.java new file mode 100644 index 0000000..7220a2c --- /dev/null +++ b/src/test/java/Tests/MobileAppTests/Flows/NHAFlow.java @@ -0,0 +1,37 @@ +package Tests.MobileAppTests.Flows; + +import Tests.MobileAppTests.Objects.BasePageObjects; +import Tests.MobileAppTests.Objects.LoginPageObjects; +import Tests.MobileAppTests.Utils.IRunner; +import Tests.MobileAppTests.Utils.WaitUtils; +import io.appium.java_client.AppiumDriver; + +public class NHAFlow extends WaitUtils implements IRunner { + + public NHAFlow(AppiumDriver driver) { + super(driver); + System.out.println("In NHA flow"); + } + + @Override + public void moveSplashScreens(BasePageObjects basePageObjects) { + + if (isElementPresent(basePageObjects.skipButton)) { + refreshAndwaitForElementToBeVisible(basePageObjects.skipButton).click(); + } + } + + @Override + public void login(LoginPageObjects loginPageObjects, String username, String password) { + loginPageObjects.userName.sendKeys(username); + loginPageObjects.password.sendKeys(password); + loginPageObjects.loginButton.click(); + try { + Thread.sleep(10000); + } catch (InterruptedException e) { + e.printStackTrace(); + } +// System.out.println(driver.getPageSource()); + waitForElement(loginPageObjects.allowPermission).click(); + } +} diff --git a/src/test/java/Tests/MobileAppTests/Objects/BasePageObjects.java b/src/test/java/Tests/MobileAppTests/Objects/BasePageObjects.java index add3995..89423df 100644 --- a/src/test/java/Tests/MobileAppTests/Objects/BasePageObjects.java +++ b/src/test/java/Tests/MobileAppTests/Objects/BasePageObjects.java @@ -7,4 +7,7 @@ public class BasePageObjects { @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/btn_next") public MobileElement nextButton; + + @AndroidFindBy(id = "in.ndhm.phr.debug:id/btn_skip") + public MobileElement skipButton; } diff --git a/src/test/java/Tests/MobileAppTests/Objects/HomePageObjects.java b/src/test/java/Tests/MobileAppTests/Objects/HomePageObjects.java index 2439bf7..6e8f31f 100644 --- a/src/test/java/Tests/MobileAppTests/Objects/HomePageObjects.java +++ b/src/test/java/Tests/MobileAppTests/Objects/HomePageObjects.java @@ -2,6 +2,9 @@ import io.appium.java_client.MobileElement; import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.HowToUseLocators; + +import static io.appium.java_client.pagefactory.LocatorGroupStrategy.ALL_POSSIBLE; public class HomePageObjects { @@ -9,15 +12,21 @@ public class HomePageObjects { public MobileElement addProvider; @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/tv_patient_name") public MobileElement patientName; + + @HowToUseLocators(androidAutomation = ALL_POSSIBLE) + @AndroidFindBy(id = "in.ndhm.phr.debug:id/action_consents") @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/action_consents") public MobileElement consentTab; + @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/tv_requested_date") public MobileElement requestedDate; @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/tv_requester_name") public MobileElement nameInConsent; @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/snackbar_text") public MobileElement snackBar; - @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/sp_request_filter") + @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/sp_request_filter") public MobileElement requestFilter; + + } diff --git a/src/test/java/Tests/MobileAppTests/Objects/LoginPageObjects.java b/src/test/java/Tests/MobileAppTests/Objects/LoginPageObjects.java index 3db8dd3..607aa4e 100644 --- a/src/test/java/Tests/MobileAppTests/Objects/LoginPageObjects.java +++ b/src/test/java/Tests/MobileAppTests/Objects/LoginPageObjects.java @@ -2,20 +2,41 @@ import io.appium.java_client.MobileElement; import io.appium.java_client.pagefactory.AndroidFindBy; +import io.appium.java_client.pagefactory.HowToUseLocators; + +import static io.appium.java_client.pagefactory.LocatorGroupStrategy.ALL_POSSIBLE; public class LoginPageObjects { + @HowToUseLocators(androidAutomation = ALL_POSSIBLE) + @AndroidFindBy(id = "in.ndhm.phr.debug:id/et_cm_id") @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/et_cm_id") public MobileElement userName; + + @HowToUseLocators(androidAutomation = ALL_POSSIBLE) @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/btn_next") public MobileElement nextButton; + + @HowToUseLocators(androidAutomation = ALL_POSSIBLE) + @AndroidFindBy(id = "in.ndhm.phr.debug:id/et_password") @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/et_password") public MobileElement password; + + @HowToUseLocators(androidAutomation = ALL_POSSIBLE) + @AndroidFindBy(id = "in.ndhm.phr.debug:id/btn_next") @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/btn_login") public MobileElement loginButton; + + @HowToUseLocators(androidAutomation = ALL_POSSIBLE) + @AndroidFindBy(id = "in.ndhm.phr.debug:id/btn_register") @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/btn_register") public MobileElement registerButton; + @AndroidFindBy(id = "in.projecteka.jataayu.debug:id/text_input_end_icon") public MobileElement showPasswordButton; + + @AndroidFindBy(id = "com.android.permissioncontroller:id/permission_allow_button") + public MobileElement allowPermission; + } diff --git a/src/test/java/Tests/MobileAppTests/Pages/BasePage.java b/src/test/java/Tests/MobileAppTests/Pages/BasePage.java index 8a4a96f..a7ff4c1 100644 --- a/src/test/java/Tests/MobileAppTests/Pages/BasePage.java +++ b/src/test/java/Tests/MobileAppTests/Pages/BasePage.java @@ -6,24 +6,18 @@ import io.appium.java_client.pagefactory.AppiumFieldDecorator; import org.openqa.selenium.support.PageFactory; -public class BasePage { +public class BasePage extends WaitUtils { BasePageObjects basePageObjects; - AppiumDriver driver; public BasePage(AppiumDriver driver) { - this.driver = driver; + super(driver); basePageObjects = new BasePageObjects(); PageFactory.initElements(new AppiumFieldDecorator(driver), basePageObjects); } public LoginPage moveSplashScreens() { - if (new WaitUtils().isElementPresent(driver, basePageObjects.nextButton)) { - new WaitUtils().refreshAndwaitForElementToBeVisible(driver, basePageObjects.nextButton).click(); - new WaitUtils().refreshAndwaitForElementToBeVisible(driver, basePageObjects.nextButton).click(); - new WaitUtils().refreshAndwaitForElementToBeVisible(driver, basePageObjects.nextButton).click(); - new WaitUtils().refreshAndwaitForElementToBeVisible(driver, basePageObjects.nextButton).click(); - } + runner.moveSplashScreens(basePageObjects); return new LoginPage(driver); } } diff --git a/src/test/java/Tests/MobileAppTests/Pages/ConsentArtifactPage.java b/src/test/java/Tests/MobileAppTests/Pages/ConsentArtifactPage.java index 4d110a2..9dd9184 100644 --- a/src/test/java/Tests/MobileAppTests/Pages/ConsentArtifactPage.java +++ b/src/test/java/Tests/MobileAppTests/Pages/ConsentArtifactPage.java @@ -9,13 +9,12 @@ public class ConsentArtifactPage extends WaitUtils { ConsentArtifactPageObjects consentArtifactPageObjects; - AppiumDriver driver; public ConsentArtifactPage(AppiumDriver driver) { - this.driver = driver; + super(driver); consentArtifactPageObjects = new ConsentArtifactPageObjects(); PageFactory.initElements(new AppiumFieldDecorator(driver), consentArtifactPageObjects); - new WaitUtils().waitForElement(driver, consentArtifactPageObjects.grantButton); + waitForElement(consentArtifactPageObjects.grantButton); } public OTPPage grantConsent() { diff --git a/src/test/java/Tests/MobileAppTests/Pages/HomePage.java b/src/test/java/Tests/MobileAppTests/Pages/HomePage.java index 78e6c52..6ff3083 100644 --- a/src/test/java/Tests/MobileAppTests/Pages/HomePage.java +++ b/src/test/java/Tests/MobileAppTests/Pages/HomePage.java @@ -9,26 +9,25 @@ public class HomePage extends WaitUtils { HomePageObjects homePageObjects; - AppiumDriver driver; public HomePage(AppiumDriver driver) { - this.driver = driver; + super(driver); homePageObjects = new HomePageObjects(); PageFactory.initElements(new AppiumFieldDecorator(driver), homePageObjects); } public SearchLinkProviderPage clickAddNewProvider() { - new WaitUtils().waitForElement(driver, homePageObjects.addProvider).click(); + waitForElement(homePageObjects.addProvider).click(); return new SearchLinkProviderPage(driver); } public String getPatientName() { - return new WaitUtils().refreshAndwaitForElementToBeVisible(driver, homePageObjects.patientName).getText(); + return refreshAndwaitForElementToBeVisible(homePageObjects.patientName).getText(); } public HomePage navigateToConsentsTab() { - new WaitUtils().waitForElement(driver, homePageObjects.consentTab).click(); - new WaitUtils().waitForTextToAppear(driver, homePageObjects.requestedDate); + waitForElement(homePageObjects.consentTab).click(); + waitForTextToAppear(homePageObjects.requestedDate); return this; } @@ -38,10 +37,14 @@ public ConsentArtifactPage clickConsent() { } public String getSnackBarText() { - return new WaitUtils().waitForTextToAppear(driver, homePageObjects.snackBar).getText(); + return waitForTextToAppear(homePageObjects.snackBar).getText(); } public boolean isRequestedDateDisplayed() { - return new WaitUtils().isElementPresent(driver, homePageObjects.requestedDate); + return isElementPresent(homePageObjects.requestedDate); + } + + public boolean validateHomePage() { + return isElementPresent(homePageObjects.consentTab); } } diff --git a/src/test/java/Tests/MobileAppTests/Pages/LinkAccountsPage.java b/src/test/java/Tests/MobileAppTests/Pages/LinkAccountsPage.java index 0c2e5c5..ff37759 100644 --- a/src/test/java/Tests/MobileAppTests/Pages/LinkAccountsPage.java +++ b/src/test/java/Tests/MobileAppTests/Pages/LinkAccountsPage.java @@ -6,16 +6,15 @@ import io.appium.java_client.pagefactory.AppiumFieldDecorator; import org.openqa.selenium.support.PageFactory; -public class LinkAccountsPage { +public class LinkAccountsPage extends WaitUtils { LinkAccountsPageObjects linkAccountsPageObjects; - AppiumDriver driver; public LinkAccountsPage(AppiumDriver driver) { - this.driver = driver; + super(driver); linkAccountsPageObjects = new LinkAccountsPageObjects(); PageFactory.initElements(new AppiumFieldDecorator(driver), linkAccountsPageObjects); - new WaitUtils().waitForElement(driver, linkAccountsPageObjects.patientName); + waitForElement(linkAccountsPageObjects.patientName); } public String getPatientName() { @@ -23,7 +22,7 @@ public String getPatientName() { } public OTPPage linkCareContext() { - linkAccountsPageObjects.linkSelected.click(); - return new OTPPage(driver); + linkAccountsPageObjects.linkSelected.click(); + return new OTPPage(driver); } } diff --git a/src/test/java/Tests/MobileAppTests/Pages/LoginPage.java b/src/test/java/Tests/MobileAppTests/Pages/LoginPage.java index 5a0b321..782d09b 100644 --- a/src/test/java/Tests/MobileAppTests/Pages/LoginPage.java +++ b/src/test/java/Tests/MobileAppTests/Pages/LoginPage.java @@ -7,43 +7,26 @@ import io.appium.java_client.pagefactory.AppiumFieldDecorator; import org.openqa.selenium.support.PageFactory; -public class LoginPage { - - +public class LoginPage extends WaitUtils { LoginPageObjects loginPageObjects; - AppiumDriver driver; public LoginPage(AppiumDriver driver) { - this.driver = driver; + super(driver); loginPageObjects = new LoginPageObjects(); PageFactory.initElements(new AppiumFieldDecorator(driver), loginPageObjects); - new WaitUtils().waitForElement(driver, loginPageObjects.userName); + waitForElement(loginPageObjects.userName); } public HomePage loginUser() { String userName = PropertiesCache.getInstance().getProperty("mobileUser"); String password = PropertiesCache.getInstance().getProperty("mobilePassword"); - - loginPageObjects.userName.sendKeys(userName); - new WaitUtils().waitForElementToBeEnabled(driver, loginPageObjects.nextButton).click(); - new WaitUtils().waitForElement(driver, loginPageObjects.password).sendKeys(password); - - //TODO - To enable the login button. Temp fix to pass test - loginPageObjects.showPasswordButton.click(); - loginPageObjects.loginButton.click(); - + runner.login(loginPageObjects, userName, password); return new HomePage(driver); } public HomePage loginUser(String username, String password) { - loginPageObjects.userName.sendKeys(username); - new WaitUtils().waitForElementToBeEnabled(driver, loginPageObjects.nextButton).click(); - - new WaitUtils().waitForElement(driver, loginPageObjects.password).sendKeys(password); - loginPageObjects.loginButton.click(); - + runner.login(loginPageObjects, username, password); return new HomePage(driver); - } public RegistrationPage navigateToCreateAccount() { diff --git a/src/test/java/Tests/MobileAppTests/Pages/OTPPage.java b/src/test/java/Tests/MobileAppTests/Pages/OTPPage.java index 224c50b..71515c4 100644 --- a/src/test/java/Tests/MobileAppTests/Pages/OTPPage.java +++ b/src/test/java/Tests/MobileAppTests/Pages/OTPPage.java @@ -6,27 +6,25 @@ import io.appium.java_client.pagefactory.AppiumFieldDecorator; import org.openqa.selenium.support.PageFactory; -public class OTPPage { - +public class OTPPage extends WaitUtils { OTPPageObjects otpPageObjects; - AppiumDriver driver; public OTPPage(AppiumDriver driver) { - this.driver = driver; + super(driver); otpPageObjects = new OTPPageObjects(); PageFactory.initElements(new AppiumFieldDecorator(driver), otpPageObjects); - new WaitUtils().refreshAndwaitForElementToBeVisible(driver, otpPageObjects.continueButton); + refreshAndwaitForElementToBeVisible(otpPageObjects.continueButton); } public T enterOTP(T nextPage) { - new WaitUtils().waitForElement(driver, otpPageObjects.otpField).sendKeys("666666"); + waitForElement(otpPageObjects.otpField).sendKeys("666666"); otpPageObjects.continueButton.click(); return nextPage; } public T enterPin(T nextPage, String text) { - new WaitUtils().waitForSpecificTextToBeDisplayed(driver, otpPageObjects.consentPinLabel, text); + waitForSpecificTextToBeDisplayed(otpPageObjects.consentPinLabel, text); otpPageObjects.consentPin.sendKeys("1234"); otpPageObjects.continueButton.click(); return nextPage; diff --git a/src/test/java/Tests/MobileAppTests/Pages/RegistrationPage.java b/src/test/java/Tests/MobileAppTests/Pages/RegistrationPage.java index 5a97b04..9f11c9e 100644 --- a/src/test/java/Tests/MobileAppTests/Pages/RegistrationPage.java +++ b/src/test/java/Tests/MobileAppTests/Pages/RegistrationPage.java @@ -7,25 +7,25 @@ import io.appium.java_client.pagefactory.AppiumFieldDecorator; import org.openqa.selenium.support.PageFactory; -public class RegistrationPage { +public class RegistrationPage extends WaitUtils { RegistrationPageObjects registrationPageObjects; - AppiumDriver driver; public RegistrationPage(AppiumDriver driver) { + super(driver); this.driver = driver; registrationPageObjects = new RegistrationPageObjects(); PageFactory.initElements(new AppiumFieldDecorator(driver), registrationPageObjects); - new WaitUtils().refreshAndwaitForElementToBeVisible(driver, registrationPageObjects.continueButton); + refreshAndwaitForElementToBeVisible(registrationPageObjects.continueButton); } public OTPPage enterContactNoAndContinue(String phoneNumber) { registrationPageObjects.mobileNo.sendKeys(phoneNumber); - new WaitUtils().waitForElement(driver, registrationPageObjects.continueButton).click(); + waitForElement(registrationPageObjects.continueButton).click(); return new OTPPage(driver); } public HomePage enterUserDetails(Patient patient, String username) { - new WaitUtils().waitForElementToBeVisible(driver, registrationPageObjects.patientName).sendKeys(patient.getPatientName()); + waitForElementToBeVisible(registrationPageObjects.patientName).sendKeys(patient.getPatientName()); if (patient.getGender().equals("male")) { registrationPageObjects.genderMale.click(); } else if (patient.getGender().equals("female")) { @@ -33,12 +33,12 @@ public HomePage enterUserDetails(Patient patient, String username) { } registrationPageObjects.registerButton.click(); - new WaitUtils().waitForElementToBeVisible(driver, registrationPageObjects.password).sendKeys("Test@135"); + waitForElementToBeVisible(registrationPageObjects.password).sendKeys("Test@135"); registrationPageObjects.cmID.clear(); registrationPageObjects.cmID.sendKeys(username); registrationPageObjects.confirmPassword.sendKeys("Test@135"); registrationPageObjects.confirmRegisterButton.click(); - new WaitUtils().waitForElementToBeVisible(driver, registrationPageObjects.confirmationMessage); + waitForElementToBeVisible(registrationPageObjects.confirmationMessage); registrationPageObjects.confirmRegisterButton.click(); return new HomePage(driver); } diff --git a/src/test/java/Tests/MobileAppTests/Pages/SearchLinkProviderPage.java b/src/test/java/Tests/MobileAppTests/Pages/SearchLinkProviderPage.java index 24abc55..ebe335e 100644 --- a/src/test/java/Tests/MobileAppTests/Pages/SearchLinkProviderPage.java +++ b/src/test/java/Tests/MobileAppTests/Pages/SearchLinkProviderPage.java @@ -9,23 +9,22 @@ public class SearchLinkProviderPage extends WaitUtils { SearchLinkProviderObjects searchLinkProviderObjects; - AppiumDriver driver; public SearchLinkProviderPage(AppiumDriver driver) { - this.driver = driver; + super(driver); searchLinkProviderObjects = new SearchLinkProviderObjects(); PageFactory.initElements(new AppiumFieldDecorator(driver), searchLinkProviderObjects); - new WaitUtils().waitForElement(driver, searchLinkProviderObjects.providerInput); + waitForElement(searchLinkProviderObjects.providerInput); } public SearchLinkProviderPage searchAndSelectProvider(String providerName) { searchLinkProviderObjects.providerInput.sendKeys(providerName); - waitForElement(driver,searchLinkProviderObjects.providerName).click(); + waitForElement(searchLinkProviderObjects.providerName).click(); return this; } public LinkAccountsPage clickConfirmProvider() { - waitForElementToBeVisible(driver, searchLinkProviderObjects.confirmProvider).click(); + waitForElementToBeVisible(searchLinkProviderObjects.confirmProvider).click(); return new LinkAccountsPage(driver); } } diff --git a/src/test/java/Tests/MobileAppTests/Tests/LoginTest.java b/src/test/java/Tests/MobileAppTests/Tests/LoginTest.java index f934365..1e3101e 100644 --- a/src/test/java/Tests/MobileAppTests/Tests/LoginTest.java +++ b/src/test/java/Tests/MobileAppTests/Tests/LoginTest.java @@ -3,6 +3,7 @@ import Tests.APITests.APIUtils.PropertiesCache; import Tests.MobileAppTests.Pages.LoginPage; import Tests.MobileAppTests.Utils.BaseDriver; +import org.testng.Assert; import org.testng.annotations.Test; public class LoginTest extends BaseDriver { @@ -12,6 +13,8 @@ public class LoginTest extends BaseDriver { @Test public void loginUser() { - new LoginPage(driver).loginUser(userName, password); + + boolean status = new LoginPage(driver).loginUser(userName, password).validateHomePage(); + Assert.assertTrue(status); } } diff --git a/src/test/java/Tests/MobileAppTests/Tests/RegistrationTest.java b/src/test/java/Tests/MobileAppTests/Tests/RegistrationTest.java index 4889f33..23fd2a7 100644 --- a/src/test/java/Tests/MobileAppTests/Tests/RegistrationTest.java +++ b/src/test/java/Tests/MobileAppTests/Tests/RegistrationTest.java @@ -19,7 +19,8 @@ public void registerLinkCareContext() { Patient patient = new Patient("Hina Patel", "8888888888", "female"); HomePage homePage = new LoginPage(driver).navigateToCreateAccount().enterContactNoAndContinue(patient.getMobile()) .enterOTP(new RegistrationPage(driver)).enterUserDetails(patient, userName).clickAddNewProvider() - .searchAndSelectProvider("Max").clickConfirmProvider().linkCareContext().enterOTP(new HomePage(driver)); + .searchAndSelectProvider("Max").clickConfirmProvider().linkCareContext() + .enterOTP(new HomePage(driver)); Assert.assertTrue(homePage.getPatientName().length() > 0, "Patient Name not displayed on Link Provider screen"); } diff --git a/src/test/java/Tests/MobileAppTests/Utils/AppUtility.java b/src/test/java/Tests/MobileAppTests/Utils/AppUtility.java index a244e12..59c0d6d 100644 --- a/src/test/java/Tests/MobileAppTests/Utils/AppUtility.java +++ b/src/test/java/Tests/MobileAppTests/Utils/AppUtility.java @@ -1,11 +1,13 @@ package Tests.MobileAppTests.Utils; +import Tests.APITests.APIUtils.PropertiesCache; import io.restassured.RestAssured; import io.restassured.config.RedirectConfig; import io.restassured.config.RestAssuredConfig; import io.restassured.path.json.JsonPath; import io.restassured.response.Response; import io.restassured.specification.RequestSpecification; +import net.minidev.json.JSONArray; import java.io.File; import java.io.IOException; @@ -31,7 +33,6 @@ public static AppUtility getInstance() { if (instance == null) instance = new AppUtility(); - return instance; } @@ -45,23 +46,21 @@ private String getArtifactURL() { RequestSpecification request = RestAssured.given(); + String repoURL = PropertiesCache.getInstance().getProperty("repoURL"); //Auth Headers added to avoid the rate limiting - Response response = request.header("Authorization", System.getenv("Authorization")) - .get("/repos/ProjectEKA/Jataayu/actions/workflows/android.yml/runs?branch=master&status=completed");//NCG yml file + Response response = request.header("Authorization", "token " + System.getenv("Authorization")) + .get(repoURL);//NCG yml file JsonPath jsonPathEvaluator = response.jsonPath(); String run_id = jsonPathEvaluator.getString("workflow_runs[0].id"); System.out.println("Getting artifacts for the run id - " + run_id); - RequestSpecification request1 = RestAssured.given(); - response = request1.header("Authorization", System.getenv("Authorization")).get(String.format("/repos/ProjectEKA/Jataayu/actions/runs/%s/artifacts", run_id)); - jsonPathEvaluator = response.jsonPath(); - String artifactURL = jsonPathEvaluator.getString("artifacts[0].archive_download_url"); + String artifactURL = getArtifactURL(run_id); RequestSpecification requestSpecification = RestAssured.given(); - requestSpecification.header("Authorization", "Bearer "+System.getenv("Authorization")); + requestSpecification.header("Authorization", "token " + System.getenv("Authorization")); requestSpecification.config(new RestAssuredConfig().redirect(new RedirectConfig().followRedirects(false))); response = requestSpecification.get(artifactURL); @@ -71,6 +70,20 @@ private String getArtifactURL() { return response.getHeader("Location"); } + private String getArtifactURL(String run_id) { + Response response; + JsonPath jsonPathEvaluator; + RequestSpecification request1 = RestAssured.given(); + response = request1.header("Authorization", "token " + System.getenv("Authorization")).get(String.format(PropertiesCache.getInstance().getProperty("artifactURL") +"actions/runs/%s/artifacts", run_id)); + jsonPathEvaluator = response.jsonPath(); + if (System.getenv("env").equals("ncg")) + return jsonPathEvaluator.getString("artifacts[0].archive_download_url"); + else { + JSONArray artifact = com.jayway.jsonpath.JsonPath.read(response.getBody().asString(), "$.artifacts[?(@.name=~ /^.*" + System.getenv("env") + ".*$/)].archive_download_url"); + return artifact.get(0).toString(); + } + } + public String getPath() { return path; } diff --git a/src/test/java/Tests/MobileAppTests/Utils/BaseDriver.java b/src/test/java/Tests/MobileAppTests/Utils/BaseDriver.java index 3890535..db7b83a 100644 --- a/src/test/java/Tests/MobileAppTests/Utils/BaseDriver.java +++ b/src/test/java/Tests/MobileAppTests/Utils/BaseDriver.java @@ -1,6 +1,7 @@ package Tests.MobileAppTests.Utils; +import Tests.APITests.APIUtils.PropertiesCache; import Tests.MobileAppTests.Pages.BasePage; import io.appium.java_client.AppiumDriver; import io.appium.java_client.android.AndroidDriver; @@ -8,6 +9,8 @@ import io.appium.java_client.remote.MobileCapabilityType; import io.appium.java_client.service.local.AppiumDriverLocalService; import io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException; +import io.appium.java_client.service.local.AppiumServiceBuilder; +import org.apache.commons.io.filefilter.WildcardFileFilter; import org.openqa.selenium.WebElement; import org.openqa.selenium.remote.DesiredCapabilities; import org.testng.annotations.AfterClass; @@ -16,6 +19,7 @@ import org.testng.annotations.BeforeMethod; import java.io.File; +import java.io.FileFilter; public class BaseDriver { private static String path = null; @@ -24,13 +28,15 @@ public class BaseDriver { @BeforeClass public void setUp() { -// service = AppiumDriverLocalService.buildService(new AppiumServiceBuilder() +// service = AppiumDriverLocalService.buildService( +// new AppiumServiceBuilder() // .usingAnyFreePort() // .usingDriverExecutable(new File( -// "/usr/local/bin/node")) -// .withAppiumJS(new File("/usr/local/bin/appium"))); +// "/Users/shridhk/.nvm/versions/node/v12.4.0/bin/node")).withAppiumJS( +// +// new File("/usr/local/bin/appium"))); - service = AppiumDriverLocalService.buildDefaultService(); + service =AppiumDriverLocalService.buildDefaultService(); service.start(); @@ -43,21 +49,27 @@ public void setUp() { @BeforeMethod public void beforeMethod() { - - File app = new File(path + "/app-ncg-debug.apk");//NCG APK + File dir = new File(path); + FileFilter fileFilter = new WildcardFileFilter("*.apk"); + File[] files = dir.listFiles(fileFilter); + File app = new File(String.valueOf(files[0])); DesiredCapabilities capabilities = new DesiredCapabilities(); capabilities.setCapability("deviceName", "Android Emulator"); capabilities.setCapability("app", app.getAbsolutePath()); capabilities.setCapability("automationName", "UIAutomator2"); capabilities.setCapability(MobileCapabilityType.NEW_COMMAND_TIMEOUT, 700000); - capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "in.projecteka.jataayu.LauncherActivity"); - capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "in.projecteka.jataayu.debug"); + + capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, PropertiesCache.getInstance().getProperty("APP_ACTIVITY")); + capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, PropertiesCache.getInstance().getProperty("APP_PACKAGE")); + driver = new AndroidDriver<>(service.getUrl(), capabilities); + + new RunnerFactory().instantiateRunner(driver); handleSplashScreen(); } private void handleSplashScreen() { - new BasePage(this.driver).moveSplashScreens(); + new BasePage(driver).moveSplashScreens(); } @AfterMethod diff --git a/src/test/java/Tests/MobileAppTests/Utils/IRunner.java b/src/test/java/Tests/MobileAppTests/Utils/IRunner.java new file mode 100644 index 0000000..b0e38de --- /dev/null +++ b/src/test/java/Tests/MobileAppTests/Utils/IRunner.java @@ -0,0 +1,9 @@ +package Tests.MobileAppTests.Utils; + +import Tests.MobileAppTests.Objects.BasePageObjects; +import Tests.MobileAppTests.Objects.LoginPageObjects; + +public interface IRunner { + void moveSplashScreens(BasePageObjects basePageObjects); + void login(LoginPageObjects loginPageObjects, String username, String password); +} diff --git a/src/test/java/Tests/MobileAppTests/Utils/RunnerFactory.java b/src/test/java/Tests/MobileAppTests/Utils/RunnerFactory.java new file mode 100644 index 0000000..cdeb491 --- /dev/null +++ b/src/test/java/Tests/MobileAppTests/Utils/RunnerFactory.java @@ -0,0 +1,23 @@ +package Tests.MobileAppTests.Utils; + +import Tests.MobileAppTests.Flows.NCGFlow; +import Tests.MobileAppTests.Flows.NHAFlow; +import io.appium.java_client.AppiumDriver; + +public class RunnerFactory { + public static IRunner runner; + + public void instantiateRunner(AppiumDriver driver) { + String env = System.getenv("env"); + switch (env) { + case "ncg": + runner = new NCGFlow(driver); + break; + case "nhsDev": + runner = new NHAFlow(driver); + break; + default: + runner = new NHAFlow(driver); + } + } +} diff --git a/src/test/java/Tests/MobileAppTests/Utils/WaitUtils.java b/src/test/java/Tests/MobileAppTests/Utils/WaitUtils.java index 944dbe1..6f47cc6 100644 --- a/src/test/java/Tests/MobileAppTests/Utils/WaitUtils.java +++ b/src/test/java/Tests/MobileAppTests/Utils/WaitUtils.java @@ -9,49 +9,51 @@ public class WaitUtils { public WebDriverWait wait; - - public MobileElement waitForElement(AppiumDriver driver, MobileElement id) { + public AppiumDriver driver; + public IRunner runner; + + public WaitUtils(AppiumDriver driver) { + this.runner = RunnerFactory.runner; + this.driver = driver; wait = new WebDriverWait(driver, 30); + } + + public MobileElement waitForElement(MobileElement id) { wait.until(ExpectedConditions .elementToBeClickable(id)); return id; } - public MobileElement waitForElementToBeVisible(AppiumDriver driver, MobileElement id) { - wait = new WebDriverWait(driver, 30); + public MobileElement waitForElementToBeVisible(MobileElement id) { wait.until(ExpectedConditions.visibilityOf(id)); return id; } - public MobileElement refreshAndwaitForElementToBeVisible(AppiumDriver driver, MobileElement id) { - wait = new WebDriverWait(driver, 30); + + public MobileElement refreshAndwaitForElementToBeVisible(MobileElement id) { wait.until(ExpectedConditions.refreshed(ExpectedConditions.visibilityOf(id))); return id; } - public MobileElement waitForTextToAppear(AppiumDriver driver, MobileElement id) { - wait = new WebDriverWait(driver, 30); + public MobileElement waitForTextToAppear(MobileElement id) { wait.until((ExpectedCondition) d -> id.getText().length() != 0); return id; } - public MobileElement waitForSpecificTextToBeDisplayed(AppiumDriver driver, MobileElement id, String text) { - wait = new WebDriverWait(driver, 30); + public MobileElement waitForSpecificTextToBeDisplayed(MobileElement id, String text) { wait.until(ExpectedConditions.refreshed((ExpectedCondition) d -> id.getText().contains(text))); return id; } - public MobileElement waitForElementToBeEnabled(AppiumDriver driver, MobileElement id) { - wait = new WebDriverWait(driver, 30); + public MobileElement waitForElementToBeEnabled(MobileElement id) { wait.until(ExpectedConditions.elementToBeClickable(id)); return id; } - public boolean isElementPresent(AppiumDriver driver, MobileElement id) { + public boolean isElementPresent(MobileElement id) { try { - wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOf(id)); return true; - } catch (NoSuchElementException e) { + } catch (Exception e) { return false; } diff --git a/src/test/resources/config-nhs-dev.properties b/src/test/resources/config-nhs-dev.properties new file mode 100644 index 0000000..4338f9a --- /dev/null +++ b/src/test/resources/config-nhs-dev.properties @@ -0,0 +1,8 @@ +repoURL=/repos/I-NHA/Jan-Aarogya-Setu-Android/actions/runs?branch=master&status=completed +artifactURL=/repos/I-NHA/Jan-Aarogya-Setu-Android/ +APP_ACTIVITY=in.ndhm.phr.LauncherActivity +APP_PACKAGE=in.ndhm.phr.debug + +#Props for Mobile Tests +mobileUser=navjotauto +mobilePassword=Test@135 \ No newline at end of file diff --git a/src/test/resources/config-nhs-sandbox.properties b/src/test/resources/config-nhs-sandbox.properties new file mode 100644 index 0000000..4338f9a --- /dev/null +++ b/src/test/resources/config-nhs-sandbox.properties @@ -0,0 +1,8 @@ +repoURL=/repos/I-NHA/Jan-Aarogya-Setu-Android/actions/runs?branch=master&status=completed +artifactURL=/repos/I-NHA/Jan-Aarogya-Setu-Android/ +APP_ACTIVITY=in.ndhm.phr.LauncherActivity +APP_PACKAGE=in.ndhm.phr.debug + +#Props for Mobile Tests +mobileUser=navjotauto +mobilePassword=Test@135 \ No newline at end of file diff --git a/src/test/resources/config-nhs-uat.properties b/src/test/resources/config-nhs-uat.properties new file mode 100644 index 0000000..4338f9a --- /dev/null +++ b/src/test/resources/config-nhs-uat.properties @@ -0,0 +1,8 @@ +repoURL=/repos/I-NHA/Jan-Aarogya-Setu-Android/actions/runs?branch=master&status=completed +artifactURL=/repos/I-NHA/Jan-Aarogya-Setu-Android/ +APP_ACTIVITY=in.ndhm.phr.LauncherActivity +APP_PACKAGE=in.ndhm.phr.debug + +#Props for Mobile Tests +mobileUser=navjotauto +mobilePassword=Test@135 \ No newline at end of file diff --git a/src/test/resources/config.properties b/src/test/resources/config.properties index 45a4e1c..399becb 100644 --- a/src/test/resources/config.properties +++ b/src/test/resources/config.properties @@ -1,3 +1,7 @@ +repoURL=/repos/ProjectEKA/Jataayu/actions/workflows/android.yml/runs?branch=master&status=completed +artifactURL=/repos/ProjectEKA/Jataayu/ +APP_ACTIVITY=in.projecteka.jataayu.LauncherActivity +APP_PACKAGE=in.projecteka.jataayu.debug #URLs consentManagerURL=https://ncg-dev.projecteka.in/consent-manager centralRegistryURL= https://ncg-dev.projecteka.in/central-registry