diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 07a1e612b..b0eae6d77 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -12,4 +12,4 @@ updates: - package-ecosystem: "github-actions" # See documentation for possible values directory: "/" # Location of package manifests schedule: - interval: "daily" + interval: "daily" \ No newline at end of file diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 350189031..6242cf8a7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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: @@ -28,4 +28,4 @@ jobs: - name: Build with Gradle uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef with: - arguments: build + arguments: build --refresh-dependencies diff --git a/build.gradle b/build.gradle index 9fc896b0b..a3cf807ac 100644 --- a/build.gradle +++ b/build.gradle @@ -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' diff --git a/caps/calculator2_local_capabilities.json b/caps/calculator2_local_capabilities.json index b019d1a50..946997b66 100644 --- a/caps/calculator2_local_capabilities.json +++ b/caps/calculator2_local_capabilities.json @@ -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", diff --git a/caps/calculator_local_capabilities.json b/caps/calculator_local_capabilities.json index b019d1a50..946997b66 100644 --- a/caps/calculator_local_capabilities.json +++ b/caps/calculator_local_capabilities.json @@ -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", diff --git a/caps/calculator_pcloudy_capabilities.json b/caps/calculator_pcloudy_capabilities.json index e3680b3ab..6837d6c6c 100644 --- a/caps/calculator_pcloudy_capabilities.json +++ b/caps/calculator_pcloudy_capabilities.json @@ -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": { diff --git a/caps/confengine_local_capabilities.json b/caps/confengine_local_capabilities.json new file mode 100644 index 000000000..d61bdfda9 --- /dev/null +++ b/caps/confengine_local_capabilities.json @@ -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" + } + ] + } + ] +} diff --git a/caps/dineout_local_capabilities.json b/caps/dineout_local_capabilities.json new file mode 100644 index 000000000..e0325f430 --- /dev/null +++ b/caps/dineout_local_capabilities.json @@ -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" + } + ] + } + ] +} diff --git a/caps/indigo_local_capabilities.json b/caps/indigo_local_capabilities.json new file mode 100644 index 000000000..8a4f5ee3c --- /dev/null +++ b/caps/indigo_local_capabilities.json @@ -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" + } + ] + } + ] +} diff --git a/caps/jiomeet_browserStack_capabilities.json b/caps/jiomeet_browserStack_capabilities.json index f52b91284..5dc06faac 100644 --- a/caps/jiomeet_browserStack_capabilities.json +++ b/caps/jiomeet_browserStack_capabilities.json @@ -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", diff --git a/caps/jiomeet_local_capabilities.json b/caps/jiomeet_local_capabilities.json index 73fb2ad60..aabbed2eb 100644 --- a/caps/jiomeet_local_capabilities.json +++ b/caps/jiomeet_local_capabilities.json @@ -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", diff --git a/caps/jiomeetlatest_capabilities.json b/caps/jiomeetlatest_capabilities.json index 73fb2ad60..aabbed2eb 100644 --- a/caps/jiomeetlatest_capabilities.json +++ b/caps/jiomeetlatest_capabilities.json @@ -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", diff --git a/caps/jiomeetoldversion_capabilities.json b/caps/jiomeetoldversion_capabilities.json index 51e76deb7..7d2a095da 100644 --- a/caps/jiomeetoldversion_capabilities.json +++ b/caps/jiomeetoldversion_capabilities.json @@ -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", diff --git a/caps/theapp_browserStack_capabilities.json b/caps/theapp_browserStack_capabilities.json index db58145df..d2ffc5215 100644 --- a/caps/theapp_browserStack_capabilities.json +++ b/caps/theapp_browserStack_capabilities.json @@ -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": { diff --git a/caps/theapp_headspin_capabilities.json b/caps/theapp_headspin_capabilities.json index b5c80ec2b..00c971616 100644 --- a/caps/theapp_headspin_capabilities.json +++ b/caps/theapp_headspin_capabilities.json @@ -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": { diff --git a/caps/theapp_local_capabilities.json b/caps/theapp_local_capabilities.json index 21e29a543..2038b2dd4 100644 --- a/caps/theapp_local_capabilities.json +++ b/caps/theapp_local_capabilities.json @@ -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 diff --git a/caps/theapp_pcloudy_capabilities.json b/caps/theapp_pcloudy_capabilities.json index 135f84c87..d7c71c168 100644 --- a/caps/theapp_pcloudy_capabilities.json +++ b/caps/theapp_pcloudy_capabilities.json @@ -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": { diff --git a/configs/confengine_local_config.properties b/configs/confengine_local_config.properties new file mode 100644 index 000000000..af730207b --- /dev/null +++ b/configs/confengine_local_config.properties @@ -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 diff --git a/configs/dineout_local_config.properties b/configs/dineout_local_config.properties new file mode 100644 index 000000000..b0e2a273c --- /dev/null +++ b/configs/dineout_local_config.properties @@ -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 diff --git a/configs/indigo_local_config.properties b/configs/indigo_local_config.properties new file mode 100644 index 000000000..53e08e40f --- /dev/null +++ b/configs/indigo_local_config.properties @@ -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 diff --git a/src/main/java/com/znsio/e2e/listener/CucumberWebScenarioListener.java b/src/main/java/com/znsio/e2e/listener/CucumberWebScenarioListener.java index f3dee1791..3bec02212 100644 --- a/src/main/java/com/znsio/e2e/listener/CucumberWebScenarioListener.java +++ b/src/main/java/com/znsio/e2e/listener/CucumberWebScenarioListener.java @@ -20,7 +20,7 @@ public class CucumberWebScenarioListener private final Map 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())); } @@ -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())); } @@ -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, @@ -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())); } diff --git a/src/main/java/com/znsio/e2e/runner/Runner.java b/src/main/java/com/znsio/e2e/runner/Runner.java index 4fca5ba27..16294ac30 100644 --- a/src/main/java/com/znsio/e2e/runner/Runner.java +++ b/src/main/java/com/znsio/e2e/runner/Runner.java @@ -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 cukeArgs = setup.getExecutionArguments(); @@ -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]); } @@ -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); diff --git a/src/main/java/com/znsio/e2e/runner/Setup.java b/src/main/java/com/znsio/e2e/runner/Setup.java index 10c3e4e57..bde0a19a2 100644 --- a/src/main/java/com/znsio/e2e/runner/Setup.java +++ b/src/main/java/com/znsio/e2e/runner/Setup.java @@ -435,7 +435,7 @@ private ArrayList setupWebExecution() { return webCukeArgs; } - static Map initialiseApplitoolsConfiguration() { + static Map initialiseApplitoolsConfiguration() { if(applitoolsConfiguration.isEmpty()) { getApplitoolsConfigFromProvidedConfigFile(); applitoolsConfiguration.put(APPLITOOLS.SERVER_URL, getServerUrl()); diff --git a/src/main/java/com/znsio/e2e/steps/RunCukes.java b/src/main/java/com/znsio/e2e/steps/RunCukes.java index e33669395..b03a0ea81 100644 --- a/src/main/java/com/znsio/e2e/steps/RunCukes.java +++ b/src/main/java/com/znsio/e2e/steps/RunCukes.java @@ -17,14 +17,14 @@ public class RunCukes public RunCukes() { long threadId = Thread.currentThread() .getId(); - LOGGER.info("RunCukes constructor: ThreadId: " + threadId); + LOGGER.info(String.format("ThreadId: '%s': RunCukes constructor", threadId)); context = SessionContext.getTestExecutionContext(threadId); } @Override @DataProvider(parallel = true) public Object[][] scenarios() { - LOGGER.info(String.format("ThreadID: %d: in overridden scenarios%n", Thread.currentThread() + LOGGER.info(String.format("ThreadId: %d: in overridden scenarios%n", Thread.currentThread() .getId())); Object[][] scenarios = super.scenarios(); LOGGER.info(scenarios); diff --git a/src/main/java/com/znsio/e2e/tools/Visual.java b/src/main/java/com/znsio/e2e/tools/Visual.java index f31050387..9b3fc88e9 100644 --- a/src/main/java/com/znsio/e2e/tools/Visual.java +++ b/src/main/java/com/znsio/e2e/tools/Visual.java @@ -105,6 +105,8 @@ private com.applitools.eyes.appium.Eyes instantiateAppiumEyes(String driverType, applitoolsLogFileNameForApp = getApplitoolsLogFileNameFor("app"); appEyes.setLogHandler(new FileLogger(applitoolsLogFileNameForApp, true, isVerboseLoggingEnabled)); + // todo - enhancements - https://applitools.com/docs/topics/general-concepts/visual-test-best-practices.html?Highlight=setMatchTimeout + // add setIgnoreCaret, setHideScrollbars, setIgnoreDisplacements appEyes.addProperty(APP_NAME, appName); appEyes.addProperty("USER_PERSONA", userPersona); appEyes.addProperty(BRANCH_NAME, String.valueOf(getValueFromConfig(BRANCH_NAME))); diff --git a/src/test/java/com/znsio/sample/e2e/businessLayer/confengine/ConfEngineBL.java b/src/test/java/com/znsio/sample/e2e/businessLayer/confengine/ConfEngineBL.java new file mode 100644 index 000000000..cb7402b0f --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/businessLayer/confengine/ConfEngineBL.java @@ -0,0 +1,41 @@ +package com.znsio.sample.e2e.businessLayer.confengine; + +import com.context.TestExecutionContext; +import com.znsio.e2e.entities.Platform; +import com.znsio.e2e.runner.Runner; +import com.znsio.sample.e2e.entities.SAMPLE_TEST_CONTEXT; +import com.znsio.sample.e2e.screen.confengine.ConfEngineLandingScreen; +import org.apache.log4j.Logger; +import org.assertj.core.api.SoftAssertions; + +public class ConfEngineBL { + private static final Logger LOGGER = Logger.getLogger(ConfEngineBL.class.getName()); + private final TestExecutionContext context; + private final SoftAssertions softly; + private final String currentUserPersona; + private final Platform currentPlatform; + + public ConfEngineBL(String userPersona, Platform forPlatform) { + long threadId = Thread.currentThread() + .getId(); + this.context = Runner.getTestExecutionContext(threadId); + softly = Runner.getSoftAssertion(threadId); + this.currentUserPersona = userPersona; + this.currentPlatform = forPlatform; + Runner.setCurrentDriverForUser(userPersona, forPlatform, context); + } + + public ConfEngineBL() { + long threadId = Thread.currentThread() + .getId(); + this.context = Runner.getTestExecutionContext(threadId); + softly = Runner.getSoftAssertion(threadId); + this.currentUserPersona = SAMPLE_TEST_CONTEXT.ME; + this.currentPlatform = Runner.platform; + } + + public ConfEngineBL seeListOfConferences() { + ConfEngineLandingScreen.get().getListOfConferences(); + return this; + } +} diff --git a/src/test/java/com/znsio/sample/e2e/businessLayer/dineout/DineoutSearchBL.java b/src/test/java/com/znsio/sample/e2e/businessLayer/dineout/DineoutSearchBL.java new file mode 100644 index 000000000..bc99a7f54 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/businessLayer/dineout/DineoutSearchBL.java @@ -0,0 +1,49 @@ +package com.znsio.sample.e2e.businessLayer.dineout; + +import com.context.TestExecutionContext; +import com.znsio.e2e.entities.Platform; +import com.znsio.e2e.runner.Runner; +import com.znsio.sample.e2e.entities.SAMPLE_TEST_CONTEXT; +import com.znsio.sample.e2e.screen.dineout.DineoutLandingScreen; +import org.apache.log4j.Logger; +import org.assertj.core.api.SoftAssertions; + +public class DineoutSearchBL { + private static final Logger LOGGER = Logger.getLogger(DineoutSearchBL.class.getName()); + private final TestExecutionContext context; + private final SoftAssertions softly; + private final String currentUserPersona; + private final Platform currentPlatform; + + public DineoutSearchBL(String userPersona, Platform forPlatform) { + long threadId = Thread.currentThread() + .getId(); + this.context = Runner.getTestExecutionContext(threadId); + softly = Runner.getSoftAssertion(threadId); + this.currentUserPersona = userPersona; + this.currentPlatform = forPlatform; + Runner.setCurrentDriverForUser(userPersona, forPlatform, context); + } + + public DineoutSearchBL() { + long threadId = Thread.currentThread() + .getId(); + this.context = Runner.getTestExecutionContext(threadId); + softly = Runner.getSoftAssertion(threadId); + this.currentUserPersona = SAMPLE_TEST_CONTEXT.ME; + this.currentPlatform = Runner.platform; + } + + public DineoutSearchBL selectCity(String city) { + DineoutLandingScreen.get() + .selectDefaultCity() + .selectCity(city); + return this; + } + + public DineoutSearchBL searchForCusine(String cusine) { + DineoutLandingScreen.get() + .searchCuisine(cusine); + return this; + } +} diff --git a/src/test/java/com/znsio/sample/e2e/businessLayer/indigo/FlightResultsBL.java b/src/test/java/com/znsio/sample/e2e/businessLayer/indigo/FlightResultsBL.java new file mode 100644 index 000000000..fb17e596e --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/businessLayer/indigo/FlightResultsBL.java @@ -0,0 +1,35 @@ +package com.znsio.sample.e2e.businessLayer.indigo; + +import com.context.TestExecutionContext; +import com.znsio.e2e.entities.Platform; +import com.znsio.e2e.runner.Runner; +import com.znsio.sample.e2e.entities.SAMPLE_TEST_CONTEXT; +import org.apache.log4j.Logger; +import org.assertj.core.api.SoftAssertions; + +public class FlightResultsBL { + private static final Logger LOGGER = Logger.getLogger(FlightResultsBL.class.getName()); + private final TestExecutionContext context; + private final SoftAssertions softly; + private final String currentUserPersona; + private final Platform currentPlatform; + + public FlightResultsBL(String userPersona, Platform forPlatform) { + long threadId = Thread.currentThread() + .getId(); + this.context = Runner.getTestExecutionContext(threadId); + softly = Runner.getSoftAssertion(threadId); + this.currentUserPersona = userPersona; + this.currentPlatform = forPlatform; + Runner.setCurrentDriverForUser(userPersona, forPlatform, context); + } + + public FlightResultsBL() { + long threadId = Thread.currentThread() + .getId(); + this.context = Runner.getTestExecutionContext(threadId); + softly = Runner.getSoftAssertion(threadId); + this.currentUserPersona = SAMPLE_TEST_CONTEXT.ME; + this.currentPlatform = Runner.platform; + } +} diff --git a/src/test/java/com/znsio/sample/e2e/businessLayer/indigo/GiftVoucherBL.java b/src/test/java/com/znsio/sample/e2e/businessLayer/indigo/GiftVoucherBL.java new file mode 100644 index 000000000..2b7a42211 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/businessLayer/indigo/GiftVoucherBL.java @@ -0,0 +1,71 @@ +package com.znsio.sample.e2e.businessLayer.indigo; + +import com.context.TestExecutionContext; +import com.znsio.e2e.entities.Platform; +import com.znsio.e2e.runner.Runner; +import com.znsio.sample.e2e.entities.SAMPLE_TEST_CONTEXT; +import com.znsio.sample.e2e.screen.indigo.IndigoGiftVouchersScreen; +import com.znsio.sample.e2e.screen.indigo.IndigoHomeScreen; +import org.apache.log4j.Logger; +import org.assertj.core.api.SoftAssertions; + +import static org.assertj.core.api.Assertions.assertThat; + +public class GiftVoucherBL { + private static final Logger LOGGER = Logger.getLogger(GiftVoucherBL.class.getName()); + private final TestExecutionContext context; + private final SoftAssertions softly; + private final String currentUserPersona; + private final Platform currentPlatform; + + public GiftVoucherBL(String userPersona, Platform forPlatform) { + long threadId = Thread.currentThread() + .getId(); + this.context = Runner.getTestExecutionContext(threadId); + softly = Runner.getSoftAssertion(threadId); + this.currentUserPersona = userPersona; + this.currentPlatform = forPlatform; + Runner.setCurrentDriverForUser(userPersona, forPlatform, context); + } + + public GiftVoucherBL() { + long threadId = Thread.currentThread() + .getId(); + this.context = Runner.getTestExecutionContext(threadId); + softly = Runner.getSoftAssertion(threadId); + this.currentUserPersona = SAMPLE_TEST_CONTEXT.ME; + this.currentPlatform = Runner.platform; + } + + private GiftVoucherBL selectWithoutPersonalise(String numberOfGiftVouchersToPurchase, String denomination) { + IndigoGiftVouchersScreen indigoGiftVouchersScreen = IndigoGiftVouchersScreen.get() + .select(numberOfGiftVouchersToPurchase, denomination) + .preview(); + int totalPrice = indigoGiftVouchersScreen.getTotalPrice(); + assertThat(totalPrice).as("Computed amount is incorrect") + .isEqualTo(Integer.parseInt(denomination) * Integer.parseInt(numberOfGiftVouchersToPurchase)); + return this; + } + + public GiftVoucherBL selectGiftVoucher(String numberOfGiftVouchersToPurchase, String denomination) { + IndigoGiftVouchersScreen indigoGiftVouchersScreen = IndigoHomeScreen.get() + .selectGiftVouchers() + .select(numberOfGiftVouchersToPurchase, denomination); + int totalPrice = indigoGiftVouchersScreen.getTotalPrice(); + assertThat(totalPrice).as("Computed amount is incorrect") + .isEqualTo(Integer.parseInt(denomination) * Integer.parseInt(numberOfGiftVouchersToPurchase)); + indigoGiftVouchersScreen.preview(); + return this; + } + + public GiftVoucherBL selectGiftVoucherAndPersonalise(String numberOfGiftVouchersToPurchase, String denomination, String forWhom, String customMessage) { + IndigoGiftVouchersScreen indigoGiftVouchersScreen = IndigoHomeScreen.get() + .selectGiftVouchers() + .select(numberOfGiftVouchersToPurchase, denomination, forWhom, customMessage); + int totalPrice = indigoGiftVouchersScreen.getTotalPrice(); + assertThat(totalPrice).as("Computed amount is incorrect") + .isEqualTo(Integer.parseInt(denomination) * Integer.parseInt(numberOfGiftVouchersToPurchase)); + indigoGiftVouchersScreen.preview(); + return this; + } +} diff --git a/src/test/java/com/znsio/sample/e2e/businessLayer/indigo/IndigoBL.java b/src/test/java/com/znsio/sample/e2e/businessLayer/indigo/IndigoBL.java new file mode 100644 index 000000000..3a0d67918 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/businessLayer/indigo/IndigoBL.java @@ -0,0 +1,46 @@ +package com.znsio.sample.e2e.businessLayer.indigo; + +import com.context.TestExecutionContext; +import com.znsio.e2e.entities.Platform; +import com.znsio.e2e.runner.Runner; +import com.znsio.sample.e2e.entities.SAMPLE_TEST_CONTEXT; +import com.znsio.sample.e2e.screen.indigo.IndigoHomeScreen; +import org.apache.log4j.Logger; +import org.assertj.core.api.SoftAssertions; + +public class IndigoBL { + private static final Logger LOGGER = Logger.getLogger(IndigoBL.class.getName()); + private final TestExecutionContext context; + private final SoftAssertions softly; + private final String currentUserPersona; + private final Platform currentPlatform; + + public IndigoBL(String userPersona, Platform forPlatform) { + long threadId = Thread.currentThread() + .getId(); + this.context = Runner.getTestExecutionContext(threadId); + softly = Runner.getSoftAssertion(threadId); + this.currentUserPersona = userPersona; + this.currentPlatform = forPlatform; + Runner.setCurrentDriverForUser(userPersona, forPlatform, context); + } + + public IndigoBL() { + long threadId = Thread.currentThread() + .getId(); + this.context = Runner.getTestExecutionContext(threadId); + softly = Runner.getSoftAssertion(threadId); + this.currentUserPersona = SAMPLE_TEST_CONTEXT.ME; + this.currentPlatform = Runner.platform; + } + + public FlightResultsBL searchForTicket(String journeyType, String from, String destination, String numberOfAdults) { + IndigoHomeScreen.get() + .selectJourneyType(journeyType) + .selectNumberOfAdultPassengers(Integer.parseInt(numberOfAdults)) + .selectFrom(from) + .selectTo(destination) + .searchFlightOptions(); + return new FlightResultsBL(); + } +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/android/confengine/ConfEngineLandingScreenAndroid.java b/src/test/java/com/znsio/sample/e2e/screen/android/confengine/ConfEngineLandingScreenAndroid.java new file mode 100644 index 000000000..c06dbd414 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/android/confengine/ConfEngineLandingScreenAndroid.java @@ -0,0 +1,38 @@ +package com.znsio.sample.e2e.screen.android.confengine; + +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.confengine.ConfEngineLandingScreen; +import io.appium.java_client.AppiumDriver; +import org.apache.log4j.Logger; +import org.openqa.selenium.By; + +import java.util.Set; + +public class ConfEngineLandingScreenAndroid + extends ConfEngineLandingScreen { + private final Driver driver; + private final Visual visually; + private static final String SCREEN_NAME = ConfEngineLandingScreenAndroid.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; + + public ConfEngineLandingScreenAndroid(Driver driver, Visual visually) { + this.driver = driver; + this.visually = visually; + visually.checkWindow(SCREEN_NAME, "Launch screen"); + } + + @Override + public ConfEngineLandingScreen getListOfConferences() { + visually.checkWindow(SCREEN_NAME, "Landing screen"); + Set contextNames = ((AppiumDriver) driver.getInnerDriver()).getContextHandles(); + for(String contextName : contextNames) { + System.out.println(contextName); //prints out something like NATIVE_APP \n WEBVIEW_1 + } + ((AppiumDriver) driver.getInnerDriver()).context(String.valueOf(contextNames.toArray()[1])); + driver.waitTillElementIsPresent(By.xpath("//li[@conference-id='selenium-conf-2022']")).click(); + visually.checkWindow(SCREEN_NAME, "Selected Selenium Conf 2022"); + return this; + } +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/android/dineout/DineoutLandingScreenAndroid.java b/src/test/java/com/znsio/sample/e2e/screen/android/dineout/DineoutLandingScreenAndroid.java new file mode 100644 index 000000000..ddf75d642 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/android/dineout/DineoutLandingScreenAndroid.java @@ -0,0 +1,88 @@ +package com.znsio.sample.e2e.screen.android.dineout; + +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.dineout.DineoutLandingScreen; +import org.apache.log4j.Logger; +import org.openqa.selenium.By; +import org.openqa.selenium.NoSuchElementException; +import org.openqa.selenium.WebElement; + +public class DineoutLandingScreenAndroid + extends DineoutLandingScreen { + private final Driver driver; + private final Visual visually; + private static final String SCREEN_NAME = DineoutLandingScreenAndroid.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; + + public DineoutLandingScreenAndroid(Driver driver, Visual visually) { + this.driver = driver; + this.visually = visually; + visually.checkWindow(SCREEN_NAME, "Launch screen"); + } + + @Override + public DineoutLandingScreen selectDefaultCity() { + driver.waitTillElementIsPresent(By.id("com.dineout.book:id/skip_tv")) + .click(); + driver.waitTillElementIsPresent(By.id("com.dineout.book:id/manual_location_txt")) + .click(); + driver.waitTillElementIsPresent(By.id("com.dineout.book:id/et_search_location")) + .sendKeys("Mumbai"); + driver.waitTillElementIsPresent(By.id("com.dineout.book:id/textView_search_location_header")) + .click(); + + + try { + // waitFor offer then click, if exists + driver.waitTillElementIsPresent(By.xpath( + "//android.widget.FrameLayout[@resource-id='com.dineout.book:id/inapp_half_interstitial_image_frame_layout']//android.widget" + + ".ImageView[not(@resource-id='com.dineout.book:id/half_interstitial_image')]"), + 10) + .click(); + } catch(NoSuchElementException e) { + LOGGER.info("Did not get any popup banner"); + } + + try { + // update location, if exists + driver.waitTillElementIsPresent(By.id("com.dineout.book:id/txt_update_now_cta"), 5) + .click(); + } catch(NoSuchElementException e) { + LOGGER.info("Did not get update location CTA"); + } + return this; + } + + @Override + public DineoutLandingScreen selectCity(String city) { + driver.waitTillElementIsPresent(By.id("com.dineout.book:id/search_text")) + .click(); + driver.waitTillElementIsPresent(By.id("com.dineout.book:id/tv_rest_suggestions")) + .sendKeys("Mumbai"); + // select the region + driver.waitTillElementIsPresent(By.xpath("//android.widget.TextView[@text='Location']")) + .click(); + + // select first from the list + driver.waitTillElementIsPresent(By.id("com.dineout.book:id/suggestion_layout")) + .click(); + return this; + } + + @Override + public DineoutLandingScreen searchCuisine(String cuisine) { + driver.waitTillElementIsPresent(By.id("com.dineout.book:id/image_view_search")) + .click(); + WebElement suggestionsElement = driver.waitTillElementIsPresent(By.id("com.dineout.book:id/tv_rest_suggestions")); + suggestionsElement.click(); + suggestionsElement.sendKeys(cuisine); + suggestionsElement.click(); + driver.waitTillElementIsPresent(By.xpath("//android.widget.TextView[@text='Cuisine']")) + .click(); + driver.waitTillElementIsPresent(By.id("com.dineout.book:id/selected_state_container")) + .click(); + return this; + } +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/android/indigo/IndigoFlightSearchResultsScreenAndroid.java b/src/test/java/com/znsio/sample/e2e/screen/android/indigo/IndigoFlightSearchResultsScreenAndroid.java new file mode 100644 index 000000000..f36eb202a --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/android/indigo/IndigoFlightSearchResultsScreenAndroid.java @@ -0,0 +1,20 @@ +package com.znsio.sample.e2e.screen.android.indigo; + +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.indigo.IndigoFlightSearchResultsScreen; +import org.apache.log4j.Logger; + +public class IndigoFlightSearchResultsScreenAndroid + extends IndigoFlightSearchResultsScreen { + private final Driver driver; + private final Visual visually; + private static final String SCREEN_NAME = IndigoFlightSearchResultsScreenAndroid.class.getSimpleName(); + private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + + public IndigoFlightSearchResultsScreenAndroid(Driver driver, Visual visually) { + this.driver = driver; + this.visually = visually; + } +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/android/indigo/IndigoGiftVouchersScreenAndroid.java b/src/test/java/com/znsio/sample/e2e/screen/android/indigo/IndigoGiftVouchersScreenAndroid.java new file mode 100644 index 000000000..75a173867 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/android/indigo/IndigoGiftVouchersScreenAndroid.java @@ -0,0 +1,76 @@ +package com.znsio.sample.e2e.screen.android.indigo; + +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.indigo.IndigoGiftVouchersScreen; +import io.appium.java_client.AppiumDriver; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.log4j.Logger; +import org.openqa.selenium.By; + +import java.util.Set; + +public class IndigoGiftVouchersScreenAndroid + extends IndigoGiftVouchersScreen { + private final Driver driver; + private final Visual visually; + private static final String SCREEN_NAME = IndigoGiftVouchersScreenAndroid.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; + private static final By bySelectDenominationDropdownXpath = By.xpath("//android.widget.TextView[@text='Select Denomination']"); + private static final String bySelectValueFromDropdown = "//android.widget.CheckedTextView[@text='%s']"; + private static final By bySelectQuantityDropdownXpath = By.xpath("//android.widget.TextView[@text='Select']"); + private static final By byPreviewButtonXpath = By.xpath("//android.widget.Button[@text='Preview']"); + private static final By byTotalAmountId = By.id("in.goindigo.android:id/lblTotal"); + + private static final String byGiftValueTitleXpath = "//android.widget.TextView[@text='Gift Voucher Denomination']"; + + public IndigoGiftVouchersScreenAndroid(Driver driver, Visual visually) { + this.driver = driver; + this.visually = visually; + driver.waitTillElementIsVisible(By.xpath(byGiftValueTitleXpath), 20); + visually.checkWindow(SCREEN_NAME, "On Gift Vouchers screen"); + } + + @Override + public IndigoGiftVouchersScreen select(String numberOfGiftVouchersToPurchase, String denomination) { + throw new NotImplementedException(SCREEN_NAME + ":" + new Throwable().getStackTrace()[0].getMethodName() + NOT_YET_IMPLEMENTED); + } + + @Override + public int getTotalPrice() { + throw new NotImplementedException(SCREEN_NAME + ":" + new Throwable().getStackTrace()[0].getMethodName() + NOT_YET_IMPLEMENTED); + } + + @Override + public IndigoGiftVouchersScreen select(String numberOfGiftVouchersToPurchase, String denomination, String forWhom, String customMessage) { + driver.findElement(bySelectDenominationDropdownXpath) + .click(); + String denominationToSelectXpath = String.format(bySelectValueFromDropdown, denomination); + driver.waitTillElementIsVisible(By.xpath(denominationToSelectXpath)) + .click(); + visually.checkWindow(SCREEN_NAME, "Selected voucher denomination"); + driver.waitTillElementIsVisible(bySelectQuantityDropdownXpath) + .click(); + String quantitytoSelectXpath = String.format(bySelectValueFromDropdown, numberOfGiftVouchersToPurchase); + driver.waitTillElementIsVisible(By.xpath(quantitytoSelectXpath)) + .click(); + visually.checkWindow(SCREEN_NAME, "Selected voucher quantity"); + Set contextNames = ((AppiumDriver) driver.getInnerDriver()).getContextHandles(); + driver.scrollDownByScreenSize(); + + String lblTotal = driver.findElement(byTotalAmountId) + .getText(); + LOGGER.info("Total amount: " + lblTotal); + driver.findElement(By.id("chkPersonal")) + .click(); + visually.checkWindow(SCREEN_NAME, "Personalise gift voucher selected"); + + return this; + } + + @Override + public IndigoGiftVouchersScreen preview() { + throw new NotImplementedException(SCREEN_NAME + ":" + new Throwable().getStackTrace()[0].getMethodName() + NOT_YET_IMPLEMENTED); + } +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/android/indigo/IndigoHomeScreenAndroid.java b/src/test/java/com/znsio/sample/e2e/screen/android/indigo/IndigoHomeScreenAndroid.java new file mode 100644 index 000000000..d65e56943 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/android/indigo/IndigoHomeScreenAndroid.java @@ -0,0 +1,63 @@ +package com.znsio.sample.e2e.screen.android.indigo; + +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.indigo.IndigoFlightSearchResultsScreen; +import com.znsio.sample.e2e.screen.indigo.IndigoGiftVouchersScreen; +import com.znsio.sample.e2e.screen.indigo.IndigoHomeScreen; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.log4j.Logger; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +public class IndigoHomeScreenAndroid + extends IndigoHomeScreen { + private final Driver driver; + private final Visual visually; + private static final String SCREEN_NAME = IndigoHomeScreenAndroid.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; + private static final By byContinueAsGuestId = By.id("in.goindigo.android:id/button_as_guest"); + private static final By byGiftVoucherXpath = By.xpath("//android.widget.TextView[@text='Gift voucher']/.."); + + public IndigoHomeScreenAndroid(Driver driver, Visual visually) { + this.driver = driver; + this.visually = visually; + WebElement continueAsGuestElement = this.driver.waitForClickabilityOf(byContinueAsGuestId, 20); + visually.checkWindow(SCREEN_NAME, "Launch screen"); + continueAsGuestElement.click(); + } + + @Override + public IndigoHomeScreen selectFrom(String from) { + throw new NotImplementedException(SCREEN_NAME + ":" + new Throwable().getStackTrace()[0].getMethodName() + NOT_YET_IMPLEMENTED); + } + + @Override + public IndigoHomeScreen selectTo(String destination) { + throw new NotImplementedException(SCREEN_NAME + ":" + new Throwable().getStackTrace()[0].getMethodName() + NOT_YET_IMPLEMENTED); + } + + @Override + public IndigoHomeScreen selectNumberOfAdultPassengers(int numberOfAdults) { + throw new NotImplementedException(SCREEN_NAME + ":" + new Throwable().getStackTrace()[0].getMethodName() + NOT_YET_IMPLEMENTED); + } + + @Override + public IndigoHomeScreen selectJourneyType(String journeyType) { + throw new NotImplementedException(SCREEN_NAME + ":" + new Throwable().getStackTrace()[0].getMethodName() + NOT_YET_IMPLEMENTED); + } + + @Override + public IndigoFlightSearchResultsScreen searchFlightOptions() { + throw new NotImplementedException(SCREEN_NAME + ":" + new Throwable().getStackTrace()[0].getMethodName() + NOT_YET_IMPLEMENTED); + } + + @Override + public IndigoGiftVouchersScreen selectGiftVouchers() { + WebElement giftVoucherElement = driver.waitForClickabilityOf(byGiftVoucherXpath, 20); + visually.checkWindow(SCREEN_NAME, "On Landing screen"); + giftVoucherElement.click(); + return IndigoGiftVouchersScreen.get(); + } +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/android/jiomeet/InAMeetingScreenAndroid.java b/src/test/java/com/znsio/sample/e2e/screen/android/jiomeet/InAMeetingScreenAndroid.java index a8dcf8c84..302b89500 100644 --- a/src/test/java/com/znsio/sample/e2e/screen/android/jiomeet/InAMeetingScreenAndroid.java +++ b/src/test/java/com/znsio/sample/e2e/screen/android/jiomeet/InAMeetingScreenAndroid.java @@ -17,10 +17,10 @@ public class InAMeetingScreenAndroid private final Visual visually; private static final String SCREEN_NAME = InAMeetingScreenAndroid.class.getSimpleName(); private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); - private final By byMicStatusId = By.id("com.jio.rilconferences:id/mic_status_label"); - private final By byMeetingId = By.id("com.jio.rilconferences:id/caller_number"); - private final By byMeetingPasswordId = By.id("com.jio.rilconferences:id/caller_password"); - private final By byTopHeaderControlsPanelId = By.id("videoTopLayout1"); + private static final By byMicStatusId = By.id("com.jio.rilconferences:id/mic_status_label"); + private static final By byMeetingId = By.id("com.jio.rilconferences:id/caller_number"); + private static final By byMeetingPasswordId = By.id("com.jio.rilconferences:id/caller_password"); + private static final By byTopHeaderControlsPanelId = By.id("videoTopLayout1"); private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; public InAMeetingScreenAndroid(Driver driver, Visual visually) { diff --git a/src/test/java/com/znsio/sample/e2e/screen/android/jiomeet/LandingScreenAndroid.java b/src/test/java/com/znsio/sample/e2e/screen/android/jiomeet/LandingScreenAndroid.java index 8c5839f48..b24fa36de 100644 --- a/src/test/java/com/znsio/sample/e2e/screen/android/jiomeet/LandingScreenAndroid.java +++ b/src/test/java/com/znsio/sample/e2e/screen/android/jiomeet/LandingScreenAndroid.java @@ -15,8 +15,8 @@ public class LandingScreenAndroid private final Visual visually; private static final String SCREEN_NAME = LandingScreenAndroid.class.getSimpleName(); private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); - private final By byWelcomeMessageId = By.id("com.jio.rilconferences:id/textUserName"); - private final By byStartInstantMeetingId = By.id("com.jio.rilconferences:id/buttonStartMeeting"); + private static final By byWelcomeMessageId = By.id("com.jio.rilconferences:id/textUserName"); + private static final By byStartInstantMeetingId = By.id("com.jio.rilconferences:id/buttonStartMeeting"); public LandingScreenAndroid(Driver driver, Visual visually) { this.driver = driver; diff --git a/src/test/java/com/znsio/sample/e2e/screen/android/jiomeet/SignInScreenAndroid.java b/src/test/java/com/znsio/sample/e2e/screen/android/jiomeet/SignInScreenAndroid.java index fa8bbfbdf..c4b096ff4 100644 --- a/src/test/java/com/znsio/sample/e2e/screen/android/jiomeet/SignInScreenAndroid.java +++ b/src/test/java/com/znsio/sample/e2e/screen/android/jiomeet/SignInScreenAndroid.java @@ -17,17 +17,17 @@ public class SignInScreenAndroid private final Visual visually; private static final String SCREEN_NAME = SignInScreenAndroid.class.getSimpleName(); private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); - private final By bySignInId = By.id("com.jio.rilconferences:id/signIn"); - private final By byUserNameId = By.id("com.jio.rilconferences:id/edit_mobile_number"); - private final By byProceedButtonId = By.id("com.jio.rilconferences:id/btn_otp_next"); - private final By byPasswordId = By.id("com.jio.rilconferences:id/edt_otp_number"); - private final By byWelcomeMessageId = By.id("com.jio.rilconferences:id/textUserName"); - private final By byJoinMeetingId = By.id("com.jio.rilconferences:id/joinMeetingBtn"); - private final By byEnterMeetingId = By.id("com.jio.rilconferences:id/inputMeetingLink"); - private final By byEnterMeetingPasswordId = By.id("com.jio.rilconferences:id/inputMeetingPassword"); - private final By byEnterDisplayNameId = By.id("com.jio.rilconferences:id/inputUserName"); - private final By byEnterMeeting = By.id("com.jio.rilconferences:id/buttonNext"); - private final By byJoinMeeting = By.id("com.jio.rilconferences:id/buttonJoinMeeting"); + private static final By bySignInId = By.id("com.jio.rilconferences:id/signIn"); + private static final By byUserNameId = By.id("com.jio.rilconferences:id/edit_mobile_number"); + private static final By byProceedButtonId = By.id("com.jio.rilconferences:id/btn_otp_next"); + private static final By byPasswordId = By.id("com.jio.rilconferences:id/edt_otp_number"); + private static final By byWelcomeMessageId = By.id("com.jio.rilconferences:id/textUserName"); + private static final By byJoinMeetingId = By.id("com.jio.rilconferences:id/joinMeetingBtn"); + private static final By byEnterMeetingId = By.id("com.jio.rilconferences:id/inputMeetingLink"); + private static final By byEnterMeetingPasswordId = By.id("com.jio.rilconferences:id/inputMeetingPassword"); + private static final By byEnterDisplayNameId = By.id("com.jio.rilconferences:id/inputUserName"); + private static final By byEnterMeeting = By.id("com.jio.rilconferences:id/buttonNext"); + private static final By byJoinMeeting = By.id("com.jio.rilconferences:id/buttonJoinMeeting"); public SignInScreenAndroid(Driver driver, Visual visually) { this.driver = driver; diff --git a/src/test/java/com/znsio/sample/e2e/screen/android/theapp/AppLaunchScreenAndroid.java b/src/test/java/com/znsio/sample/e2e/screen/android/theapp/AppLaunchScreenAndroid.java index 1705f7d14..051f2dc07 100644 --- a/src/test/java/com/znsio/sample/e2e/screen/android/theapp/AppLaunchScreenAndroid.java +++ b/src/test/java/com/znsio/sample/e2e/screen/android/theapp/AppLaunchScreenAndroid.java @@ -17,8 +17,8 @@ public class AppLaunchScreenAndroid private final Visual visually; private final String byClipboardDemoAccessibilityId = "Clipboard Demo"; private final String loginScreenAccessibilityId = "Login Screen"; - private final By byGoBackToHomeScreenButtonXpath = By.xpath("//android.widget.ImageButton[@content-desc=\"Navigate Up\"]"); - private final By byEchoMessageXpath = By.xpath("//android.view.ViewGroup[@content-desc=\"Echo Box\"]/android.view.ViewGroup"); + private static final By byGoBackToHomeScreenButtonXpath = By.xpath("//android.widget.ImageButton[@content-desc=\"Navigate Up\"]"); + private static final By byEchoMessageXpath = By.xpath("//android.view.ViewGroup[@content-desc=\"Echo Box\"]/android.view.ViewGroup"); public AppLaunchScreenAndroid(Driver driver, Visual visually) { this.driver = driver; diff --git a/src/test/java/com/znsio/sample/e2e/screen/android/theapp/EchoScreenAndroid.java b/src/test/java/com/znsio/sample/e2e/screen/android/theapp/EchoScreenAndroid.java index 3848907ae..786e7f7f2 100644 --- a/src/test/java/com/znsio/sample/e2e/screen/android/theapp/EchoScreenAndroid.java +++ b/src/test/java/com/znsio/sample/e2e/screen/android/theapp/EchoScreenAndroid.java @@ -11,8 +11,8 @@ public class EchoScreenAndroid private final Visual visually; private final String SCREEN_NAME = EchoScreenAndroid.class.getSimpleName(); private final String byMessageInputAccessibilityId = "messageInput"; - private final By bySaveMessageButtonXpath = By.xpath("//android.widget.Button[@content-desc=\"messageSaveBtn\"]/android.widget.TextView"); - private final By byGoBackToHomeScreenButtonXpath = By.xpath("//android.widget.ImageButton[@content-desc=\"Navigate Up\"]"); + private static final By bySaveMessageButtonXpath = By.xpath("//android.widget.Button[@content-desc=\"messageSaveBtn\"]/android.widget.TextView"); + private static final By byGoBackToHomeScreenButtonXpath = By.xpath("//android.widget.ImageButton[@content-desc=\"Navigate Up\"]"); public EchoScreenAndroid(Driver driver, Visual visually) { this.driver = driver; diff --git a/src/test/java/com/znsio/sample/e2e/screen/android/theapp/LoginScreenAndroid.java b/src/test/java/com/znsio/sample/e2e/screen/android/theapp/LoginScreenAndroid.java index a09a15897..be4cf6dcf 100644 --- a/src/test/java/com/znsio/sample/e2e/screen/android/theapp/LoginScreenAndroid.java +++ b/src/test/java/com/znsio/sample/e2e/screen/android/theapp/LoginScreenAndroid.java @@ -18,8 +18,8 @@ public class LoginScreenAndroid private final String userNameId = "username"; private final String passwordId = "password"; private final String loginButtonId = "loginBtn"; - private final By errorMessageId = By.id("android:id/message"); - private final By dismissAlertId = By.id("android:id/button1"); + private static final By errorMessageId = By.id("android:id/message"); + private static final By dismissAlertId = By.id("android:id/button1"); public LoginScreenAndroid(Driver driver, Visual visually) { this.driver = driver; diff --git a/src/test/java/com/znsio/sample/e2e/screen/confengine/ConfEngineLandingScreen.java b/src/test/java/com/znsio/sample/e2e/screen/confengine/ConfEngineLandingScreen.java new file mode 100644 index 000000000..b1f0c5362 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/confengine/ConfEngineLandingScreen.java @@ -0,0 +1,38 @@ +package com.znsio.sample.e2e.screen.confengine; + +import com.znsio.e2e.entities.Platform; +import com.znsio.e2e.runner.Runner; +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.android.confengine.ConfEngineLandingScreenAndroid; +import com.znsio.sample.e2e.screen.web.confengine.ConfEngineLandingScreenWeb; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.log4j.Logger; + +import static com.znsio.e2e.runner.Runner.fetchDriver; +import static com.znsio.e2e.runner.Runner.fetchEyes; + +public abstract class ConfEngineLandingScreen { + private static final String SCREEN_NAME = ConfEngineLandingScreen.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + + public static ConfEngineLandingScreen get() { + Driver driver = fetchDriver(Thread.currentThread() + .getId()); + Platform platform = Runner.fetchPlatform(Thread.currentThread() + .getId()); + LOGGER.info(SCREEN_NAME + ": Driver type: " + driver.getType() + ": Platform: " + platform); + Visual visually = fetchEyes(Thread.currentThread() + .getId()); + + switch(platform) { + case android: + return new ConfEngineLandingScreenAndroid(driver, visually); + case web: + return new ConfEngineLandingScreenWeb(driver, visually); + } + throw new NotImplementedException(SCREEN_NAME + " is not implemented in " + Runner.platform); + } + + public abstract ConfEngineLandingScreen getListOfConferences(); +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/dineout/DineoutLandingScreen.java b/src/test/java/com/znsio/sample/e2e/screen/dineout/DineoutLandingScreen.java new file mode 100644 index 000000000..2eb5d26d3 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/dineout/DineoutLandingScreen.java @@ -0,0 +1,42 @@ +package com.znsio.sample.e2e.screen.dineout; + +import com.znsio.e2e.entities.Platform; +import com.znsio.e2e.runner.Runner; +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.android.dineout.DineoutLandingScreenAndroid; +import com.znsio.sample.e2e.screen.web.dineout.DineoutLandingScreenWeb; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.log4j.Logger; + +import static com.znsio.e2e.runner.Runner.fetchDriver; +import static com.znsio.e2e.runner.Runner.fetchEyes; + +public abstract class DineoutLandingScreen { + private static final String SCREEN_NAME = DineoutLandingScreen.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + + public static DineoutLandingScreen get() { + Driver driver = fetchDriver(Thread.currentThread() + .getId()); + Platform platform = Runner.fetchPlatform(Thread.currentThread() + .getId()); + LOGGER.info(SCREEN_NAME + ": Driver type: " + driver.getType() + ": Platform: " + platform); + Visual visually = fetchEyes(Thread.currentThread() + .getId()); + + switch(platform) { + case android: + return new DineoutLandingScreenAndroid(driver, visually); + case web: + return new DineoutLandingScreenWeb(driver, visually); + } + throw new NotImplementedException(SCREEN_NAME + " is not implemented in " + Runner.platform); + } + + public abstract DineoutLandingScreen selectDefaultCity(); + + public abstract DineoutLandingScreen selectCity(String city); + + public abstract DineoutLandingScreen searchCuisine(String cusine); +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/indigo/IndigoFlightSearchResultsScreen.java b/src/test/java/com/znsio/sample/e2e/screen/indigo/IndigoFlightSearchResultsScreen.java new file mode 100644 index 000000000..1a6107686 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/indigo/IndigoFlightSearchResultsScreen.java @@ -0,0 +1,36 @@ +package com.znsio.sample.e2e.screen.indigo; + +import com.znsio.e2e.entities.Platform; +import com.znsio.e2e.runner.Runner; +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.android.indigo.IndigoFlightSearchResultsScreenAndroid; +import com.znsio.sample.e2e.screen.web.indigo.IndigoFlightSearchResultsScreenWeb; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.log4j.Logger; + +import static com.znsio.e2e.runner.Runner.fetchDriver; +import static com.znsio.e2e.runner.Runner.fetchEyes; + +public abstract class IndigoFlightSearchResultsScreen { + private static final String SCREEN_NAME = IndigoFlightSearchResultsScreen.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + + public static IndigoFlightSearchResultsScreen get() { + Driver driver = fetchDriver(Thread.currentThread() + .getId()); + Platform platform = Runner.fetchPlatform(Thread.currentThread() + .getId()); + LOGGER.info(SCREEN_NAME + ": Driver type: " + driver.getType() + ": Platform: " + platform); + Visual visually = fetchEyes(Thread.currentThread() + .getId()); + + switch(platform) { + case android: + return new IndigoFlightSearchResultsScreenAndroid(driver, visually); + case web: + return new IndigoFlightSearchResultsScreenWeb(driver, visually); + } + throw new NotImplementedException(SCREEN_NAME + " is not implemented in " + Runner.platform); + } +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/indigo/IndigoGiftVouchersScreen.java b/src/test/java/com/znsio/sample/e2e/screen/indigo/IndigoGiftVouchersScreen.java new file mode 100644 index 000000000..bba001351 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/indigo/IndigoGiftVouchersScreen.java @@ -0,0 +1,44 @@ +package com.znsio.sample.e2e.screen.indigo; + +import com.znsio.e2e.entities.Platform; +import com.znsio.e2e.runner.Runner; +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.android.indigo.IndigoGiftVouchersScreenAndroid; +import com.znsio.sample.e2e.screen.web.indigo.IndigoGiftVouchersScreenWeb; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.log4j.Logger; + +import static com.znsio.e2e.runner.Runner.fetchDriver; +import static com.znsio.e2e.runner.Runner.fetchEyes; + +public abstract class IndigoGiftVouchersScreen { + private static final String SCREEN_NAME = IndigoGiftVouchersScreen.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + + public static IndigoGiftVouchersScreen get() { + Driver driver = fetchDriver(Thread.currentThread() + .getId()); + Platform platform = Runner.fetchPlatform(Thread.currentThread() + .getId()); + LOGGER.info(SCREEN_NAME + ": Driver type: " + driver.getType() + ": Platform: " + platform); + Visual visually = fetchEyes(Thread.currentThread() + .getId()); + + switch(platform) { + case android: + return new IndigoGiftVouchersScreenAndroid(driver, visually); + case web: + return new IndigoGiftVouchersScreenWeb(driver, visually); + } + throw new NotImplementedException(SCREEN_NAME + " is not implemented in " + Runner.platform); + } + + public abstract IndigoGiftVouchersScreen select(String numberOfGiftVouchersToPurchase, String denomination); + + public abstract int getTotalPrice(); + + public abstract IndigoGiftVouchersScreen select(String numberOfGiftVouchersToPurchase, String denomination, String forWhom, String customMessage); + + public abstract IndigoGiftVouchersScreen preview(); +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/indigo/IndigoHomeScreen.java b/src/test/java/com/znsio/sample/e2e/screen/indigo/IndigoHomeScreen.java new file mode 100644 index 000000000..b74c09e95 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/indigo/IndigoHomeScreen.java @@ -0,0 +1,48 @@ +package com.znsio.sample.e2e.screen.indigo; + +import com.znsio.e2e.entities.Platform; +import com.znsio.e2e.runner.Runner; +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.android.indigo.IndigoHomeScreenAndroid; +import com.znsio.sample.e2e.screen.web.indigo.IndigoHomeScreenWeb; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.log4j.Logger; + +import static com.znsio.e2e.runner.Runner.fetchDriver; +import static com.znsio.e2e.runner.Runner.fetchEyes; + +public abstract class IndigoHomeScreen { + private static final String SCREEN_NAME = IndigoHomeScreen.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + + public static IndigoHomeScreen get() { + Driver driver = fetchDriver(Thread.currentThread() + .getId()); + Platform platform = Runner.fetchPlatform(Thread.currentThread() + .getId()); + LOGGER.info(SCREEN_NAME + ": Driver type: " + driver.getType() + ": Platform: " + platform); + Visual visually = fetchEyes(Thread.currentThread() + .getId()); + + switch(platform) { + case android: + return new IndigoHomeScreenAndroid(driver, visually); + case web: + return new IndigoHomeScreenWeb(driver, visually); + } + throw new NotImplementedException(SCREEN_NAME + " is not implemented in " + Runner.platform); + } + + public abstract IndigoHomeScreen selectFrom(String from); + + public abstract IndigoHomeScreen selectTo(String destination); + + public abstract IndigoHomeScreen selectNumberOfAdultPassengers(int numberOfAdults); + + public abstract IndigoHomeScreen selectJourneyType(String journeyType); + + public abstract IndigoFlightSearchResultsScreen searchFlightOptions(); + + public abstract IndigoGiftVouchersScreen selectGiftVouchers(); +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/web/confengine/ConfEngineLandingScreenWeb.java b/src/test/java/com/znsio/sample/e2e/screen/web/confengine/ConfEngineLandingScreenWeb.java new file mode 100644 index 000000000..8fd8822f0 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/web/confengine/ConfEngineLandingScreenWeb.java @@ -0,0 +1,27 @@ +package com.znsio.sample.e2e.screen.web.confengine; + +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.confengine.ConfEngineLandingScreen; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.log4j.Logger; + +public class ConfEngineLandingScreenWeb + extends ConfEngineLandingScreen { + private final Driver driver; + private final Visual visually; + private static final String SCREEN_NAME = ConfEngineLandingScreenWeb.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; + + public ConfEngineLandingScreenWeb(Driver driver, Visual visually) { + this.driver = driver; + this.visually = visually; + visually.checkWindow(SCREEN_NAME, "Launch screen"); + } + + @Override + public ConfEngineLandingScreen getListOfConferences() { + throw new NotImplementedException(SCREEN_NAME + ":" + new Throwable().getStackTrace()[0].getMethodName() + NOT_YET_IMPLEMENTED); + } +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/web/dineout/DineoutLandingScreenWeb.java b/src/test/java/com/znsio/sample/e2e/screen/web/dineout/DineoutLandingScreenWeb.java new file mode 100644 index 000000000..cb3dbf862 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/web/dineout/DineoutLandingScreenWeb.java @@ -0,0 +1,52 @@ +package com.znsio.sample.e2e.screen.web.dineout; + +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.dineout.DineoutLandingScreen; +import org.apache.commons.lang3.NotImplementedException; +import org.apache.log4j.Logger; +import org.openqa.selenium.By; +import org.openqa.selenium.WebElement; + +public class DineoutLandingScreenWeb + extends DineoutLandingScreen { + + private final Driver driver; + private final Visual visually; + private static final String SCREEN_NAME = DineoutLandingScreenWeb.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; + + public DineoutLandingScreenWeb(Driver driver, Visual visually) { + this.driver = driver; + this.visually = visually; + visually.checkWindow(SCREEN_NAME, "Launch screen"); + } + + @Override + public DineoutLandingScreen selectDefaultCity() { + driver.waitTillElementIsPresent(By.xpath("//a[@aria-label='Mumbai']")) + .click(); + return this; + } + + @Override + public DineoutLandingScreen selectCity(String city) { + visually.checkWindow(SCREEN_NAME, "On home page"); + WebElement restaurantSearch = driver.waitTillElementIsPresent(By.id("restaurantSearch")); + restaurantSearch.clear(); + restaurantSearch.sendKeys(city); + visually.checkWindow(SCREEN_NAME, "Selected default city"); + driver.waitTillElementIsPresent(By.xpath("//li[text()='Location']")) + .click(); + driver.waitTillElementIsPresent(By.xpath("//section//button[@value='Submit']")) + .click(); + visually.checkWindow(SCREEN_NAME, "Selected first area in city - " + city); + return this; + } + + @Override + public DineoutLandingScreen searchCuisine(String cusine) { + throw new NotImplementedException(SCREEN_NAME + ":" + new Throwable().getStackTrace()[0].getMethodName() + NOT_YET_IMPLEMENTED); + } +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/web/indigo/IndigoFlightSearchResultsScreenWeb.java b/src/test/java/com/znsio/sample/e2e/screen/web/indigo/IndigoFlightSearchResultsScreenWeb.java new file mode 100644 index 000000000..9f58b1565 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/web/indigo/IndigoFlightSearchResultsScreenWeb.java @@ -0,0 +1,33 @@ +package com.znsio.sample.e2e.screen.web.indigo; + +import com.context.TestExecutionContext; +import com.znsio.e2e.runner.Runner; +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.indigo.IndigoFlightSearchResultsScreen; +import org.apache.log4j.Logger; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; + +public class IndigoFlightSearchResultsScreenWeb + extends IndigoFlightSearchResultsScreen { + private final Driver driver; + private final Visual visually; + private final WebDriver innerDriver; + private final TestExecutionContext context; + private static final String SCREEN_NAME = IndigoFlightSearchResultsScreenWeb.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; + private static final By byBackToSearchResultsLinkXpath = By.xpath("//div[@class='bck-to-search']"); + + public IndigoFlightSearchResultsScreenWeb(Driver driver, Visual visually) { + this.driver = driver; + this.visually = visually; + this.innerDriver = this.driver.getInnerDriver(); + long threadId = Thread.currentThread() + .getId(); + context = Runner.getTestExecutionContext(threadId); + driver.waitTillElementIsVisible(byBackToSearchResultsLinkXpath, 30); + visually.checkWindow(SCREEN_NAME, "On Search Results page"); + } +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/web/indigo/IndigoGiftVouchersScreenWeb.java b/src/test/java/com/znsio/sample/e2e/screen/web/indigo/IndigoGiftVouchersScreenWeb.java new file mode 100644 index 000000000..ca8ff1517 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/web/indigo/IndigoGiftVouchersScreenWeb.java @@ -0,0 +1,85 @@ +package com.znsio.sample.e2e.screen.web.indigo; + +import com.context.TestExecutionContext; +import com.znsio.e2e.runner.Runner; +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.indigo.IndigoGiftVouchersScreen; +import org.apache.log4j.Logger; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.Select; + +import static com.znsio.e2e.tools.Wait.waitFor; + +public class IndigoGiftVouchersScreenWeb + extends IndigoGiftVouchersScreen { + private final Driver driver; + private final Visual visually; + private final WebDriver innerDriver; + private final TestExecutionContext context; + private static final String SCREEN_NAME = IndigoGiftVouchersScreenWeb.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; + private static final By bySelectedVoucherValueDropdownId = By.id("SelectedVoucherValue"); + private static final By bySelectedVoucherQuantityDropdownId = By.id("SelectedVoucherQuantity"); + private static final By byTotalAmountId = By.id("lblTotal"); + private static final By byForNameId = By.id("Per_Fname"); + private static final By byCustomMessageId = By.id("Message"); + private static final By byPreviewButtonXpath = By.xpath("//input[@class='preview-btn']"); + private static final By byPreviewVoucherHeadingXpath = By.xpath("//div[@class='heading']/h2[contains(text(),'Preview Your Voucher')]"); + + public IndigoGiftVouchersScreenWeb(Driver driver, Visual visually) { + this.driver = driver; + this.visually = visually; + this.innerDriver = this.driver.getInnerDriver(); + long threadId = Thread.currentThread() + .getId(); + context = Runner.getTestExecutionContext(threadId); + waitFor(2); + } + + @Override + public IndigoGiftVouchersScreen select(String numberOfGiftVouchersToPurchase, String denomination) { + Select selectDenomination = new Select(driver.findElement(bySelectedVoucherValueDropdownId)); + selectDenomination.selectByValue(denomination); + Select selectQuantity = new Select(driver.findElement(bySelectedVoucherQuantityDropdownId)); + selectQuantity.selectByValue(numberOfGiftVouchersToPurchase); + visually.checkWindow(SCREEN_NAME, "Selected denomination and quality"); + return this; + } + + @Override + public int getTotalPrice() { + String total = driver.findElement(byTotalAmountId) + .getText(); + int totalAmount = Integer.parseInt(total.split(" ")[1]); + return totalAmount; + } + + @Override + public IndigoGiftVouchersScreen select(String numberOfGiftVouchersToPurchase, String denomination, String forWhom, String customMessage) { + select(numberOfGiftVouchersToPurchase, denomination); + driver.findElement(By.id("chkPersonal")) + .click(); + WebElement forWhomElement = driver.findElement(byForNameId); + forWhomElement.clear(); + forWhomElement.sendKeys(forWhom); + + WebElement customMessageElement = driver.findElement(byCustomMessageId); + customMessageElement.clear(); + customMessageElement.sendKeys(customMessage); + visually.checkWindow(SCREEN_NAME, "Personalised Gift Voucher"); + return this; + } + + @Override + public IndigoGiftVouchersScreen preview() { + driver.waitForClickabilityOf(byPreviewButtonXpath) + .click(); + driver.waitTillElementIsVisible(byPreviewVoucherHeadingXpath); + visually.checkWindow(SCREEN_NAME, "Preview Gift Voucher"); + return this; + } +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/web/indigo/IndigoHomeScreenWeb.java b/src/test/java/com/znsio/sample/e2e/screen/web/indigo/IndigoHomeScreenWeb.java new file mode 100644 index 000000000..9709d07a5 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/screen/web/indigo/IndigoHomeScreenWeb.java @@ -0,0 +1,164 @@ +package com.znsio.sample.e2e.screen.web.indigo; + +import com.context.TestExecutionContext; +import com.znsio.e2e.runner.Runner; +import com.znsio.e2e.tools.Driver; +import com.znsio.e2e.tools.Visual; +import com.znsio.sample.e2e.screen.indigo.IndigoFlightSearchResultsScreen; +import com.znsio.sample.e2e.screen.indigo.IndigoGiftVouchersScreen; +import com.znsio.sample.e2e.screen.indigo.IndigoHomeScreen; +import org.apache.log4j.Logger; +import org.openqa.selenium.By; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.interactions.Actions; + +import static com.znsio.e2e.tools.Wait.waitFor; + +public class IndigoHomeScreenWeb + extends IndigoHomeScreen { + private final Driver driver; + private final Visual visually; + private final WebDriver innerDriver; + private final TestExecutionContext context; + private static final String SCREEN_NAME = IndigoHomeScreenWeb.class.getSimpleName(); + private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); + private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; + private static final By byFromXpath = By.xpath("//input[@placeholder='From']"); + private static final By byToXpath = By.xpath("//input[@placeholder='To']"); + private static final String byFromDropdown = "..//div[@data-name='%s']"; + private static final String byToDropDown = "..//div[@data-name='%s']"; + private static final By byPopularDestinationsDropdownXpath = By.xpath("..//div[text()=\"Popular Destinations\"]"); + private static final By bySelectedNumberOfPassengersXpath = By.xpath("//input[@name='passenger']"); + private static final By byJourneyTypeXpath = By.xpath("//div[@class='filter-option-inner-inner']"); + ; + private static final By byNumberOfPassengersSelectionDoneXpath = By.xpath("//button[text()='Done']"); + ; + private static final By byCloseExtraSeatTooltipXpath = By.xpath("//i[@class='icon-close close-extraseat-tooltip']"); + private static final By byCloseAcceptCookiesXpath = By.xpath("//a[@class='close-cookie']"); + private static final By bySearchFlightOptionsXpath = By.xpath("//span[text()='Search Flight']"); + private static final By byDecreaseAdultPassengerCountXpath = By.xpath("//button[@title='Decrease Adult Passenger Count']"); + private static final By byIncreaseAdultPassengerCountXpath = By.xpath("//button[@title='Increase Adult Passenger Count']"); + private static final By byGetSelectedAdultPassengerCountXpath = By.xpath("//input[@class='counter adult-pax']"); + private static final By bySelectBookingXpath = By.xpath("//a[@title='Book']"); + private static final By bySelectGiftVouchersXpath = By.xpath("//div[@class='menu-wrapper-child']//div[text()='Gift Voucher']"); + private static final By bySelectJourneyTypeXpath = By.xpath("//a[contains(@class,'one-way-tab')]"); + + public IndigoHomeScreenWeb(Driver driver, Visual visually) { + this.driver = driver; + this.visually = visually; + this.innerDriver = this.driver.getInnerDriver(); + long threadId = Thread.currentThread() + .getId(); + context = Runner.getTestExecutionContext(threadId); + waitFor(2); + if(driver.isElementPresent(byCloseAcceptCookiesXpath)) { + driver.findElement(byCloseAcceptCookiesXpath) + .click(); + } + } + + @Override + public IndigoHomeScreen selectFrom(String from) { + WebElement fromElement = driver.findElement(byFromXpath); + fromElement.click(); + fromElement.sendKeys(from); + fromElement.findElement(By.xpath(String.format(byFromDropdown, from))) + .click(); + visually.checkWindow(SCREEN_NAME, "selected from"); + return this; + } + + @Override + public IndigoHomeScreen selectTo(String destination) { + WebElement toElement = driver.findElement(byToXpath); + toElement.click(); + toElement.sendKeys(destination); + toElement.findElement(byPopularDestinationsDropdownXpath); + String dest = String.format(byToDropDown, destination); + LOGGER.info("dest: " + dest); + toElement.findElement(By.xpath(dest)) + .click(); + visually.checkWindow(SCREEN_NAME, "selected destination"); + return this; + } + + @Override + public IndigoHomeScreen selectNumberOfAdultPassengers(int numberOfAdultsToSelect) { + driver.waitForClickabilityOf(bySelectedNumberOfPassengersXpath) + .click(); + visually.checkWindow(SCREEN_NAME, "Pre-selected number of passengers"); + if(driver.isElementPresent(byCloseExtraSeatTooltipXpath)) { + driver.findElement(byCloseExtraSeatTooltipXpath) + .click(); + } + int numberOfAdultsSelected = getNumberOfAdultsSelected(); + LOGGER.info("numberOfAdultsSelected: " + numberOfAdultsSelected); + if(numberOfAdultsToSelect == numberOfAdultsSelected) { + LOGGER.info("Number of adults selected is already as expected: " + numberOfAdultsToSelect); + } else if(numberOfAdultsToSelect < numberOfAdultsSelected) { + decrementAdultPassengerSelection(numberOfAdultsToSelect, numberOfAdultsSelected); + } else { + incrementAdultPassengerSelection(numberOfAdultsToSelect, numberOfAdultsSelected); + } + driver.findElement(byNumberOfPassengersSelectionDoneXpath) + .click(); + return this; + } + + private IndigoHomeScreenWeb decrementAdultPassengerSelection(int numberOfAdultsToSelect, int numberOfAdultsSelected) { + while(numberOfAdultsToSelect < numberOfAdultsSelected && numberOfAdultsSelected != 1) { + LOGGER.info("Decreasing adult passenger selected count"); + driver.findElement(byDecreaseAdultPassengerCountXpath) + .click(); + numberOfAdultsSelected--; + } + return this; + } + + private int getNumberOfAdultsSelected() { + return Integer.parseInt(driver.findElement(byGetSelectedAdultPassengerCountXpath) + .getAttribute("value")); + } + + private IndigoHomeScreenWeb incrementAdultPassengerSelection(int numberOfAdultsToSelect, int numberOfAdultsSelected) { + while(numberOfAdultsToSelect > numberOfAdultsSelected) { + LOGGER.info("Increasing adult passenger selected count"); + driver.findElement(byIncreaseAdultPassengerCountXpath) + .click(); + numberOfAdultsSelected++; + } + return this; + } + + @Override + public IndigoHomeScreen selectJourneyType(String journeyType) { + driver.findElement(byJourneyTypeXpath) + .click(); + visually.checkWindow(SCREEN_NAME, "Journey type options displayed"); + driver.findElement(bySelectJourneyTypeXpath) + .click(); + return this; + } + + @Override + public IndigoFlightSearchResultsScreen searchFlightOptions() { + driver.findElement(bySearchFlightOptionsXpath) + .click(); + return IndigoFlightSearchResultsScreen.get(); + } + + @Override + public IndigoGiftVouchersScreen selectGiftVouchers() { + WebElement bookElement = driver.findElement(bySelectBookingXpath); + Actions action = new Actions(driver.getInnerDriver()); + action.moveToElement(bookElement); + WebElement giftVouchersElement = driver.findElement(bySelectGiftVouchersXpath); + action.moveToElement(giftVouchersElement); + action.click() + .build() + .perform(); + visually.checkWindow(SCREEN_NAME, "Clicked on Gift Voucher"); + return IndigoGiftVouchersScreen.get(); + } +} diff --git a/src/test/java/com/znsio/sample/e2e/screen/web/jiomeet/InAMeetingScreenWeb.java b/src/test/java/com/znsio/sample/e2e/screen/web/jiomeet/InAMeetingScreenWeb.java index fca0d82c5..875751cf6 100644 --- a/src/test/java/com/znsio/sample/e2e/screen/web/jiomeet/InAMeetingScreenWeb.java +++ b/src/test/java/com/znsio/sample/e2e/screen/web/jiomeet/InAMeetingScreenWeb.java @@ -24,11 +24,11 @@ public class InAMeetingScreenWeb private static final String SCREEN_NAME = InAMeetingScreenWeb.class.getSimpleName(); private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; - private final By byMeetingInfoIconXpath = By.xpath("//div[@class='icon pointer']"); - private final By byMicLabelXpath = By.xpath("//div[contains(@class,'mic-section')]"); - private final By byCurrentMeetingNumberXpath = By.xpath("//div[text()='Meeting ID']/following-sibling::div"); - private final By byCurrentMeetingPinXpath = By.xpath("//div[text()='Password']/following-sibling::div"); - private final By byCurrentMeetingInvitationLinkXpath = By.xpath("//div[text()='Invitation Link']/following-sibling::div"); + private static final By byMeetingInfoIconXpath = By.xpath("//div[@class='icon pointer']"); + private static final By byMicLabelXpath = By.xpath("//div[contains(@class,'mic-section')]"); + private static final By byCurrentMeetingNumberXpath = By.xpath("//div[text()='Meeting ID']/following-sibling::div"); + private static final By byCurrentMeetingPinXpath = By.xpath("//div[text()='Password']/following-sibling::div"); + private static final By byCurrentMeetingInvitationLinkXpath = By.xpath("//div[text()='Invitation Link']/following-sibling::div"); private final TestExecutionContext context; public InAMeetingScreenWeb(Driver driver, Visual visually) { diff --git a/src/test/java/com/znsio/sample/e2e/screen/web/jiomeet/LandingScreenWeb.java b/src/test/java/com/znsio/sample/e2e/screen/web/jiomeet/LandingScreenWeb.java index 79782cc55..16489c058 100644 --- a/src/test/java/com/znsio/sample/e2e/screen/web/jiomeet/LandingScreenWeb.java +++ b/src/test/java/com/znsio/sample/e2e/screen/web/jiomeet/LandingScreenWeb.java @@ -15,12 +15,12 @@ public class LandingScreenWeb private final Visual visually; private static final String SCREEN_NAME = LandingScreenAndroid.class.getSimpleName(); private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); - private final By byHeadingXpath = By.xpath("//h3[contains(@class,'heading')]"); - private final By byWelcomeTextDescriptionXpath = By.xpath("//p[@class='desc']"); + private static final By byHeadingXpath = By.xpath("//h3[contains(@class,'heading')]"); + private static final By byWelcomeTextDescriptionXpath = By.xpath("//p[@class='desc']"); private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; - private final By byStartAMeetingOptionXpath = By.xpath("//div[text()='Start a Meeting']"); - private final By byPMIButtonXpath = By.xpath("//span[contains(text(), 'Personal Meeting ID')]"); - private final By byStartMeetingButtonXpath = By.xpath("//button[contains(text(), 'Start')]"); + private static final By byStartAMeetingOptionXpath = By.xpath("//div[text()='Start a Meeting']"); + private static final By byPMIButtonXpath = By.xpath("//span[contains(text(), 'Personal Meeting ID')]"); + private static final By byStartMeetingButtonXpath = By.xpath("//button[contains(text(), 'Start')]"); public LandingScreenWeb(Driver driver, Visual visually) { this.driver = driver; diff --git a/src/test/java/com/znsio/sample/e2e/screen/web/jiomeet/SignInScreenWeb.java b/src/test/java/com/znsio/sample/e2e/screen/web/jiomeet/SignInScreenWeb.java index 8b11c0c98..6687afc8d 100644 --- a/src/test/java/com/znsio/sample/e2e/screen/web/jiomeet/SignInScreenWeb.java +++ b/src/test/java/com/znsio/sample/e2e/screen/web/jiomeet/SignInScreenWeb.java @@ -18,16 +18,16 @@ public class SignInScreenWeb private static final String SCREEN_NAME = SignInScreenWeb.class.getSimpleName(); private static final Logger LOGGER = Logger.getLogger(SCREEN_NAME); private static final String NOT_YET_IMPLEMENTED = " not yet implemented"; - private final By byEnterMeetingId = By.id("meetingId"); - private final By byJoinMeetingButtonId = By.id("headerJoinMeetingButton"); - private final By byEnterPasswordId = By.id("pin"); - private final By byNameId = By.id("name"); - private final By byJoinMeetingButtonXpath = By.xpath("//button[contains(text(), 'Join')]"); - private final By bySignInXpath = By.xpath("//a[text()='Sign In']"); - private final By byUsernameId = By.id("username"); - private final By byProceedButtonId = By.id("proceedButton"); - private final By byPasswordId = By.id("password"); - private final By bySigninButtonId = By.id("signinButton"); + private static final By byEnterMeetingId = By.id("meetingId"); + private static final By byJoinMeetingButtonId = By.id("headerJoinMeetingButton"); + private static final By byEnterPasswordId = By.id("pin"); + private static final By byNameId = By.id("name"); + private static final By byJoinMeetingButtonXpath = By.xpath("//button[contains(text(), 'Join')]"); + private static final By bySignInXpath = By.xpath("//a[text()='Sign In']"); + private static final By byUsernameId = By.id("username"); + private static final By byProceedButtonId = By.id("proceedButton"); + private static final By byPasswordId = By.id("password"); + private static final By bySigninButtonId = By.id("signinButton"); public SignInScreenWeb(Driver driver, Visual visually) { this.driver = driver; diff --git a/src/test/java/com/znsio/sample/e2e/screen/web/theapp/AppLaunchScreenWeb.java b/src/test/java/com/znsio/sample/e2e/screen/web/theapp/AppLaunchScreenWeb.java index 1a33bc787..dcb8c7bf6 100644 --- a/src/test/java/com/znsio/sample/e2e/screen/web/theapp/AppLaunchScreenWeb.java +++ b/src/test/java/com/znsio/sample/e2e/screen/web/theapp/AppLaunchScreenWeb.java @@ -16,7 +16,7 @@ public class AppLaunchScreenWeb private final Driver driver; private final Visual visually; private final String SCREEN_NAME = AppLaunchScreenWeb.class.getSimpleName(); - private final By loginFormLinkText = By.linkText("Form Authentication"); + private static final By loginFormLinkText = By.linkText("Form Authentication"); public AppLaunchScreenWeb(Driver driver, Visual visually) { this.driver = driver; diff --git a/src/test/java/com/znsio/sample/e2e/screen/web/theapp/LoginScreenWeb.java b/src/test/java/com/znsio/sample/e2e/screen/web/theapp/LoginScreenWeb.java index 541f98265..0c95d24d1 100644 --- a/src/test/java/com/znsio/sample/e2e/screen/web/theapp/LoginScreenWeb.java +++ b/src/test/java/com/znsio/sample/e2e/screen/web/theapp/LoginScreenWeb.java @@ -13,11 +13,11 @@ public class LoginScreenWeb private final Driver driver; private final Visual visually; private final String SCREEN_NAME = LoginScreenWeb.class.getSimpleName(); - private final By userNameId = By.id("username"); - private final By passwordId = By.id("password"); - private final By loginButtonXpath = By.xpath("//button/i[contains(text(),\"Login\")]"); - private final By errorMessageId = By.id("flash"); - private final By dismissAlertXpath = By.xpath("//a[@href=\"#\"]"); + private static final By userNameId = By.id("username"); + private static final By passwordId = By.id("password"); + private static final By loginButtonXpath = By.xpath("//button/i[contains(text(),\"Login\")]"); + private static final By errorMessageId = By.id("flash"); + private static final By dismissAlertXpath = By.xpath("//a[@href=\"#\"]"); public LoginScreenWeb(Driver driver, Visual visually) { this.driver = driver; diff --git a/src/test/java/com/znsio/sample/e2e/screen/windows/notepad/NotepadScreenWindows.java b/src/test/java/com/znsio/sample/e2e/screen/windows/notepad/NotepadScreenWindows.java index d1ea75cbc..0a66fc526 100644 --- a/src/test/java/com/znsio/sample/e2e/screen/windows/notepad/NotepadScreenWindows.java +++ b/src/test/java/com/znsio/sample/e2e/screen/windows/notepad/NotepadScreenWindows.java @@ -12,7 +12,7 @@ public class NotepadScreenWindows private final Driver driver; private final Visual visually; private final String SCREEN_NAME = NotepadScreenWindows.class.getSimpleName(); - private final By byEditorName = By.name("Text Editor"); + private static final By byEditorName = By.name("Text Editor"); public NotepadScreenWindows(Driver driver, Visual visually) { this.driver = driver; diff --git a/src/test/java/com/znsio/sample/e2e/steps/AppLaunchSteps.java b/src/test/java/com/znsio/sample/e2e/steps/AppLaunchSteps.java index 691cd00dd..24f080d4f 100644 --- a/src/test/java/com/znsio/sample/e2e/steps/AppLaunchSteps.java +++ b/src/test/java/com/znsio/sample/e2e/steps/AppLaunchSteps.java @@ -49,12 +49,13 @@ public void startsOn(String userPersona, String appName, String browserName) { /** * method to evaluate whether the scenario is to be executed in normal web browser view or mobile emulation specific view * if mobile emulation is detected, it adds the targeted device name in context that will be utilized while creating WebDriver + * * @param browserName (like 'firefox-mobile2', 'chrome-tab1', etc) * @return actual browser name (like 'firefox', 'chrome', etc) */ private String evaluateBrowserType(String browserName) { String[] details = browserName.split("-"); - if (details.length == 1) { + if(details.length == 1) { //when user passes values like 'chrome', 'firefox', etc return browserName; } diff --git a/src/test/java/com/znsio/sample/e2e/steps/ConfEngineSteps.java b/src/test/java/com/znsio/sample/e2e/steps/ConfEngineSteps.java new file mode 100644 index 000000000..abe6ddf12 --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/steps/ConfEngineSteps.java @@ -0,0 +1,37 @@ +package com.znsio.sample.e2e.steps; + +import com.context.SessionContext; +import com.context.TestExecutionContext; +import com.znsio.e2e.entities.Platform; +import com.znsio.e2e.runner.Runner; +import com.znsio.e2e.tools.Drivers; +import com.znsio.sample.e2e.businessLayer.confengine.ConfEngineBL; +import com.znsio.sample.e2e.businessLayer.theapp.AppBL; +import com.znsio.sample.e2e.businessLayer.theapp.ClipboardBL; +import com.znsio.sample.e2e.businessLayer.theapp.EchoBL; +import com.znsio.sample.e2e.entities.SAMPLE_TEST_CONTEXT; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.Then; +import io.cucumber.java.en.When; +import org.apache.log4j.Logger; + +public class ConfEngineSteps { + private static final Logger LOGGER = Logger.getLogger(ConfEngineSteps.class.getName()); + private final TestExecutionContext context; + private final Drivers allDrivers; + + public ConfEngineSteps() { + context = SessionContext.getTestExecutionContext(Thread.currentThread() + .getId()); + LOGGER.info("context: " + context.getTestName()); + allDrivers = (Drivers) context.getTestState(SAMPLE_TEST_CONTEXT.ALL_DRIVERS); + LOGGER.info("allDrivers: " + (null == allDrivers)); + } + + @Given("I see the list of conferences") + public void iSeeTheListOfConferences() { + LOGGER.info(System.out.printf("iSeeTheListOfConferences - Persona:'%s'", SAMPLE_TEST_CONTEXT.ME)); + allDrivers.createDriverFor(SAMPLE_TEST_CONTEXT.ME, Runner.platform, context); + new ConfEngineBL(SAMPLE_TEST_CONTEXT.ME, Runner.platform).seeListOfConferences(); + } +} diff --git a/src/test/java/com/znsio/sample/e2e/steps/DineoutSteps.java b/src/test/java/com/znsio/sample/e2e/steps/DineoutSteps.java new file mode 100644 index 000000000..134c8bc5a --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/steps/DineoutSteps.java @@ -0,0 +1,38 @@ +package com.znsio.sample.e2e.steps; + +import com.context.SessionContext; +import com.context.TestExecutionContext; +import com.znsio.e2e.runner.Runner; +import com.znsio.e2e.tools.Drivers; +import com.znsio.sample.e2e.businessLayer.dineout.DineoutSearchBL; +import com.znsio.sample.e2e.entities.SAMPLE_TEST_CONTEXT; +import io.cucumber.java.en.Given; +import io.cucumber.java.en.When; +import org.apache.log4j.Logger; + +public class DineoutSteps { + private static final Logger LOGGER = Logger.getLogger(IndigoSteps.class.getName()); + private final TestExecutionContext context; + private final Drivers allDrivers; + + public DineoutSteps() { + context = SessionContext.getTestExecutionContext(Thread.currentThread() + .getId()); + LOGGER.info("context: " + context.getTestName()); + allDrivers = (Drivers) context.getTestState(SAMPLE_TEST_CONTEXT.ALL_DRIVERS); + LOGGER.info("allDrivers: " + (null == allDrivers)); + } + + @Given("I am in {string}") + public void iAmIn(String city) { + LOGGER.info(System.out.printf("iAmIn - Persona:'%s'", SAMPLE_TEST_CONTEXT.ME)); + allDrivers.createDriverFor(SAMPLE_TEST_CONTEXT.ME, Runner.platform, context); + new DineoutSearchBL(SAMPLE_TEST_CONTEXT.ME, Runner.platform).selectCity(city); + } + + @When("I search for {string} cuisine restaurants") + public void iSearchForCuisineRestaurants(String cusine) { + LOGGER.info(System.out.printf("iSearchForCuisineRestaurants - Persona:'%s'", SAMPLE_TEST_CONTEXT.ME)); + new DineoutSearchBL(SAMPLE_TEST_CONTEXT.ME, Runner.platform).searchForCusine(cusine); + } +} diff --git a/src/test/java/com/znsio/sample/e2e/steps/IndigoSteps.java b/src/test/java/com/znsio/sample/e2e/steps/IndigoSteps.java new file mode 100644 index 000000000..45770e93c --- /dev/null +++ b/src/test/java/com/znsio/sample/e2e/steps/IndigoSteps.java @@ -0,0 +1,46 @@ +package com.znsio.sample.e2e.steps; + +import com.context.SessionContext; +import com.context.TestExecutionContext; +import com.znsio.e2e.runner.Runner; +import com.znsio.e2e.tools.Drivers; +import com.znsio.sample.e2e.businessLayer.indigo.GiftVoucherBL; +import com.znsio.sample.e2e.businessLayer.indigo.IndigoBL; +import com.znsio.sample.e2e.entities.SAMPLE_TEST_CONTEXT; +import io.cucumber.java.en.Given; +import org.apache.log4j.Logger; + +public class IndigoSteps { + private static final Logger LOGGER = Logger.getLogger(IndigoSteps.class.getName()); + private final TestExecutionContext context; + private final Drivers allDrivers; + + public IndigoSteps() { + context = SessionContext.getTestExecutionContext(Thread.currentThread() + .getId()); + LOGGER.info("context: " + context.getTestName()); + allDrivers = (Drivers) context.getTestState(SAMPLE_TEST_CONTEXT.ALL_DRIVERS); + LOGGER.info("allDrivers: " + (null == allDrivers)); + } + + @Given("I search for a {string} ticket from {string} to {string} for {string} adult passenger") + public void iSearchForATicketFromToForPassenger(String journeyType, String from, String destination, String numberOfAdults) { + LOGGER.info(System.out.printf("iSearchForATicketFromToForPassenger - Persona:'%s'", SAMPLE_TEST_CONTEXT.ME)); + allDrivers.createDriverFor(SAMPLE_TEST_CONTEXT.ME, Runner.platform, context); + new IndigoBL(SAMPLE_TEST_CONTEXT.ME, Runner.platform).searchForTicket(journeyType, from, destination, numberOfAdults); + } + + @Given("I want to purchase {string} gift voucher of INR {string}") + public void iWantToPurchaseGiftVoucherOfINR(String numberOfGiftVouchersToPurchase, String denomination) { + LOGGER.info(System.out.printf("iWantToPurchaseGiftVoucherOfINR - Persona:'%s'", SAMPLE_TEST_CONTEXT.ME)); + allDrivers.createDriverFor(SAMPLE_TEST_CONTEXT.ME, Runner.platform, context); + new GiftVoucherBL(SAMPLE_TEST_CONTEXT.ME, Runner.platform).selectGiftVoucher(numberOfGiftVouchersToPurchase, denomination); + } + + @Given("I want to personalize {string} gift voucher of INR {string} for {string} with message {string}") + public void iWantToPersonalizeGiftVoucherOfINRForWithMessage(String numberOfGiftVouchersToPurchase, String denomination, String forWhom, String customMessage) { + LOGGER.info(System.out.printf("iWantToPurchaseGiftVoucherOfINR - Persona:'%s'", SAMPLE_TEST_CONTEXT.ME)); + allDrivers.createDriverFor(SAMPLE_TEST_CONTEXT.ME, Runner.platform, context); + new GiftVoucherBL(SAMPLE_TEST_CONTEXT.ME, Runner.platform).selectGiftVoucherAndPersonalise(numberOfGiftVouchersToPurchase, denomination, forWhom, customMessage); + } +} diff --git a/src/test/java/com/znsio/sample/e2e/steps/RunTestCukes.java b/src/test/java/com/znsio/sample/e2e/steps/RunTestCukes.java index a125cc8cd..b5d08e113 100644 --- a/src/test/java/com/znsio/sample/e2e/steps/RunTestCukes.java +++ b/src/test/java/com/znsio/sample/e2e/steps/RunTestCukes.java @@ -32,7 +32,7 @@ public RunTestCukes() { @Override @DataProvider(parallel = true) public Object[][] scenarios() { - LOGGER.info(String.format("ThreadID: %d: in overridden scenarios%n", Thread.currentThread() + LOGGER.info(String.format("ThreadId: %d: in overridden scenarios%n", Thread.currentThread() .getId())); Object[][] scenarios = super.scenarios(); LOGGER.info(scenarios); @@ -41,7 +41,7 @@ public Object[][] scenarios() { @Before public void beforeTestScenario(Scenario scenario) { - LOGGER.info(String.format("ThreadID: %d: in overridden beforeTestScenario%n", Thread.currentThread() + LOGGER.info(String.format("ThreadId: %d: in overridden beforeTestScenario%n", Thread.currentThread() .getId())); new Hooks().beforeScenario(scenario); Configuration ufgConfig = new Configuration(); @@ -54,7 +54,7 @@ public void beforeTestScenario(Scenario scenario) { @After public void afterTestScenario(Scenario scenario) { - LOGGER.info(String.format("ThreadID: %d: in overridden afterTestScenario%n", Thread.currentThread() + LOGGER.info(String.format("ThreadId: %d: in overridden afterTestScenario%n", Thread.currentThread() .getId())); new Hooks().afterScenario(scenario); } diff --git a/src/test/resources/com/znsio/sample/e2e/features/confEngine.feature b/src/test/resources/com/znsio/sample/e2e/features/confEngine.feature new file mode 100644 index 000000000..83e88bb1c --- /dev/null +++ b/src/test/resources/com/znsio/sample/e2e/features/confEngine.feature @@ -0,0 +1,7 @@ +@confengine @dev +Feature: Create a personal schedule + +# CONFIG=./configs/confengine_local_config.properties PLATFORM=android TAG=confengine ./gradlew run + @android + Scenario: See the schedule of an upcoming conference + Given I see the list of conferences diff --git a/src/test/resources/com/znsio/sample/e2e/features/dineout.feature b/src/test/resources/com/znsio/sample/e2e/features/dineout.feature new file mode 100644 index 000000000..138b48863 --- /dev/null +++ b/src/test/resources/com/znsio/sample/e2e/features/dineout.feature @@ -0,0 +1,10 @@ +@dineout +Feature: Search for restaurants + +# CONFIG=./configs/dineout_local_config.properties PLATFORM=android TAG=dineout ./gradlew run + @web @android @searchRestaurants + Scenario: Search for one way ticket from Pune to Delhi for single passenger + Given I am in "Mumbai" + When I search for "mexican" cuisine restaurants + And I filter for restaurants with "Dineout Pay" offers + Then I can reserve a table in the first restaurant displayed diff --git a/src/test/resources/com/znsio/sample/e2e/features/indigo.feature b/src/test/resources/com/znsio/sample/e2e/features/indigo.feature new file mode 100644 index 000000000..eec74aa7f --- /dev/null +++ b/src/test/resources/com/znsio/sample/e2e/features/indigo.feature @@ -0,0 +1,18 @@ +@indigo +Feature: Search for flight options + +# CONFIG=./configs/indigo_local_config.properties PLATFORM=web TAG=searchFlights ./gradlew run + @web @searchFlights + Scenario: Search for one way ticket from Pune to Delhi for single passenger + Given I search for a "one-way" ticket from "Pune" to "Delhi" for "1" adult passenger + +# CONFIG=./configs/indigo_local_config.properties PLATFORM=web TAG=giftVoucher ./gradlew run + @web @android @giftVoucher + Scenario Outline: Customise and preview an Indigo gift voucher with invalid Promo code + Given I want to personalize "1" gift voucher of INR "10000" for "" with message "" + When I provide the receiver and sender details and "deny" the terms & conditions + Then I cannot purchase the gift voucher + + Examples: + | receipient | personalisedMessage | + | my friend | Safe travels | diff --git a/src/test/resources/environments.json b/src/test/resources/environments.json index 2d7e3216f..bfc2aaa5d 100644 --- a/src/test/resources/environments.json +++ b/src/test/resources/environments.json @@ -4,6 +4,11 @@ "BASE_URL": "http://the-internet.herokuapp.com/", "IMAGES_BASE_URL": "http://images.google.com/", "BING_BASE_URL": "http://bing.com/images", - "JIOMEET_BASE_URL": "https://jiomeetpro.jio.com/home" + "JIOMEET_BASE_URL": "https://jiomeetpro.jio.com/home", + "INDIGO_BASE_URL": "https://www.goindigo.in/", + "DINEOUT_BASE_URL": "https://www.dineout.co.in/" + }, + "dev": { + "CONFENGINE_BASE_URL": "https://www.dev.confengine.com/" } } \ No newline at end of file diff --git a/src/test/resources/sampleApps/AndroidCalculator.apk b/src/test/resources/sampleApps/AndroidCalculator.apk deleted file mode 100644 index c858b4b36..000000000 Binary files a/src/test/resources/sampleApps/AndroidCalculator.apk and /dev/null differ diff --git a/src/test/resources/sampleApps/TheApp-release.apk b/src/test/resources/sampleApps/TheApp-release.apk deleted file mode 100644 index 74792ae77..000000000 Binary files a/src/test/resources/sampleApps/TheApp-release.apk and /dev/null differ diff --git a/src/test/resources/testData.json b/src/test/resources/testData.json index 1aa09a593..d3fc07b5e 100644 --- a/src/test/resources/testData.json +++ b/src/test/resources/testData.json @@ -8,5 +8,6 @@ "firstName": "Eot", "lastName": "Testing" } - } + }, + "dev": {} } \ No newline at end of file