Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Via UIAutomatorViewer

  1. Lancer UiAutomatorViewer

...

  1. Brancher un smartphone (et 1 seul)

  1. Presser le bouton "Device screenshot" :

...

  1. Une capture du smartphone avec la hiérarchie de vues apparaît : 

...

  1. Sur la capture d'écran (à gauche), sélectionner l'élément pour lequel vous souhaitez récupérer un id et récupérer le "resource-id" à droite :

...

  1. Dans notre cas, le bouton "Créer un album partagé" a pour id : com.sec.android.

gallery3d:id/create_button_layout. Cet id pourra être utilisé dans les scripts d'automatisation GDSL du moment qu'il s'agit du seul élément de la hiérarchie de vue à avoir cet id.

Via Accessibility Scanner

Une alternative à UiAutomatorViewer est Accessibility Scanner.

  1. Pour l'utiliser, télécharger l'app sur le Play Store, la lancer et la configurer comme demandé. Plus d'information sur : https://support.google.com/accessibility/android/answer/6376570?hl=en

  1. Aller sur l'écran à automatiser et cliquer sur l'icône d'Accessibility Scanner :

...

  1. Sélectionner ensuite "Instantanné" : 

...

  1. La capture est affichée. Sélectionnez alors l'élément qui vous intéresse et l'id sera affiché en bas : 

...

We don't have a way to export this macro.
Info

This page concerns only measure on android device, if you want to measure on iPhone, you can follow this link:

Lancer un script gdsl avec le testrunner sur iOS (sans mesure physique) 

Table of Contents
minLevel1
maxLevel6
outlinefalse
stylenone
typelist
printabletrue

1. Install UIAutomatorViewer

  • Install Android Studio if you don’t have it

  • Open Android Studio

  • Click on More Actions > SDK Manager (or Tools > SDK Manager if a project is open)

  • Click on the SDK tools tab, uncheck option "Hide Obsolete Packages"

  • Check option “Android SDK Tools” and install version 26.1.1

  • UIAutomatorViewer is now installed in Android SDK directory

  • Add UIAutomatorViewer to your path:

    • On Linux: add the line export PATH=$HOME/Android/Sdk/tools/bin:$PATH in the .bashrc file and run the command "source ~/.bashrc"

    • On Mac: add the line export PATH=$HOME/Library/Android/sdk/tools/bin:$PATH in the .bash_profile file and run the command "source ~/.bash_profile"

    • On Windows: Windows start menu > Settings > System > About > Advanced settings > Environment variables > Path > Modify > Add the path C:\Users\[username]\AppData\Local\Android\Sdk\tools\bin. Replace username by the name of the user.

Info

UIAutomatorViewer needs Java 1.8 by default to work

2. Launch UIAutomatorViewer

Check your java version with the following command:

Code Block
languagebash
java -version

2.1. Launch UIAutomatorViewer without installing Java 1.8

Note

If you use a Mac, please follow the next part.

To avoid installing a different version of Java, you could set environment variables for your PC profile:

Linux

Windows

ANDROID_HOME

Edit the ~/.bashrc file:

export ANDROID_HOME=$HOME/Android/Sdk

Windows start menu > Settings > System > About > Advanced settings > Environment variables > Path > Add:

C:\Users\[username]\AppData\Local\Android\Sdk

Replace username by the name of the user.

JAVA_HOME

Edit the ~/.bashrc file:

export JAVA_HOME=$HOME/android-studio/jbr

If jbr is not present (old version of Android Studio) replace it by jre.

Windows start menu > Settings > System > About > Advanced settings > Environment variables > Path > Add:

C:\Program Files\Android\Android Studio\jbr

If jbr is not present (old version of Android Studio) replace it by jre.

PATH

Edit the ~/.bashrc file:

export PATH=$JAVA_HOME/bin:$PATH

Windows start menu > Settings > System > About > Advanced settings > Environment variables > Path > Modify > Add the path:

$JAVA_HOME\bin

Image Added

After adding the variables, you can open a new terminal (this is important to open a new terminal to take into account the variables you have just set) and use the following command to open UIAutomatorViewer :

On Linux :

Code Block
languagebash
java -Xmx1600M -Dcom.android.uiautomator.bindir="$ANDROID_HOME/tools" -cp "$ANDROID_HOME/tools/lib/x86_64/swt.jar":"$ANDROID_HOME/tools/lib/*" com.android.uiautomator.UiAutomatorViewer  

On Windows :

Code Block
languagebash
java -Xmx1600M -Dcom.android.uiautomator.bindir="%ANDROID_HOME%\tools" -cp "%ANDROID_HOME%\tools\lib\x86_64\swt.jar";"%ANDROID_HOME%\tools\lib\*" com.android.uiautomator.UiAutomatorViewer
  • The following program appears :

...

2.2. Launch UIAutomatorViewer with Java 1.8

Install Java 1.8:

  • On Linux, run the following commands:

Code Block
languagebash
# Install java 8
sudo apt-get install openjdk-8-jdk
# Check java version
java -version
# Update the java default version use by your system (if you have several)
sudo update-alternatives --config java
  • On Mac with Intel chip, run the command below, add the line export PATH=/usr/local/opt/openjdk@8/bin:$PATH in the .bash_profile file and run the command "source ~/.bash_profile":

Code Block
languagebash
brew install openjdk@8
  • On Mac with Mac chip, run the commands below, add the line export PATH=/Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home/bin:$PATH in the .bash_profile file and run the command "source ~/.bash_profile"

Code Block
languagebash
brew tap homebrew/cask-versions
brew install --cask temurin@8
  • On Windows, install Java 1.8 by getting it on the Oracle website. You need to create an account.

Launch UIAutomatorViewer:

  • On Linux and Mac, run the following command:

Code Block
languagebash
uiautomatorviewer
  • On Windows, run the following command:

Code Block
languagebash
uiautomatorviewer.bat

The following program appears :

...

Info

On Mac, interactions may be impossible with UIAutomatorViewer.

If it is the case, do the following steps:

With some Mac, you also have to create a folder called aarch64 next to the folder called x86_64. Then, you have to copy the swt2.jar file into the new folder.

3. Use UIAutomatorviewer

When UIAutomatorViewer is opened, you can

  • Plug your usb on your smartphone

  • Click on button “Device screenshot”

  • A screen capture and a dump of view hierarchy appears on the screen

...

  • On screenshot (left), you can select the element for which you want to retrieve information and find it on the right:

...

  • In this case, the tab “Actu” have the field ‘text’ set with ‘Actu’. So in GDSL we can search the text Actu to find this tab (if there is no other element with the same text in the screen).

  • Each element of a view can be retrieve by field ‘text’, ‘resource-id’, ‘class’ or ‘content-desc’. GDSL commands are made to find an element by searching on this field

    • clickById,exampleid : click on an element which have exampleid in resource-id field

    • waitUntilText,Actu : Wait an element which have ‘Actu’ in text field