Repeato
  • Features
  • Pricing
  • Blog
  • Resources
  • Get for free
  • Getting started
  • Running test batches
  • Reporting
  • Test devices
  • Screenshot testing
  • Test exception handling
  • Tags
  • Automate switching devices
  • Advanced Configuration
  • Test workspaces
  • Advanced testing techniques
  • JavaScript API
  • Share tests within the team
  • Continuous Integration Support

Advanced testing techniques

Advanced software testing concepts can save you significant time and energy. Repeato helps you improve your testing processes.

Building a test from building blocks

Ever wondered how tests could be created without repeating yourself? Test automation makes it possible to record tests and re-use them as you like – a huge advantage of automated vs. manual testing.

In this video, we show how you can divide your tests into reusable parts. We will also cover some of the scripting possibilities of Repeato and show why it can be useful to make test steps optional. Our subject under test is the “Asana” to-do list app. We will test creating to-do’s.

Video content

  1. Automate navigation to the right screen
  2. Automate creating a todo
  3. Automate the deletion of all todos
  4. Putting everything together into a single test

Scripting

Here is an example of a more complex automation case. We automate a game (power pop bubbles) with a couple of optional “check content steps” and with some lines of code.

Check out the detailed code described below.

Defining a function which can be used in other steps

When you define a function, usually it is only accessible inside the same step. We want to call our function in other steps, so what we need to do is to use one of the longer living objects for storing the function. data is such an object and we can define a function like this:

data.checkLastMatchAndShoot = async function() {
   // myCode goes here
}

We add async because we are using asynchronous code inside of our function. Basically, all functions which are used with await, need to be wrapped in async functions. Otherwise our script will fail. You can read more about async / await here.

Fetching the result of the last executed step

After executing an optional step, we can check in our script if the returned result was successful. We can access the last step execution result via testRunner.lastStepResult.
There is also a way to check how many matches there were (how many times was the object found):
testRunner.lastStepResult.matches.length
So if there were no matches, meaning that there were no balls of a certain color found, we just return.

Otherwise, we sort the matches from top to bottom. This is going to be important because we need to distinguish between the ball in the launcher and the balls in the game field above.
We do this by checking the y position value of the match:

// if y position of last match is lower than 70% of the screen height
if(lastMatch.position.y > 0.7)

Shooting the ball into the right direction

So if we found a ball in a certain color we need to know in which direction to shoot right?
We do this by checking the result set of matches and take a closer look at the previous match (the one right above the ball in the launcher)

const oneBeforeLastMatch = matches[matches.length - 2]

We can use this match to define the direction for our shoot. To shoot we instruct a drag gesture from the ball in the launcher to the ball of the same color right above.

To get the big picture, here is the whole code:

data.checkLastMatchAndShoot = async function() {
  var matches = testRunner.lastStepResult.matches
  if(matches.length === 0){ // no ball of this color found
    return false
  }

  // we sort the matches from top to bottom
  matches = matches.sort((match1, match2) => match1.position.y - match2.position.y)
  // get the most bottom match
  const lastMatch = matches[matches.length - 1]
  
  // if most bottom match is not in the field, but at the very bottom, this means that it is inside the launcher
  if(lastMatch.position.y > 0.7) { 
    const oneBeforeLastMatch = matches[matches.length - 2]
    testRunner.deviceConnector.sendDown(lastMatch.position.x, lastMatch.position.y)
    await sleep(1000)
    testRunner.deviceConnector.sendMove(oneBeforeLastMatch.position.x, oneBeforeLastMatch.position.y)
    await sleep(1000)
    testRunner.deviceConnector.sendUp()
    return true
  } else {
    return false
  }
}

Repeato

  • Home
  • Pricing
  • Blog
  • FAQ
  • About us

Documentation

  • Getting started
  • Test exception handling
  • Advanced testing techniques
  • JavaScript API
  • Release notes

Support

  • Support & Resources
  • Documentation
  • Book a demo
  • Contact

Legal

  • Imprint
  • Terms & Conditions
  • Privacy policy
Repeato Reviews
[activecampaign form=5 css=0]
Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage {vendor_count} vendors Read more about these purposes
View preferences
{title} {title} {title}