Skip to content
Nick Abalov edited this page Dec 28, 2015 · 7 revisions

Winium.StoreApps implements subset of JSON Wire Protocol

Supported commands

NewSession

POST /session Create a new session.


GetCurrentWindowHandle

GET /session/:sessionId/window_handle Retrieve the current window handle.

driver.current_window_handle

GoBack

POST /session/:sessionId/back Navigate backwards in the browser history, if possible.

driver.back()

ExecuteScript

For details see Command Execute Script

POST /session/:sessionId/execute Inject a snippet of JavaScript into the page for execution in the context of the currently selected frame.

driver.execute_script('mobile: start')

Screenshot

GET /session/:sessionId/screenshot Take a screenshot of the current page.

driver.driver.get_screenshot_as_base64()
driver.get_screenshot_as_file(filename)
driver.get_screenshot_as_png()

Close

DELETE /session/:sessionId/window Close the current window. Warning: it will uninstall applications.

driver.close()

GetWindowSize

GET /session/:sessionId/window/:windowHandle/size Get the size of the specified window.

driver.get_window_size()

GetPageSource

GET /session/:sessionId/source Get the current page source.

driver.page_source

FindElement

POST /session/:sessionId/element Search for an element on the page, starting from the document root.

See Finding Elements for supported strategies.

# find by fully qualified name
driver.find_element_by_class_name('System.Windows.Controls.TextBlock')
driver.find_element_by_tag_name('System.Windows.Controls.TextBlock')

# find by AutomationProperties.AutomationId
driver.find_element_by_id(id_) 
# find by AutomationProperties.Name
driver.find_element_by_name(name)

FindElements

POST /session/:sessionId/elements Search for multiple elements on the page, starting from the document root.

See Finding Elements for supported strategies.

driver.find_elements_by_class_name('System.Windows.Controls.TextBlock')
driver.find_elements_by_tag_name('System.Windows.Controls.TextBlock')

# find by AutomationProperties.AutomationId
driver.find_elements_by_id(id_) 
# find by AutomationProperties.Name
driver.find_elements_by_name(name)

FindChildElement

POST /session/:sessionId/element/:id/element Search for an element on the page, starting from the identified element.

See Finding Elements for supported strategies.

parent = find_element_by_name(name1)
parent.find_element_by_name(name2)
# see FindElement above

FindChildElements

POST /session/:sessionId/element/:id/elements Search for multiple elements on the page, starting from the identified element.

parent = find_element_by_name(name1)
parent.find_elements_by_name(name2)
# see FindElements above

ClickElement

POST /session/:sessionId/element/:id/click Click on an element.

element.click()

GetElementText

GET /session/:sessionId/element/:id/text Returns the visible text for the element.

element.text

SendKeysToElement

POST /session/:sessionId/element/:id/value Send a sequence of key strokes to an element.

element.send_keys(text+Keys.ENTER)

GetElementAttribute

GET /session/:sessionId/element/:id/attribute/:name Get the value of an element's attribute.

After v1.5.0:

First tries to access AutomationProperties. If no automation property with such name exists, then (if allowed) tries to access dependency property If no dependency with such name exists, then (if allowed) tries to access public CLR property. Nested public property can be accessed using dot syntax, e.g., for "Background.Opacity".

Access level is controlled by commandSettings.elementAttributeSettings.accessModifier capability.

Enums serialization strategy is controlled by commandSettings.elementAttributeSettings.enumAsString capability.

To access Automation Properties the name of property, examples:

  • AutomationProperties.AutomationId
  • AutomationProperties.Name

To access Dependency Properties the name of the property, examples:

  • IsReadOnly

In v1.5.0:

First tries to access AutomationProperties. If no automation property with such name exists, then tries to access public property. Nested public property can be accessed using dot syntax, e.g., for "Background.Opacity".

List of automation properties can found on MSDN. When accessing AutomationProperties, property name should be specified with Property post-fix, e.g. AutomationIdProperty.

Before v.1.5.0:

Tries to access public property. Nested public property can be accessed using dot syntax, e.g., for "Background.Opacity".

Returns scalar and string attributes as plain string, returns non-scalar attributes (e.g., List<>, Dictionary<>, etc.) serialized as JSON string.

element.get_attribute(attribute_name)

IsElementDisplayed

GET /session/:sessionId/element/:id/displayed Determine if an element is currently displayed.

element.is_displayed()

GetElementLocation

GET /session/:sessionId/element/:id/location Determine an element's location on the page.

element.location

GetOrientation

GET /session/:sessionId/orientation Get the current browser orientation.

driver.orientation

GetAlertText

GET /session/:sessionId/alert_text Gets the text of the currently displayed JavaScript alert(), confirm(), or prompt() dialog.

alert_text = Alert(driver).text

AcceptAlert

POST /session/:sessionId/accept_alert Accepts the currently displayed alert dialog.

Alert(driver).accept()

DismissAlert

POST /session/:sessionId/dismiss_alert Dismisses the currently displayed alert dialog.

Alert(driver).dismiss()

MouseMoveTo

POST /session/:sessionId/moveto Move the mouse by an offset of the specificed element.

# see more http://selenium-python.readthedocs.org/en/latest/api.html#module-selenium.webdriver.common.action_chains
actions = ActionChains(driver)
# ...
actions.move_by_offset(xoffset, yoffset)
actions.perform()

MouseClick

POST /session/:sessionId/click Click any mouse button (at the coordinates set by the last moveto command).

# see more http://selenium-python.readthedocs.org/en/latest/api.html#module-selenium.webdriver.common.action_chains
actions = ActionChains(driver)
# ...
actions.click()
actions.perform()

MouseDown

POST /session/:sessionId/buttondown Click and hold the left mouse button (at the coordinates set by the last moveto command).

# see more http://selenium-python.readthedocs.org/en/latest/api.html#module-selenium.webdriver.common.action_chains
actions = ActionChains(driver)
# ...
actions.click_and_hold()
actions.perform()

MouseUp

POST /session/:sessionId/buttonup Releases the mouse button previously held (where the mouse is currently at).

# see more http://selenium-python.readthedocs.org/en/latest/api.html#module-selenium.webdriver.common.action_chains
actions = ActionChains(driver)
# ...
actions.release()
actions.perform()

TouchSingleTap

POST /session/:sessionId/touch/click Single tap on the touch enabled device.

actions = TouchActions(driver)
# ...
actions.tap(element)
actions.perform()

TouchScroll

POST session/:sessionId/touch/scroll Scroll on the touch screen using finger based motion events.

POST session/:sessionId/touch/scroll Scroll on the touch screen using finger based motion events.

actions = TouchActions(driver)
# ...
actions.scroll(offset, yoffset)
actions.scroll_from_element(on_element, xoffset, yoffset)
actions.perform()

TouchFlick

POST session/:sessionId/touch/flick Flick on the touch screen using finger motion events.

POST session/:sessionId/touch/flick Flick on the touch screen using finger motion events.

actions = TouchActions(driver)
# ...
actions.flick(self, xspeed, yspeed)
actions.flick_element(self, on_element, xoffset, yoffset, speed)
actions.perform()