Skip to main content

Mobile Adaptor

Introduction

This adapter is used to use and interact with android devices, including both physical devices and emulators.

Configuration

All the configuration needed is on the “Computer Setup for H-TEST use” guide.

Initialization Parameters

  • Device: Nexus7 or custom. Choose custom if you are not using Nexus as an Emulator.
  • Device Json Capabilities: here you need to input your device Json capabilities. It is the same as the ones in Appium.
  • URL HUB: this is the URL for your hub. http://localhost:4723/wd/hub is the default.
  • URL Browser: this is where you put the URL you want to search for if you want to use a browser.
  • Validate insert values: validates the values, checks if they are the same that were inserted.
  • Full Screenshot: to take a complete screenshot.
  • Incognito mode: to start the browser in incognito mode.

Functions

  • activateApp(App package): Thisthis function activates (brings to the foreground) the application that was specified and is not currently active, or running on the background. You specify the app package in the parameter.

  • clear(Element): Clearsclears the value of the element.

  • clearAndType(InputElement): Clearsclears the value of the element, and writes below.

  • clearNotificationBar: Clearsclears messages from the notification bar. Optional Xpath parameter to clean button.

  • click(Element): Clicksclicks on a specific element.

  • clickLink(Element): Clicksclicks on an element that is a link.

  • closeAllWindows(): Closescloses all open windows.

  • closeApp(): Closescloses the application.

  • countElements(Element): Countscounts found elements html and saves value to integer variable. The parameter is Element, with this we can indicate which part of the html the user wants to count, for example, if the user want to count the elements of the body, the body will be the parameter.

  • executeBridgeMobileCommand(Command): Executeexecute ADB shell commands on Appium (e.g. adb uninstall package). Link for useful ADB commands: https://www.inviul.com/adb-commands/. This function is recommended for advanced users.

  • executeMobileCommand(CommandName, JSONArguments): Itit is used to execute mobile commands, such as batteryInfo, swipe, drag, etc. Allows the use of JSON arguments.

  • getAttribute(Element, Attribute): Getsgets the text, value or attribute from the element and stores it in a variable.

  • getNotificationText(): Getsgets the notification text from the notification area. Optionally, removes notifications from this area.

  • installApp(appPath): Installsinstalls an application. The specified .apk file has to be a path on your PC.

  • isAppInstalled(appId): Checkschecks if an application is installed.

  • isExist(Element): Checkschecks if the element exists and prints result on user log file. The input parameter Element will be the element the function has to check.

  • javascriptExecuteWithParameters(code, argument): Allowsallows the execution of custom Javascript Code during the test, with the values as parameters.

  • networkSettings (wifi, data, airplanemode): Setssets the network configuration of the device. The parameters allow you to enable or disable Wifi, data and airplane mode. Data can only be enabled and disabled on rooted devices or emulators. Airplane mode only works on OS 6.0 and below.

  • openUrl(String URL): Opensopens the specified URL in a browser.

  • pressBack(): Pressespresses the “Back” button on the device.

  • pressHome(): Pressespresses the “Home” button on the device.

  • pressOverview():  Pressespresses the “Menu” (app overview) button on the device.

  • removeApp(appId): Uninstallsuninstalls the specified application from the device.

  • runAppInBackground: Runrun the application in the background.

  • scrollToElement(Element): Scrollsscrolls up or down to the specified element.

  • select:

  • sendSMS(Phone number, Text): Sendssends an SMS to the device. Only works in emulator.

  • startApp(appPackage, appActivity): Launcheslaunches the specified application.

  • submit(Element): Clickclick on the element and send the form.

  • swipeScreen(): Dragdrag the screen in one direction. Accepts duration, number of times to drag, and start and end coordinates.

  • switchToNativeApp(): Switchesswitches to Native App mode.

  • switchToWebView(): Switchesswitches to Web View mode.

  • terminateApp(identifier, JSONArguments): Closescloses the specified application. Accepts JSON arguments.

  • type(InputElement): Addsadds the typed value to the already existing value of the element.

  • validateAttribute(Element, Attribute, Operator, Value to validate): Validatesvalidates element attributes like: id, class, href, size, width, value, text … etc. Print result on user log file.

  • waitFor(Time in seconds): Waitswaits for the specified time in seconds.

  • waitForElement(Time in seconds, Element): Thisthis function waits for the specified item to appear on the screen.