Skip to content

Commit

Permalink
Added new sample tests and some code cleanup (znsio#146)
Browse files Browse the repository at this point in the history
* added new method in Driver

* removed duplicate method in Driver

* added web implementation for Indigo gift voucher

* added sample for Indigo and Dineout

* deleted sample apks from repo and instead pointed to a url for auto download at runtime

* started adding confengine scenario for android

* made logging changes

* updated github action versions

* refresh dependencies during ci build

* more changes in github actions

* run github actions on newSamples

* changed ATD version
  • Loading branch information
anandbagmar authored Jan 28, 2023
1 parent ac97906 commit 26fdc61
Show file tree
Hide file tree
Showing 69 changed files with 1,521 additions and 82 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ updates:
- package-ecosystem: "github-actions" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
interval: "daily"
6 changes: 3 additions & 3 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ name: Java CI with Gradle

on:
push:
branches: [ main ]
branches: [ main, newSamples ]
pull_request:
branches: [ main ]
branches: [ main, newSamples ]

jobs:
build:
Expand All @@ -28,4 +28,4 @@ jobs:
- name: Build with Gradle
uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef
with:
arguments: build
arguments: build --refresh-dependencies
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
ext {
gradleVersion = '7.3.3'
assertJVersion = '3.24.2'
atdVersion = 'dbef9bed7d'
atdVersion = 'dbef9be'
applitoolsSeleniumVersion = '3.213.0'
applitoolsAppiumVersion = '3.213.0'
commonsLang3Version = '3.12.0'
Expand Down
2 changes: 1 addition & 1 deletion caps/calculator2_local_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"android": {
"adbExecTimeout": 45000,
"app": {
"local": "./src/test/resources/sampleApps/AndroidCalculator.apk"
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/AndroidCalculator.apk"
},
"appPackage": "com.android2.calculator3",
"appActivity": "com.android2.calculator3.Calculator",
Expand Down
2 changes: 1 addition & 1 deletion caps/calculator_local_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"android": {
"adbExecTimeout": 45000,
"app": {
"local": "./src/test/resources/sampleApps/AndroidCalculator.apk"
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/AndroidCalculator.apk"
},
"appPackage": "com.android2.calculator3",
"appActivity": "com.android2.calculator3.Calculator",
Expand Down
2 changes: 1 addition & 1 deletion caps/calculator_pcloudy_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"resetKeyboard": true,
"noReset": false,
"app": {
"local": "./src/test/resources/sampleApps/AndroidCalculator.apk"
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/AndroidCalculator.apk"
}
},
"cloud": {
Expand Down
35 changes: 35 additions & 0 deletions caps/confengine_local_capabilities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"android": {
"adbExecTimeout": 45000,
"app": {
"local": "./src/test/resources/sampleApps/confEngine-devApi-debug.apk"
},
"appActivity": "com.confengine.confengine.activity.Html5Activity",
"appPackage": "com.confengine.confengine",
"appWaitDuration": 45000,
"automationName": "UiAutomator2",
"autoGrantPermissions": true,
"deviceName": "android",
"dontStopAppOnReset": true,
"enablePerformanceLogging": true,
"eventTimings": true,
"newCommandTimeout": 12000,
"noSign": true,
"platformName": "android",
"platformVersion": "11.0",
"printPageSourceOnFindFailure": true,
"skipUnlock": true,
"noReset": false
},
"hostMachines": [
{
"machineIP": "127.0.0.1",
"simulators": [
{
"deviceName": "iPhone 11",
"OS": "13.5"
}
]
}
]
}
35 changes: 35 additions & 0 deletions caps/dineout_local_capabilities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"android": {
"adbExecTimeout": 45000,
"app": {
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/dineout.book_2022-10-18.apk"
},
"appActivity": "com.dineout.book.splash.presentation.view.NewSplashActivity",
"appPackage": "com.dineout.book",
"appWaitDuration": 45000,
"automationName": "UiAutomator2",
"autoGrantPermissions": true,
"deviceName": "android",
"dontStopAppOnReset": true,
"enablePerformanceLogging": true,
"eventTimings": true,
"newCommandTimeout": 12000,
"noSign": true,
"platformName": "android",
"platformVersion": "11.0",
"printPageSourceOnFindFailure": true,
"skipUnlock": true,
"noReset": false
},
"hostMachines": [
{
"machineIP": "127.0.0.1",
"simulators": [
{
"deviceName": "iPhone 11",
"OS": "13.5"
}
]
}
]
}
35 changes: 35 additions & 0 deletions caps/indigo_local_capabilities.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"android": {
"adbExecTimeout": 45000,
"app": {
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/IndiGoFlight-App_5.0.85.apk"
},
"appActivity": "in.goindigo.android.ui.modules.splash.SplashActivity",
"appPackage": "in.goindigo.android",
"appWaitDuration": 45000,
"automationName": "UiAutomator2",
"autoGrantPermissions": true,
"deviceName": "android",
"dontStopAppOnReset": true,
"enablePerformanceLogging": true,
"eventTimings": true,
"newCommandTimeout": 12000,
"noSign": true,
"platformName": "android",
"platformVersion": "11.0",
"printPageSourceOnFindFailure": true,
"skipUnlock": true,
"noReset": false
},
"hostMachines": [
{
"machineIP": "127.0.0.1",
"simulators": [
{
"deviceName": "iPhone 11",
"OS": "13.5"
}
]
}
]
}
2 changes: 1 addition & 1 deletion caps/jiomeet_browserStack_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"android": {
"adbExecTimeout": 45000,
"app": {
"local": "./src/test/resources/sampleApps/com.jio.rilconferences_v4.21.6.7-421607_Android-5.0.apk"
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/com.jio.rilconferences_v4.21.6.7-421607_Android-5.0.apk"
},
"appActivity": "org.jio.meet.introduction.views.SplashActivity",
"appPackage": "com.jio.rilconferences",
Expand Down
2 changes: 1 addition & 1 deletion caps/jiomeet_local_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"android": {
"adbExecTimeout": 45000,
"app": {
"local": "./src/test/resources/sampleApps/com.jio.rilconferences_v4.21.6.7-421607_Android-5.0.apk"
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/com.jio.rilconferences_v4.21.6.7-421607_Android-5.0.apk"
},
"appActivity": "org.jio.meet.introduction.views.SplashActivity",
"appPackage": "com.jio.rilconferences",
Expand Down
2 changes: 1 addition & 1 deletion caps/jiomeetlatest_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"android": {
"adbExecTimeout": 45000,
"app": {
"local": "./src/test/resources/sampleApps/com.jio.rilconferences_v4.21.6.7-421607_Android-5.0.apk"
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/com.jio.rilconferences_v4.21.6.7-421607_Android-5.0.apk"
},
"appActivity": "org.jio.meet.introduction.views.SplashActivity",
"appPackage": "com.jio.rilconferences",
Expand Down
2 changes: 1 addition & 1 deletion caps/jiomeetoldversion_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"android": {
"adbExecTimeout": 45000,
"app": {
"local": "./src/test/resources/sampleApps/com.jio.rilconferences_v4.21.4.5-421405_Android-5.0.apk"
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/com.jio.rilconferences_v4.21.4.5-421405_Android-5.0.apk"
},
"appActivity": "org.jio.meet.introduction.views.SplashActivity",
"appPackage": "com.jio.rilconferences",
Expand Down
2 changes: 1 addition & 1 deletion caps/theapp_browserStack_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"browserstack.locale": "IN",
"project": "teswiz",
"app": {
"local": "./src/test/resources/sampleApps/TheApp-release.apk"
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/TheApp-release.apk"
}
},
"cloud": {
Expand Down
2 changes: 1 addition & 1 deletion caps/theapp_headspin_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"noReset": true,
"autoAcceptAlerts": true,
"app": {
"local": "./src/test/resources/sampleApps/TheApp-release.apk"
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/TheApp-release.apk"
}
},
"cloud": {
Expand Down
2 changes: 1 addition & 1 deletion caps/theapp_local_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"enablePerformanceLogging": true,
"printPageSourceOnFindFailure": true,
"app": {
"local": "./src/test/resources/sampleApps/TheApp-release.apk"
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/TheApp-release.apk"
},
"deviceName": "android",
"noSign": true
Expand Down
2 changes: 1 addition & 1 deletion caps/theapp_pcloudy_capabilities.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"resetKeyboard": true,
"noReset": false,
"app": {
"local": "./src/test/resources/sampleApps/TheApp-release.apk"
"local": "https://github.com/anandbagmar/sampleAppsForNativeMobileAutomation/raw/main/TheApp-release.apk"
}
},
"cloud": {
Expand Down
23 changes: 23 additions & 0 deletions configs/confengine_local_config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
RUNNER=distribute
FRAMEWORK=cucumber
RUNNER_LEVEL=methods
CAPS=./caps/confengine_local_capabilities.json
APP_NAME=ConfEngine
APP_PACKAGE_NAME=com.confengine.confengine
APPLITOOLS_CONFIGURATION=./configs/applitools_config.json
BASE_URL_FOR_WEB=CONFENGINE_BASE_URL
BROWSER=chrome
ENVIRONMENT_CONFIG_FILE=./src/test/resources/environments.json
IS_VISUAL=false
LOG_DIR=target
LOG_PROPERTIES_FILE=./src/test/resources/log4j.properties
PARALLEL=1
PLATFORM=android
PROXY_KEY=HTTP_PROXY
REPORT_PORTAL_FILE=src/test/resources/reportportal.properties
RUN_IN_CI=false
TARGET_ENVIRONMENT=dev
LAUNCH_NAME_SUFFIX= on 'dev' Environment
TEST_DATA_FILE=./src/test/resources/testData.json
CLEANUP_DEVICE_BEFORE_STARTING_EXECUTION=false
BROWSER_CONFIG_FILE=./configs/browser_config.json
23 changes: 23 additions & 0 deletions configs/dineout_local_config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
RUNNER=distribute
FRAMEWORK=cucumber
RUNNER_LEVEL=methods
CAPS=./caps/dineout_local_capabilities.json
APP_NAME=Dineout
APP_PACKAGE_NAME=indigo_local_config.properties
APPLITOOLS_CONFIGURATION=./configs/applitools_config.json
BASE_URL_FOR_WEB=DINEOUT_BASE_URL
BROWSER=chrome
ENVIRONMENT_CONFIG_FILE=./src/test/resources/environments.json
IS_VISUAL=false
LOG_DIR=target
LOG_PROPERTIES_FILE=./src/test/resources/log4j.properties
PARALLEL=1
PLATFORM=android
PROXY_KEY=HTTP_PROXY
REPORT_PORTAL_FILE=src/test/resources/reportportal.properties
RUN_IN_CI=false
TARGET_ENVIRONMENT=prod
LAUNCH_NAME_SUFFIX= on 'prod' Environment
TEST_DATA_FILE=./src/test/resources/testData.json
CLEANUP_DEVICE_BEFORE_STARTING_EXECUTION=false
BROWSER_CONFIG_FILE=./configs/browser_config.json
23 changes: 23 additions & 0 deletions configs/indigo_local_config.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
RUNNER=distribute
FRAMEWORK=cucumber
RUNNER_LEVEL=methods
CAPS=./caps/indigo_local_capabilities.json
APP_NAME=Indigo
APP_PACKAGE_NAME=in.goindigo.android
APPLITOOLS_CONFIGURATION=./configs/applitools_config.json
BASE_URL_FOR_WEB=INDIGO_BASE_URL
BROWSER=chrome
ENVIRONMENT_CONFIG_FILE=./src/test/resources/environments.json
IS_VISUAL=false
LOG_DIR=target
LOG_PROPERTIES_FILE=./src/test/resources/log4j.properties
PARALLEL=1
PLATFORM=android
PROXY_KEY=HTTP_PROXY
REPORT_PORTAL_FILE=src/test/resources/reportportal.properties
RUN_IN_CI=false
TARGET_ENVIRONMENT=prod
LAUNCH_NAME_SUFFIX= on 'prod' Environment
TEST_DATA_FILE=./src/test/resources/testData.json
CLEANUP_DEVICE_BEFORE_STARTING_EXECUTION=false
BROWSER_CONFIG_FILE=./configs/browser_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class CucumberWebScenarioListener
private final Map<String, Integer> scenarioRunCounts = new HashMap<>();

public CucumberWebScenarioListener() {
LOGGER.info(String.format("ThreadID: %d: CucumberWebScenarioListener\n", Thread.currentThread()
LOGGER.info(String.format("ThreadId: %d: CucumberWebScenarioListener\n", Thread.currentThread()
.getId()));
}

Expand All @@ -34,7 +34,7 @@ public void setEventPublisher(EventPublisher eventPublisher) {

private void webRunStartedHandler(TestRunStarted event) {
LOGGER.info("webRunStartedHandler");
LOGGER.info(String.format("ThreadID: %d: beforeSuite: \n", Thread.currentThread()
LOGGER.info(String.format("ThreadId: %d: beforeSuite: \n", Thread.currentThread()
.getId()));
}

Expand All @@ -49,7 +49,7 @@ private void webCaseStartedHandler(TestCaseStarted event) {
Integer scenarioRunCount = getScenarioRunCount(scenarioName);
String normalisedScenarioName = normaliseScenarioName(scenarioName);

LOGGER.info(String.format("ThreadID: %d: beforeScenario: for scenario: %s\n", Thread.currentThread()
LOGGER.info(String.format("ThreadId: %d: beforeScenario: for scenario: %s\n", Thread.currentThread()
.getId(), scenarioName));
testExecutionContext.addTestState(TEST_CONTEXT.SCENARIO_LOG_DIRECTORY, FileLocations.REPORTS_DIRECTORY + normalisedScenarioName);
testExecutionContext.addTestState(TEST_CONTEXT.SCREENSHOT_DIRECTORY,
Expand All @@ -75,7 +75,7 @@ private void webRunFinishedHandler(TestRunFinished event) {
LOGGER.info("webRunFinishedHandler: " + event.getResult()
.toString());
SessionContext.setReportPortalLaunchURL();
LOGGER.info(String.format("ThreadID: %d: afterSuite: \n", Thread.currentThread()
LOGGER.info(String.format("ThreadId: %d: afterSuite: \n", Thread.currentThread()
.getId()));
}

Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/znsio/e2e/runner/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public Runner() {
public Runner(String configFilePath, String stepDefDirName, String featuresDirName) {
Path path = Paths.get(configFilePath);
if(!Files.exists(path)) {
throw new InvalidTestDataException(String.format("Invalid path ('%s') provided for config", configFilePath));
throw new InvalidTestDataException(
String.format("Invalid path ('%s') provided for config", configFilePath));
}
setup = new Setup(configFilePath);
List<String> cukeArgs = setup.getExecutionArguments();
Expand Down Expand Up @@ -183,7 +184,9 @@ public static void main(String[] args) {
LOGGER.info("\t" + arg);
}
if(args.length != 3) {
throw new InvalidTestDataException("Expected following parameters: 'String configFilePath, String stepDefDirName, String featuresDirName");
throw new InvalidTestDataException(
"Expected following parameters: 'String configFilePath, String stepDefDirName, String " +
"featuresDirName");
}
new Runner(args[0], args[1], args[2]);
}
Expand Down Expand Up @@ -273,7 +276,8 @@ public static String getBrowserConfigFileContents() {
inputStream = Files.newInputStream(Paths.get(browserConfigFile));
}
} catch(Exception e) {
throw new InvalidTestDataException(String.format("There was a problem while setting browser config file '%s'", browserConfigFile));
throw new InvalidTestDataException(
String.format("There was a problem while setting browser config file '%s'", browserConfigFile));
}
configs.put(BROWSER_CONFIG_FILE_CONTENTS, new JSONObject(new JSONTokener(inputStream)).toString());
return configs.get(BROWSER_CONFIG_FILE_CONTENTS);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/znsio/e2e/runner/Setup.java
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ private ArrayList<String> setupWebExecution() {
return webCukeArgs;
}

static Map initialiseApplitoolsConfiguration() {
static Map<String, Object> initialiseApplitoolsConfiguration() {
if(applitoolsConfiguration.isEmpty()) {
getApplitoolsConfigFromProvidedConfigFile();
applitoolsConfiguration.put(APPLITOOLS.SERVER_URL, getServerUrl());
Expand Down
Loading

0 comments on commit 26fdc61

Please sign in to comment.