UI Testing

UI Testing

    UI tests is compromised of Web and Mobile ( Android, iOS, Win) tests
    Test are written similarly, using the same structure for all UI platforms ( Web, Mobile )

Writing UI Tests

Setup Property File

Web:

    Set app url at Web.property and browser type
    1
    webApp="http://demo.autonomx.io/admin/"
    2
    web.browserType = CHROME
    Copied!

Android

    Set app apk file, dir, and simulator, or UDID (real device) at android.property
    1
    # Android
    2
    android.app = "selendroid.apk"
    3
    android.appDir = "resources/"
    4
    android.mobile = "Pixel_2_XL_API_25"
    5
    android.tablet = "Pixel_2_XL_API_25"
    6
    7
    # udid for real device
    8
    android.UDID = ""
    Copied!

iOS

    Set app file, directory, mobile name or UDID (real device) at ios.property
    1
    #iOS
    2
    ios.app = "eurika.app"
    3
    ios.appDir = "resources/"
    4
    ios.mobile = "iPhone 7"
    5
    ios.tablet = "iPad Air 2"
    6
    7
    # udid for real device
    8
    ios.UDID = ""
    Copied!

Win

    Set app path at win.property
    1
    #win
    2
    win.app = "Microsoft.WindowsCalculator_8wekyb3d8bbwe!App"
    Copied!

Set Test Data ( Optional )

    If test case requires data, such as user information for login, we can add test data using 3 different methods:
      Data Provider: For running same test cases with different data sets
      Csv Test Data: Test data stored in external csv file
        Advantage:
          External storage of data sets
          Easier to create and group
        Disadvantage: Less flexible than setting data programmatically
      Test Object: Test data stored programmatically in class file
        Advantage:
          Flexible to manipulate data as required
        Disadvantage:
          Data is internal in code

Set Test Panel

    Using page object model, we specify page info in test panel class
    For each page, panel, or feature in our application, we can create a panel
    Panel class includes 2 sections:
      Locator: Specify all page element locators in this section. eg. username field, password field
      Action: All methods/actions associated with page in this section. eg. login method

Write Test Case

Sample Test Class

1
public class VerifyLoginTest extends TestBase {
2
3
@BeforeMethod
4
public void beforeMethod() throws Exception {
5
setupWebDriver(app.webApp.getHybridDriver());
6
}
7
8
@Test()
9
public void verifyAdminUserWithCsvData() {
10
11
User user = Data.webApp.user().admin();
12
TestLog.When("I login with user " + user.getUsername());
13
app.webApp.login.loginWithCsvData(user);
14
15
TestLog.Then("I verify admin logo is displayed");
16
Helper.verifyElementIsDisplayed(MainPanel.elements.ADMIN_LOGO);
17
18
TestLog.When("I logout");
19
app.webApp.main.logout();
20
21
TestLog.Then("I should see the login panel");
22
Helper.verifyElementIsDisplayed(LoginPanel.elements.LOGIN_SUBMIT);
23
}
24
}
Copied!
Last modified 1yr ago