Table of Contents |
---|
...
Status | ||||
---|---|---|---|---|
|
Table of Contents |
---|
Process of script writing
✅ We recommend that you add the steps to your test file progressively:
...
Note: The step for measuring residual loads is necessary because resources are used even if the view is present (end of loading of certain page elements, scripts...). In this case, the line pause,${PAUSEAFTERLOAD} is used.
Infotip |
---|
The .vsix extension for VS Code guides in that process and help avoiding errors. |
2 - Tips for automation
. |
## Add meaningful comments to the code :
At the beginning of the script, give a brief description of the scenario
When using a
ClickByXY
orClickById
command, indicate the action performed by this command.When using an if, while or find command. Specify the purpose of the use.
When a manipulation is out of the ordinary (need for manual intervention, out-of-measure processing, abnormal pause, etc.) Explain the manipulation in question and why it must be carried out in this way.
Tips for automation
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
Switch the terminal in English because the testbench terminals are in English. |
🚀 To go faster during the writing of script and test part, modify the job.yml file:
Replace
PAUSEDURATION: 30000
which configures the time of a pause step, byPAUSEDURATION: 1000
config-skipsetupphone: true
allows to skip device preparation at the beginning of the testCommand
testrunner testdslcommand -c "clickBy..."
allows you to run a single command without restarting an entire script.--dd
or--disable-dumpsys
to delete the dumpsys iteration with the CLI. Be careful to remove this option for final measurements.
📨 Each time you launch a test, it is sent on Greenspector server by default. During the automation phase, it is not necessary to sent data on the Greenspector Appweb interface. In job.yml file,
Replace
online: true
byonline: false
to avoid unnecessary measurements to appear in Greenspector Appthe web interface
If you want to see detailled results on AppGreenspector Studio, set this parameter at true and create a test version not to mix them with official measures.
Parfois, il existe des éléments présents seulement au premier affichage d’un écran. Cela peut poser problème dans le cas où plusieurs tests sont effectués sur la même application.
Ainsi, nous vous conseillons d’utiliser les commandes suivantes : Les "waitUntilBeforeClick"
WaitUntilByTextBeforeClick
WaitUntilByDescBeforeClick
WaitUntilByTextExactBeforeClick
WaitUntilByIdBeforeClick
Le second paramètre de ces méthodes est un booléen optionnel qui permet s’il est à true de ne pas faire échouer le test sur cette instruction même si elle est fausse. La valeur par défaut de ce paramètre est false.
Ce test échouera si "OK" n'est pas trouvé : waitUntilByTextBeforeClick,OK
Ce test continue à la prochaine instruction si "OK" n'est pas trouvé ❓ Sometimes there are elements that are only present on the first display of a screen. This can cause problems when several tests are run on the same application.
We therefore recommend that you use the following commands: The "waitUntilBeforeClick
"
waitUntilByTextBeforeClick
waitUntilByDescBeforeClick
waitUntilByTextExactBeforeClick
waitUntilByIdBeforeClick
The second parameter of these methods is an optional Boolean which, if set to true, prevents the test from failing on this instruction even if it is false. The default value of this parameter is false.
This test will fail if “OK” is not found: waitUntilByTextBeforeClick,OK
This test continues on the next instruction if “OK” is not found: waitUntilByTextBeforeClick,OK,true
...
GDSL best practices
🌐 Prepare the measuring web environment with browserPrepareAndOpenForReference
...
which cleans and closes open tabs. Next, an all-black page is opened (https://dl.greenspector.com/black/), which will be used as the reference measurement for the web.
🐪 Name steps with camelCase naming convention (example : CHRGT_homePage
)
Do not use “/” in step name : measures will not be sent
On loading, wait
Enter the view name in the step name:
CHRGT_[viewName]
In the case of an action step, we recommend using a name of the form ACTION_[viewName]_[actionName] (example: ACTION_homePage_writeSearch)
SCROLL_[ viewName]
PAUSE_[viewName]
💬 When loading a new view :
Wait (
waitUntil
) for the last element to be displayed. This command can also be used to detect the success of an action (if this leads to a change in the display).It is recommended that you wait for the exact element:
waitUntilTextExact
In all cases, use
waitUntilPageLoaded
as a last resort. Not all data is loaded after this function. This depends on the quality of the network. It is preferable to use a function such aswaitUntilText
orwaitUntilId
.
Before proceeding with a loading load measurement, check that the expected element (
waitUntil
) is not already present: (assertNotExists
)Waiting for the exact element:waitUntilTextExact
⏸️ Values of pause steps :
A pause step follows each loading step. It then has a
PAUSEDURATION
duration of 30000 ms. This type of pause can also be used to measure the inactive state of a digital service.A
PAUSEAFTERLOAD
pause of 1000 ends ms at the end of the loading and action steps/scroll stages.A
PAUSEAFTERACTION
pause of 500 ms is placed after each action command (unless there is except before aPAUSEAFTERLOAD
afterwards pause). This certifies ensures that the steps are last at least one second long.A
PAUSEAFTERSCROLL
pause of 500 ms is placed after each scroll or /swipe command (unless after except before aPAUSEAFTERLOAD
pause)Tag priorities.
🔢 Priorities of element detection tag : text/description > id > class > package
If it's not possible to find the element via these tags, use the tree method (parent/child)
- If
Only if the above methods are not possible, use XY or Percent (and specify the element clicked as a comment).
↕️ When scrolling, swipeVertical
is preferable to scrollDownward
and scrollUpward
, as it is more precise. For even greater precision, you can add a 4th parameter with the swipe time (default 500 ms).
...
Test as you automate
Add meaningful comment to your code
...
At the beginning of the script, give a short description of the scenario
...
When using a ClickByXY or ClickById, indicate the action performed by this command.
...
When using an if, while or find command. Specify the purpose of use.
...
For more information, see scroll documentation.
Note |
---|
The swipeVertical function does not exist on iOS. Instead, there are the scrollDown, scrollUp and swipe functions. |
🍪 On the web in particular, accept cookies in a separate measure:
Code Block |
---|
measureStart,CHRGT_homePageAfterCookies
clickByText,accept all
waitUntilText,Actu
pause,${PAUSEAFTERLOAD}
measureStop
measureStart,PAUSE_homePageAfterCookies
pause,${PAUSEDURATION}
measureStop |
👇 The clickByText
function searches by text, then by description. It is therefore useful when the description is accessible.
📋 When filling in forms :
The
pressBack
function can be used to deactivate the keyboard. It can also be used to exit full-screen mode for videos.If fields are not accessible by their text, description or identifier, you can use the
clickOnFirstEmptyEditText
function. This selects the next empty text field.After the
enterText
function, do not enter any special or accented characters, as they are not taken into account. This function can also invert numbers when filling in a telephone number in a field. To get round this problem, you can use functions starting with setText.
Panel | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
iOS specifics
|