Cross Application Testing

Cross Application Testing

    We can test multiple apps together in one test method
    We will need to create the appropriate drivers for each app and run the test actions associated with them

Setup Driver

    1
    WebDriver webDriver = setupWebDriver(app.webApp.getWebDriver());
    Copied!
    Assign the driver to a WebDriver object, so we can switch back and forth between the different apps
    The web browser will now launch

Write Test Steps

    Write required test steps for the app
    1
    TestLog.When("I login with admin user");
    2
    UserObject user = UserObject.user().withAdminLogin();
    3
    app.webApp.login.login(user);
    4
    5
    TestLog.Then("I verify admin logo is displayed");
    6
    Helper.verifyElementIsDisplayed(MainPanel.elements.ADMIN_LOGO);
    Copied!

Switch To Android App

    Switch to driver of a different app
    1
    // switch to android app
    2
    WebDriver androidDriver = setupWebDriver(app.androidApp.getAndroidMobileDriver());
    Copied!
    We switched to an android driver from the "androidApp" module
    The android simulator will now launch

Write Test Steps For Android App

    1
    app.androidApp.main.selectRegisterPanel();
    Copied!
    We are selecting the registration panel in the android app

Switch Back To The webApp

    1
    TestLog.When("I logout");
    2
    app.webApp.main.logout();
    3
    4
    TestLog.Then("I should see the login panel");
    5
    Helper.verifyElementIsDisplayed(LoginPanel.elements.LOGIN_SUBMIT);
    Copied!
    The driver will switch to the web application and continue with the test

All Togather

    1
    @Test
    2
    public void cross_application_test() throws Exception {
    3
    4
    WebDriver webDriver = setupWebDriver(app.webApp.getWebDriver());
    5
    6
    TestLog.When("I login with admin user");
    7
    UserObject user = UserObject.user().withAdminLogin();
    8
    app.webApp.login.login(user);
    9
    10
    TestLog.Then("I verify admin logo is displayed");
    11
    Helper.verifyElementIsDisplayed(MainPanel.elements.ADMIN_LOGO);
    12
    13
    // switch to android app
    14
    WebDriver androidDriver = setupWebDriver(app.androidApp.getAndroidMobileDriver());
    15
    app.androidApp.main.selectRegisterPanel();
    16
    17
    // Switch to web app
    18
    Helper.switchDriver(webDriver);
    19
    20
    TestLog.When("I logout");
    21
    app.webApp.main.logout();
    22
    23
    TestLog.Then("I should see the login panel");
    24
    Helper.verifyElementIsDisplayed(LoginPanel.elements.LOGIN_SUBMIT);
    25
    }
    Copied!
Last modified 2yr ago