Text methods
1 - Introduction
2 - List of text input commands
3 - Use case
Use case 1 : Fill a form
The Kwit application login form contains an "Email" field that can be accessed with its text and Android class.
Be careful, the text above “Sign in with your Email” contains also the text “Email”.
To select the form field, use the clickByTextExact
function or access to it with its Android class: android.widget.EditText.
It is therefore possible to use the formClickOnEditText
function with the position of the text field as a parameter. If no parameter is supplied, the first field is selected by default.
There's also the formClickOnFirstEmptyEditText
function, which can be used to select the first empty text field. This is not useful in our case, as the "Email" field is already pre-filled.
This is what you get after entering your email address:
Then pressTab
to move on to the next field.
Example :
### Quick preparation of the device
applicationStart,fr.kwit.android
waitUntilText,Already an account
# Click on the element "Already an account"
clickByText,Already an account
waitUntilText,Sign Up
# Click on the element "Other Sign in methods"
clickByPercent,50,85
waitUntilText,Other Sign in methods
# Click on the element "Email"
clickByPercent,50,92
waitUntilText,Sign in with your Email
### Fill the form
measureStart,ACTION_loginPage_fillForm
formClickOnEditText
enterText,test@gmail.com
pressTab
enterText,12345678
pause,${PAUSEAFTERLOAD}
measureStop
Use case 2 : Fields are not accessible via their text, id or description
The website https://www.sante.fr contains fields that are not accessible via their text, description or identifier.
However, both fields have the following Android class: android.widget.EditText.
You can use the GDSL function formClickOnFirstEmptyEditText
which clicks on the first empty text field.
Example :
### Quick preparation of the device
setBrowser,chrome
launchBrowser
browserClearCache
browserCloseAllTabs
browserNewTab
browserGoToUrl,https://www.sante.fr
pressEnter
# Accept cookies
waitUntilText,Tout accepter
clickByText,Tout accepter
waitUntilText,L'information fiable
### Fill the form
measureStart,ACTION_homePage_fillForm
formClickOnFirstEmptyEditText
enterText,pediatre
pressTab
enterText,Hauts-de-Seine
pause,${PAUSEAFTERLOAD}
measureStop
After the enterText function, do not write special or accented characters, as they are not taken into account.