Skip to content

Java Utility Classes

Tal Abraham edited this page Nov 14, 2016 · 1 revision

##Introduction The Quantum framework supplies a set of Utility classes that provide static methods that are used to execute basic test steps in your java-coded tests. The methods are organized into two basic classes of functionality:

  • Application level methods are defined in the ApplicationUtils class.
  • Device focused methods are defined in the DeviceUtils class.

ApplicationUtils class

The ApplicationUtils class is a static Java class that provides static methods to perform the basic application level control and verification steps of the application user-interface. The methods provided include:

  • installApp - installs an application from the Perfecto Repository to the device, optionally applying instrumentation.
  • startApp - starts the installed application, identified by name or package name.
  • closeApp - stops the named application (display name or package name), if currently running. If application is not running, no action is taken.
  • cleanApp - resets the named application (display name or package name).
  • uninstallApp - uninstall a manually installed application, identified by name or package name. Does not affect built-in applications.
  • uninstallAllApps - uninstalls all applications that were manually installed on the device. Does not affect built-in applications.
  • getAppInfo - retrieve the value of a particular application property.

Verification and Assertion methods

  • verifyAppInfo - verifies that the particular application property has a specific value.
  • assertAppInfo - asserts the value of a particular application property has a specific value.
  • verifyVisualText - verifies that specific text appears.
  • assertVisualText - applies an Assertion that specific text is displayed on the screen.
  • isText - applies a visual checkpoint that specific text is displayed.
  • waitForPresentTextVisual - applies a visual checkpoint that specific text is displayed within a timeout period.
  • verifyVisualImg - verifies that specific image appears.
  • assertVisualImg - applies an Assertion that specific image is displayed on the screen.
  • isImg - applies a visual checkpoint that specific image is displayed.
  • waitForPresentImsageVisual - applies a visual checkpoint that specific image is displayed within a timeout period.

Context methods

  • switchToContext - changes the execution context to either NATIVE_APP, VISUAL, or WEBVIEW.
  • getCurrentContext - retrieves the current context setting of the test.

DeviceUtils class

The DeviceUtils class is a static Java class that provides static methods to perform basic device level automation actions. These include:

  • pressKey - clicks on a single or sequence of physical device keys.
  • swipe - performs the swipe gesture according to the start and end coordinates.
  • touch - performs the touch gesture according to the point coordinates.
  • hideKeyboard - hides the virtual keyboard display.
  • rotateDevice - rotates the device to landscape, portrait, or its next state.
  • goToHomeScreen - switches the device display to the device home screen.
  • lockDevice - puts the device into lock mode.
  • takeScreenshot - takes a screenshot of the device display and stores it in the Perfecto Repository.

Location operations

  • setLocation - changes the location setting of the device to a specified address or latitude/longitude.
  • getDeviceLocation - retrieves the current location setting of the device.
  • resetLocation - cancels the device location setting, returns the device to its current physical location.
  • verifyLocation - verifies that the location is set to the specific location.
  • assertLocation - applies an Assertion that location is set to a specific location.

Timezone operations

  • setTimezone - changes the timezone setting of the device to a specified address or latitude/longitude.
  • getTimezone - retrieves the current timezone setting of the device.
  • resetTimezone - cancels the device timezone setting, returns the device to its default timezone.
  • verifyTimezone - verifies that the timezoneis set to the specific timezone.
  • assertTimezone - applies an Assertion that timezone is set to a specific timezone.

Clone this wiki locally