-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Queries
This is list of most common endpoints with some query examples using curl
with pre-set environment variables:
-
DEVICE_URL
set as device URL (eg.http://localhost:8100
) -
SESSION_ID
set as session id. Returned by start session command e.g.D15E12F6-CA23-4CD4-89F9-E5C5EA6F4FAD
JSON_HEADER='-H "Content-Type: application/json"'
WebDriverAgent is intended to implement WebDriver spec so we will not get much into details as you can simply read WebDriver spec.
curl -X GET $JSON_HEADER $DEVICE_URL/status
If application is already installed on device you can start it using bundleId
parameter:
curl -X POST $JSON_HEADER \
-d "{\"desiredCapabilities\":{\"bundleId\":\"com.apple.mobilesafari\"}}" \
$DEVICE_URL/session
It is also possible to request to install application before launching it by adding app
parameter:
curl -X POST $JSON_HEADER \
-d "{\"desiredCapabilities\":{\"bundleId\":\"com.apple.mobilesafari\", \"app\":\"[host_path]/magicapp.app\"}}" \
$DEVICE_URL/session
curl -X GET $JSON_HEADER $DEVICE_URL/session/$SESSION_ID
curl -X DELETE $JSON_HEADER $DEVICE_URL/session/$SESSION_ID
Open web browser at inspector endpoint /inspector
curl -X POST $JSON_HEADER -d "" $DEVICE_URL/homescreen
curl -X GET $JSON_HEADER $DEVICE_URL/screenshot
curl -X POST $JSON_HEADER -d "{\"duration\":3}" $DEVICE_URL/session/$SESSION_ID/deactivateApp
Supported orientations are:
- PORTRAIT
- LANDSCAPE
- UIA_DEVICE_ORIENTATION_LANDSCAPERIGHT
- UIA_DEVICE_ORIENTATION_PORTRAIT_UPSIDEDOWN
curl -X POST $JSON_HEADER \
-d "{\"orientation\":\"LANDSCAPE\"}" \
$DEVICE_URL/session/$SESSION_ID/orientation`
curl -X GET $JSON_HEADER $DEVICE_URL/source
Some of element search endpoints use property names listed here.
You can search for elements by:
- property with given value (
link text
)
curl -X POST $JSON_HEADER \
-d "{\"using\":\"link text\",\"value\":\"label=Apple\"}" \
$DEVICE_URL/session/$SESSION_ID/elements
- property with given partial value (
partial link text
)
curl -X POST $JSON_HEADER \
-d "{\"using\":\"partial link text\",\"value\":\"label=App\"}" \
$DEVICE_URL/session/$SESSION_ID/elements
- using
class name
curl -X POST $JSON_HEADER \
-d "{\"using\":\"class name\",\"value\":\"XCUIElementTypeButton\"}" \
$DEVICE_URL/session/$SESSION_ID/elements
- using
xpath
curl -X POST $JSON_HEADER \
-d "{\"using\":\"xpath\",\"value\":\"//XCUIElementTypeButton[@name='Share']\"}" \
$DEVICE_URL/session/$SESSION_ID/elements
- using
predicate string
curl -X POST $JSON_HEADER \
-d "{\"using\":\"predicate string\",\"value\":\"wdVisible==1\"}" \
$DEVICE_URL/session/$SESSION_ID/elements
In same manner you can query subelements of given element with id by using /element/:id/elements
endpoint.
- You can also list all cell for given table view or collection view:
curl -X GET $JSON_HEADER $DEVICE_URL/session/$SESSION_ID/uiaElement/:id/getVisibleCells
All elements returned by search endpoints have assigned element_id
. Given element_id
you can query properties like enabled
, rect
, size
, location
, text
, displayed
, accessible
, name
e.g.:
curl -X GET $JSON_HEADER $DEVICE_URL/session/$SESSION_ID/element/5/displayed
or using by using element/5/attribute/:name
endpoint e.g.:
curl -X GET $JSON_HEADER $DEVICE_URL/session/$SESSION_ID/element/5/attribute/name
curl -X POST $JSON_HEADER -d "" $DEVICE_URL/session/$SESSION_ID/element/5/click
curl -X POST $JSON_HEADER \
-d "{\"value\":[\"h\",\"t\",\"t\",\"p\",\":\",\"/\",\"/\",\"g\",\"i\",\"t\",\"h\",\"u\",\"b\",\".\",\"c\",\"o\",\"m\",\"\\n\"]}" \
$DEVICE_URL/session/$SESSION_ID/element/5/value
curl -X POST $JSON_HEADER -d "" $DEVICE_URL/session/$SESSION_ID/element/5/clear
curl -X GET $JSON_HEADER $DEVICE_URL/session/$SESSION_ID/alert_text
curl -X POST $JSON_HEADER -d "" $DEVICE_URL/session/$SESSION_ID/accept_alert
curl -X POST $JSON_HEADER -d "" $DEVICE_URL/session/$SESSION_ID/dismiss_alert
curl -X POST $JSON_HEADER -d "{\"match\":1}" $DEVICE_URL/session/$SESSION_ID/simulator/touch_id
curl -X POST $JSON_HEADER -d "{\"match\":0}" $DEVICE_URL/session/$SESSION_ID/simulator/touch_id