Best practices and tips
1 - Process of script writing
We recommend that you add the steps to your test file progressively:
Add the
startMeasure
keyword,Step name
to the test fileAdd the GDSL instruction(s) for composing the step (e.g. click)
Identify a text on the application that should appear at the end of the action or load
Add the expected text with a wait keyword
Add the
stopMeasure
keyword to end the measurementLaunch the test
Continue like that step by step
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.
The .vsix extension for VS Code guides in that process and help avoiding errors.
2 - Tips for automation
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 App. In job.yml file,
Replace
online: true
byonline: false
to avoid unnecessary measurements to appear in Greenspector App
If you want to see detailled results on App, 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é : waitUntilByTextBeforeClick,OK,true
3 - GDSL best practices
Prepare the measuring web environment with
browserPrepareAndOpenForReference
-> allows to clean cache and tabs
Name steps with camelCase naming convention
Do not use “/” in step name : measures will not be sent
On loading, wait (
waitUntil
) for the last element to be displayedBefore a loading measurement, check that the expected element (
waitUntil
) is not already present : (assertNotExists
)Waiting for the exact element:
waitUntilTextExact
A pause step follows each loading step.
A
PAUSEAFTERLOAD
pause of 1000 ends the loading and action stepsA
PAUSEAFTERACTION
pause of 500 is placed after each action command (unless there is aPAUSEAFTERLOAD
afterwards). This certifies that the steps are at least one second long.A
PAUSEAFTERSCROLL
pause of 500 is placed after each scroll or swipe command (unless after aPAUSEAFTERLOAD
)
Tag priorities: text/description > id > class > package
If it's not possible to find the element via these tags, use the tree method (parent/child)
If the above methods are not possible, use XY
When scrolling,
swipeVertical
is preferable toscrollDownward
andscrollUpward
, 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.
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 has to be done this way.