Skip to content

Commit 6911f7d

Browse files
committed
Add new locator strategy find_elements_by_windows_uiautomation and test
1 parent b6c3503 commit 6911f7d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

appium/webdriver/webelement.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,20 @@ def find_element_by_windows_uiautomation(self, win_uiautomation):
230230
"""
231231
return self.find_element(by=MobileBy.WINDOWS_UI_AUTOMATION, value=win_uiautomation)
232232

233+
def find_elements_by_windows_uiautomation(self, win_uiautomation):
234+
"""Finds elements by windows uiautomation
235+
236+
Args:
237+
win_uiautomation (str): The element name in the windows UIAutomation selector
238+
239+
Usage:
240+
driver.find_elements_by_windows_uiautomation()
241+
242+
Returns:
243+
:obj:`list` of :obj:`appium.webdriver.webelement.WebElement`
244+
"""
245+
return self.find_elements(by=MobileBy.WINDOWS_UI_AUTOMATION, value=win_uiautomation)
246+
233247
def find_element(self, by=By.ID, value=None):
234248
"""Find an element given a By strategy and locator
235249

test/unit/webdriver/webelement_test.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,18 @@ def test_find_elements_by_android_data_matcher_no_value(self):
8080
assert d['using'] == '-android datamatcher'
8181
assert d['value'] == '{}'
8282
assert len(els) == 0
83+
84+
@httpretty.activate
85+
def test_find_element_by_windows_uiautomation(self):
86+
driver = android_w3c_driver()
87+
element = MobileWebElement(driver, 'element_id', w3c=True)
88+
httpretty.register_uri(
89+
httpretty.POST,
90+
appium_command('/session/1234567890/element/element_id/element'),
91+
body='{"value": {"element-6066-11e4-a52e-4f735466cecf": "win-element-id"}}'
92+
)
93+
el = element.find_element_by_windows_uiautomation('win_element')
94+
95+
d = get_httpretty_request_body(httpretty.last_request())
96+
assert d['using'] == '-windows uiautomation'
97+
assert el.id == 'win-element-id'

0 commit comments

Comments
 (0)