Skip to content
This repository has been archived by the owner on Oct 28, 2024. It is now read-only.

8 ‐ Automation of tests

Pierre-Yves Lapersonne edited this page Oct 28, 2024 · 1 revision

Automation of tests

For what things?

So as to improve quality of sources or products, you may apply principles of Test-Driven-Development (TDD), Behaviour-Driven-Development (BDD) or DevOps with continous integration (#buzzwords ^_^)

You may use Robot Framework, a powerful tool which provides API to describe test cases.
Robot Framework works well with other tools like Appium if you want to process tests in mobile or web apps.

It is also possible to use the Tapster robot in such tests: you just have to include the wrapper: it provides high level Robot Framework keywords which gather Tapster-dedicated and Appium-dedicated keywords. It will avoid you to know on which (X,Y) coordinates you have to tap by allowing you to tap on "this button" or "the widget with that id".

Set up

If you want to use the Tapster robot in automated tests processes, you have to follow the steps below.

  1. Install the dependencies for Robot Framework
  pip install -U robotframework-appiumlibrary
  pip install -U requests
  pip install -U robotframework-requests
  1. Calibrate the robot for the tested device. You can save the output calibration file to use it later

  2. Start the Appium server which will look in the tested app to get widgets, locations, etc

   appium
  1. Start the Node.js server of the robot, which will receive the HTTP requests
   node server.js --calibration path-to-calibration-file

Use of keywords

You will be able to use the keywords of the tapster_wrapper.robot file. You just have to include as a Resource the file in your tests cases script. Be aware this library uses the config.robot and the tapster_keywords.robot files, keep on eye on their paths.

Keywords Parameters Description
Tap To Point x y offset_x (opt,=0) offset_y (opt,=0) Tap to a point using 2D coordinates based on device's screen 2D landmark
Tap To Element With Id id offset_x (opt,=0) offset_y (opt,=0) Tap to the widget which have this id, using or not offsets, at the center of the widget
Tap To Element With Text text offset_x (opt,=0) offset_y (opt,=0) Tap to the widget which have this text, using or not offsets, at the center of the widget
Tap To Element With Xpath xpath_locator offset_x (opt,=0) offset_y (opt,=0) Tap to the widget reached using this XPath locator, using or not offsets, at the center of the widget
Tap To Element N Times With Id N id offset_x (opt,=0) offset_y (opt,=0) Tap N times to the widget which have this id, using or not offsets, at the center of the widget
Tap To Element N Times With Text text id offset_x (opt,=0) offset_y (opt,=0) Tap N times to the widget which have this text, using or not offsets, at the center of the widget
Tap To Element N Times With Xpath N xpath_locator offset_x (opt,=0) offset_y (opt,=0) Tap N times to the widget which can be found using this XPath locator, using or not offsets, at the center of the widgets
Tap Somewhere To Element With Id id offset_x (opt,=0) offset_y (opt,=0) Tap somewhere to the widget which have this id, using or not offsets, using a random position
Tap Somewhere To Element With Text text offset_x (opt,=0) offset_y (opt,=0) Tap somewhere to the widget which have this text, using or not offsets, using a random position
Tap Somewhere To Element With Xpath xpath_locator offset_x (opt,=0) offset_y (opt,=0) Tap somewhere to the widget which can be found with this XPath locator, using or not offsets, using a random position
Long Tap To Point x y duration offset_x (opt,=0) offset_y (opt,=0) Make a long tap using 2D coordinates based on device's screen 2D landmark
Long Tap To Element With Id text offset_x (opt,=0) offset_y (opt,=0) Make a long to the widget which have this id, using or not offsets, at the center of the widget
Long Tap To Element With Text text offset_x (opt,=0) offset_y (opt,=0) Make a long to the widget which have this text, using or not offsets, at the center of the widget
Long Tap To Element With Xpath text offset_x (opt,=0) offset_y (opt,=0) Make a long to the widget which have this XPath locator, using or not offsets, at the center of the widget
Double Tap To Point x y duration offset_x (opt,=0) offset_y (opt,=0) Make a double tap using 2D coordinates based on device's screen 2D landmark
Double Tap To Element With Id text offset_x (opt,=0) offset_y (opt,=0) Make a double to the widget which have this id, using or not offsets, at the center of the widget
Double Tap To Element With Text text offset_x (opt,=0) offset_y (opt,=0) Make a double to the widget which have this text, using or not offsets, at the center of the widget
Double Tap To Element With Xpath text offset_x (opt,=0) offset_y (opt,=0) Make a double to the widget which have this XPath locator, using or not offsets, at the center of the widget
Triple Tap To Point x y duration offset_x (opt,=0) offset_y (opt,=0) Make a triple tap using 2D coordinates based on device's screen 2D landmark
Triple Tap To Element With Id text offset_x (opt,=0) offset_y (opt,=0) Make a triple to the widget which have this id, using or not offsets, at the center of the widget
Triple Tap To Element With Text text offset_x (opt,=0) offset_y (opt,=0) Make a triple to the widget which have this text, using or not offsets, at the center of the widget
Triple Tap To Element With Xpath text offset_x (opt,=0) offset_y (opt,=0) Make a triple to the widget which have this XPath locator, using or not offsets, at the center of the widget
Stresstap To Element With Id N id offset_x (opt,=0) offset_y (opt,=0) Tap N times very quickly to the widget which have this id, using or not offsets
Stresstap To Element With Text N text offset_x (opt,=0) offset_y (opt,=0) Tap N times very quickly to the widget which have this text, using or not offsets
Stresstap To Element With Xpath N xpath_locator offset_x (opt,=0) offset_y (opt,=0) Tap N times very quickly to the widget found with this XPath locator
Swipe a b c d offset_x (opt,=0) offset_y (opt,=0) Swipe from (a,b) to (c,d) using or not Offsets
Swipe N Times N a b c d offset_x (opt,=0) offset_y (opt,=0) Swipe N times from (a,b) to (c,d) using or not offsets
Swipe Using Elements Id source_id destination_id offset_x (opt,=0) offset_y (opt,=0) Swipe from an element to another using their ids
Swipe Using Elements Text source_text destination_text offset_x (opt,=0) offset_y (opt,=0) Swipe from an element to another using their text contents
Swipe Using Elements Xpath source_xpath destination_xpath offset_x (opt,=0) offset_y (opt,=0) Swipe from an element to another using XPath locators
Swipe N Times Using Elements Id N source_id destination_id offset_x (opt,=0) offset_y (opt,=0) Swipe N times from an element to another using their ids
Swipe N Times Uusing Elements Text N source_text destination_text offset_x (opt,=0) offset_y (opt,=0) Swipe N times from an element to another using their text contents
Swipe N Times Using Elements Xpath N source_xpath destination_xpath offset_x (opt,=0) offset_y (opt,=0) Swipe N times from an element to another using XPath locators
Stress Swipes N a b c d offset_x (opt,=0) offset_y (opt,=0) Swipe very quickly N times from (a,b) to (c,d) using or not offsets
Stress Swipes Using Elements Id N source_id destination_id offset_x (opt,=0) offset_y (opt,=0) Swipe N times very quickly from an element to another using their ID
Stress Swipes Using Elements Text N source_text destination_text offset_x (opt,=0) offset_y (opt,=0) Swipe N times very quickly from an element to another using their text values
Stress Swipes Using Elements Xpath N source_xpath destination_xpath offset_x (opt,=0) offset_y (opt,=0) Swipe N times very quickly from an element to another using XPath locators
Reset Reset position of the robot's arms
Draw Random Pattern n minWidth minHeight maxWidth maxHeight Draws a random pattern with n points, thus n-1 strokes, in a defined area
Draw Star Draws a lovely star
Draw Circle x y r Draws a circle centered on (x,y) with r radius
Draw Cross x1 y1 x2 y2 x3 y3 x4 y4 Draws a cross with two strokes: one from 1 to 4, the other from 2 to 3
Draw Square n (opt, =2) length (opt, =30) Draws a square with a dedicated length and a ratio of points to draw
Draw Triangle x1 y1 x2 y2 x3 y3 Draws a triangle using 3 points
Draw Spiral x y n r Draws a spiral center on (x,y) point with n loops and an r radius

Notes

  1. Offsets are optional parameters with a default value defined to 0
  2. Widgets in landscape mode do not have the same coordinates as in portrait mode, but robot cannot make the difference Thus we need to convert coordinates if we are in landscape mode. AppiumLibrary for Robot Framework does not provide the suitable keywords. So we need today to hardcode the coordinates to use for landscape-displayed widgets.
  3. Some devices have Hall effect sensors, thus the finger of the robot can disturb magnetic field and make screen closed...
  4. If we want to tap on a widget according to a text or an id, if we have several matching occurences, only the first will be used.

Missing some keywords? Feel free to make pull requests!