Versions Compared

Key

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

The separator character for iOS is the semicolon “,”.

To find the package names to write after “applicationStart”: https://mrvirk.com/how-to-find-app-bundle-id-ios.html.

For more information about commands using predicates, which provides a general means of specifying queries in Cocoa, see https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Predicates/AdditionalChapters/Introduction.html.

Exemple testreference.testgb :

...

aim of the Greenspector Domain-Specific Language is to help writing automated tests by reducing the time to write tests and to avoid using an IDE. Thus non developer people can write automated tests.

Write the commands in a text file with the extension .testgb.

Example test.testgb :

Code Block
languagebash
#Launching the app
measureStart,CHRGT_homePage
applicationStart,com.google.ios.youtube
waitUntilText,Home
pause,5000${PAUSEAFTERLOAD}
measureStop

#Break on home page
measureStart,PAUSEYTPAUSE_homePage
pause,30000${PAUSEDURATION}
measureStop

Application

Command

Parameters

Description

applicationStart

String

appPackageName

bundleId: the

application package name.

bundle id

Starts an application from its

package name

bundle id.

applicationKill

String

appPackageName

bundleId: the

application package name.

bundle id

Forces an application to stop from its

package name.

bundle id.

Assert

Command

Parameters

Description

assertNotExistsText

String selector: the text that should not exist

Check if the element which text contains the text selector doesn't exist.

assertNotExistsTextExact

String selector: the exact text that should not exist

Check if the element which text is the exact given selector doesn't exist.

assertNotExistsClass

String selector: the class name that should not exist

Check if the element with the class selector doesn't exist.

BrowserManager

So far, the BrowserManager functions only work with some version of Google Chrome.

Command

Parameters

Description

launchBrowser

Launches Google Chrome.

browserClearCache

Clears the cache of Google Chrome.

browserNewTab

Opens a new tab on Google Chrome.

browserGoToUrl

String url: the url to browse.

Browses the given url on Google Chrome.

browserCloseAllTabs

Closes every opened tabs on Google Chrome.

waitUntilPageLoaded

long timeout: the timeout for the wait (in milliseconds).

Waits until the current web page is loaded.

browserCloseAllTabsAndOpen

Closes all browser tabs and open a new tab. (Browser will be closed during process).

Click

Command

Parameters

Description

longClickById

String selector: the id of the element to click on.
int duration: the click duration in milliseconds (1000 ms by default). (optional)

Performs a long click for the given duration on the element which contains the given id selector.

longClickByText

String selector: the text of the element to click on.
int duration: the click duration in milliseconds (1000 ms by default). (optional)

Performs a long click for the given duration on the element which contains the given text selector.

longClickByXY

int x: the abscissa coordinates.
int y: the ordinate coordinates.
int duration: the click duration in milliseconds (1000 ms by default). (optional)

Performs a long click on the element located at the given coordinates.

click

Clicks on the last element stored (after the Find commands).

clickByText

String selector: the text of the element to click on.

This is case insensitive.

Clicks on the element which contains the given text selector.

clickByTextExact

String selector: the exact text of the element to click on.

This is case sensitive.

Clicks on the element which contains the exact given text selector.

clickByTextEndsWith

String selector: the end of the text of the element to click on.

Clicks on the element which finishes with the given text selector.

clickByTextBeginsWith

String selector: the beginning of the text of the element to click on.

Clicks on the element which starts with the given text selector.

clickById

clickByClass

String

id

selector: the

identification of the element to click on

class name.

Clicks on the element

which contains

with the given

identification.

clickByPredicate

String selector: the predicate of the element to click on.

Clicks on the element which matches the given predicate

class selector. In case of several matching elements, it clicks on the first one found.

clickByXY

int x: the abscissa coordinates.

int y: the ordinate coordinates.

Clicks on the element located at the given coordinates.

clickById

String id: the id of the element to click on.

Clicks on the element which contains the given id.

Device

Command

Parameters

Description

pressHome

Presses the home button.

pause

long timeMillis : the time in

millisecond

milliseconds.

Waits the amount of time in

millisecond

milliseconds passed as argument.

Dump

Command

Parameters

Description

dump

String path: the path where the dump file is saved.

Takes a dump of the current state of the device.

Find

Command

Parameters

Description

findElementByName

searchByText

String selector: the text

of the element to find. This is case insensitive.

selector.

Finds the first element which text contains the given

text selector.

findElementByExactName

String selector: the exact text of the element to find. This is case sensitive.

Finds on the element which contains the exact given text selector.

findElementByPartialName

selector and sets it as the last element found.

searchByTextExact

String selector:

a part of

the text

of the element to find

selector.

Finds the first element

which partially contains

with the

