# Mobile Testing Tutorial
# Introduction
Now that you've set up your mobile environment, it's time to run some tests!
# Prerequisites
- Gondola Studio
- Setup a mobile environment
# Creating the project
To create a new Gondola project click the Gondola Studio icon in VSCode, then click the Create New Project icon.
Select your project's location
Select the [Gondola-Appium] Blank project template
Input your
gexpenses
as the name then hit EnterGondola Studio will create a folder for the project
Explorer will open for you to begin working on your project
TIP
When you create a new project, Gondola Studio calls the command-line tool npm -i
to install the Gondola FW and download all of its required dependencies. If you have downloaded them before, don't worry if you see downloading... in the status bar. NPM copies the files from an offline cache if there is nothing that needs to be updated.
TIP
If you get an Unsupported engine
error while Gondola is attempting to download dependencies, it indicates that your version of Node.js is not compatible.
We recommend using Node Version Manager
to manage your Node.js version. Follow the steps below to install it:
After installing the latest Node.js LTS version, you can check the Node.js version and install the project's dependencies by running the command below:
node -v
npm i
# Setting up your project
- Make a copy of
gondola.json
and rename it togondola.android.json
- Open
gondola.android.json
and set theapp
field tohttps://storage.gondolatest.com/public/sample/gexpenses-1.0.2.apk
- Next, create another folder name
src
in the project root. - Inside the
src
folder, create a folder namedtests
WARNING
If you're using a device running Android <=8.1 you'll need to add the flag: "appWaitForLaunch": false
to the desiredCapabilities
section of your gondola.json
. This is an issue with Expo.
# Writing your first test
In the field marked description, enter Functionality Test
# Starting TestBuilder
- Start your emulator or connect your device.
Tip
If you're using a real Android Device, make sure you've enabled USB debugging
- Start an Appium server
- Click the
TestBuilder icon. After starting TestBuilder the Create new session dialog will open
- Select
gondola.android.json
as the capabilities file.
- Select
# Using TestBuilder
After TestBuilder has finished initializing, you'll see the G Expenses app on your Device Live Screen
- In the Test Cases section you should see one blank
Test Case
. Entercheck tabs
in the description field - On the Device Live Screen, right click on the text in the header that says "Expenses".
- When the context menu appears click
wait for element
. For the number of seconds enter10
. You'll see a new row in the test case with this keyword and the locator information for the text
Did you know?
Gondola uses a smart wait; the number of seconds you specify with wait for element
is the maximum number of seconds Gondola will wait. If the element appears sooner, Gondola will stop waiting.
- Now right click the header again and search for
check text
. Enter "Expenses" for text to check for.
- Now that we've checked for the Expenses tab, let's check that the other tab works.
- Right click the
dashboard icon at the bottom of the screen, and click tap.
- Wait for the screen to refresh and then left-click the Dashboard header and click
wait for element
and enter10
seconds. - Then check that the header's text says "Dashboard" Your test case should look like this:
# Saving and running your test
There are two ways to run your test, with the execution dialog or via the command line. In this tutorial we'll use the execution dialog.
- Press the
save button. Type
expenses_test
and press enter. - After saving your test, click the run button to open the test execution dialog.
- Select
gondola.android.json
as the capabilities file. - Press the
Run
button
# Viewing the results
After running your test the results will pop up in your default browser.
TIP
By default, Gondola uses Mochawesome as test reporter, however you can use other test reporters with Gondola. Click here for more.
# Adding a Second Test Case
Now that we've checked that the different tabs exist, let's test some functionality. We'll add an expense and check that it's shown.
# Creating a new Test Case block
- Click the add new row button in the bottom row to create a new blank row.
- Enter "Test Case" in the first cell of the new row.
- In the description field write add expense
# Navigate back to the Home Tab
For our next Test Case we need to go back to the Home Tab, but we don't want to add this to the Test Case.
- Click the Inspection/Interaction Mode button in the bottom of the Device Live Screen.
- It should be blue
, click it to enter Interaction Mode
- In
Interaction Mode, press the
Home button in GExpenses to navigate back to the
Expenses
tab - Now we want to add actions so switch back to Inspection Mode by pressing the button again. It should turn blue
# Adding and Checking an Expense
- Right click on the Header and use
wait for element
and enter10
seconds. - Right-click the
+
button in the top corner of the Home tab and select the tap action - When the
Add Expense
screen appears, right-click theDescription
field and selectwait for element
, enter10 seconds
. - Then right click the same
Description
field again and selectenter
and enterCoffee
- Now right-click on the date field and select
tap
- When the date picker pops up, use tap to select today's date, then use tap on the ok button.
- Use the
enter
action to enter3.00
in theprice
field. - Right-click the
Add Expense
button and selecttap
. - After the screen refreshes you should see an item list that says
Coffee
under a section labeledToday
with a price that says$3.00
. - Right click on the list item, and select
wait for element
and input10
as the number of seconds - Right click on the text that says
Coffee
and selectcheck text
. EnterCoffee
- Right click on the text that says
$3.00
and selectcheck text
. Enter$3.00
- Save the test and run it.
# Save and Run your test
- Press the save button
- Click the run button to open the test execution dialog.
- Select
gondola.android.json
as the capabilities file. - Press the
Run
button