given text selector.

findElementByPredicate

String selector: the predicate of the element to find.

Finds the element which matches the given predicate.

findElementEndingWith

exact text and sets it as the last element found.

searchElementEndingWith

String selector: the end of the text of the element to find.

Finds the element which finishes with the given text selector.

findElementBeginningWith

searchElementBeginningWith

String selector: the beginning of the text of the element to find.

Finds on the element which starts with the given text selector.

findChildElement

String

parent

textSelector: the name of the

parent element.String elementName: the name of the

child element.

Finds a child element with the name

elementName

textSelector from a parent.

Probe

Command

Parameters

Description

measureStart

Starts a measure.

measureStop

String stepName: the name of the measure.

Stops the current measure

Starts a measure which can be identified by the given name.

measureStop

Stops the current measure.

Screen

Command

Parameters

Description

setLandscapeOrientation

Sets device orientation to landscape.

setPortraitOrientation

Sets device orientation to portrait.

takeScreenshot

String path: the path where the screenshot is saved.

Takes a screenshot of the current screen.

takeScreenshotByType

String elementId: the

identification

id of the element to take in screenshot.

String path: the path where the screenshot is saved.

Takes a screenshot of the element which contains the given

identification

id.

Scroll

Command

Parameters

Description

scrollDown

Scrolls down the screen.

scrollUp

Scrolls up the screen.

swipe

int x1: the abscissa of the device screen where the swipe begins.

int y1: the ordinate of the device screen where the swipe begins.

int x2: the abscissa of the device screen where the swipe ends.

int y2: the ordinate of the device screen where the swipe ends.

Swipes the screen.

swipeVertical

int percStartY: the percentage of the ordinate coordinates of the device screen where the swipe

begins

begin.

int percEndY: the percentage of the ordinate coordinates of the device screen where the swipe

ends.

end.

int percX: the percentage of the abscissa coordinates of the device screen where the swipe is done.

Swipes vertically the screen. The swipe gesture is from screen point A with coordinates (X percX, Y percStartY) to screen point B with coordinates (X percX, Y percEndY). The perc or % is used for the percentage of the screen size. (Example to make a swipe from A (X 65%, Y 15%) to B (X 65%, Y 50%), use: swipeVertical,15,50,65).

swipeHorizontal

int percStartX: the percentage of the abscissa coordinates of the device screen where the swipe

begins

begin.

int

Int percEndX: the percentage of the abscissa coordinates of the device screen where the swipe

ends.Swipes the screen.

end.

int percY: the percentage of the ordinate coordinates of the device screen where the swipe is done.

Swipes horizontally the screen. The swipe gesture is from screen poinwhicht A with coordinates (X percStartX, Y percY) to screen point B with coordinates (X percEndX, Y percY). The perc or % is used for the percentage of the screen size. (Example to make a swipe from A (X 20%, Y 40%) to B (X 80%, Y 40%), use: swipeHorizontal,20,80,40).

SetText

Command

Parameters

Description

setTextByText

String textToSet: the text to set.

String textSelector: the text selector.

Pastes the given text into the element which contains the given text selector.

setTextByTextExact

String textToSet: the text to set.

String textSelector: the text selector.

Pastes the given text into the element which has the given exact text selector.

setTextById

String textToSet: the text to set.

String idSelector: the id selector.

Pastes the given text into the element which contains the given id selector.

tapText

enterText

String text: the text to enter.

Enters the given text in the current selected field clicking on the keyboard keys for each character.

WaitObject

Command

Parameters

Description

waitUntilText

String selector: the selector, here the text to be visible on screen.

This is case insensitive.

long timeout: the timeout in milliseconds (60 000 ms by default). (optional)

Waits until element which contains the text selector is visible on screen.

The timeout is equal to 60 seconds.

waitUntilTextExact

String selector: the selector, here the exact text value.

This is case sensitive.

long timeout: the timeout in milliseconds (60 000 ms by default). (optional)

Waits until element with exact text selector is visible on screen

. The timeout is equal to 60 seconds

.

waitUntilTextBeginsWith

String selector: the selector, here the beginning of the text to be visible on screen.

long timeout: the timeout in milliseconds (60 000 ms by default). (optional)

Waits until element which starts with the text selector is visible on screen

. The timeout is equal to 60 seconds

.

waitUntilGoneTextExact

String selector: the selector, here the exact text value.

This is case sensitive.

long timeout: the timeout in milliseconds (60 000 ms by default). (optional)

Waits until element with exact text selector disappears from the screen

. The timeout is equal to 60 seconds.

waitUntilPredicate

String selector: the selector, here the predicate.

Waits until element which matches the predicate. The timeout is equal to 60 seconds

.