Skip to content

Commit 422fd11

Browse files
committed
cleanup a bit
1 parent 1bf5da1 commit 422fd11

File tree

8 files changed

+122
-112
lines changed

8 files changed

+122
-112
lines changed

.github/workflows/functional-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
fail-fast: false
1919
matrix:
2020
test_targets:
21-
- target: test/functional/ios/search_context/find_by_*.py test/functional/ios/safari_tests.py test/functional/ios/webdriver_tests.py
21+
- target: test/functional/ios/safari_tests.py test/functional/ios/webdriver_tests.py
2222
name: func_test_ios1
2323

2424
runs-on: macos-14

test/functional/ios/file/test_file.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.
-20.9 KB
Binary file not shown.

test/functional/ios/search_context/__init__.py

Whitespace-only changes.

test/functional/ios/search_context/find_by_element_webelement_tests.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

test/functional/ios/search_context/find_by_ios_class_chain_tests.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

test/functional/ios/search_context/find_by_ios_predicate_tests.py

Lines changed: 0 additions & 50 deletions
This file was deleted.
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env python
2+
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import httpretty
16+
17+
from appium.webdriver.common.appiumby import AppiumBy
18+
from appium.webdriver.webelement import WebElement as MobileWebElement
19+
from test.unit.helper.test_helper import appium_command, get_httpretty_request_body, ios_w3c_driver
20+
21+
22+
class TestWebDriverIOSSearchContext(object):
23+
@httpretty.activate
24+
def test_find_element_by_ios_predicate(self):
25+
driver = ios_w3c_driver()
26+
httpretty.register_uri(
27+
httpretty.POST,
28+
appium_command('/session/1234567890/element'),
29+
body='{"value": {"element-6066-11e4-a52e-4f735466cecf": "element-id"}}',
30+
)
31+
el = driver.find_element(by=AppiumBy.IOS_PREDICATE, value='wdName == "UIKitCatalog"')
32+
33+
d = get_httpretty_request_body(httpretty.last_request())
34+
assert d['using'] == '-ios predicate string'
35+
assert d['value'] == 'wdName == "UIKitCatalog"'
36+
assert el.id == 'element-id'
37+
38+
@httpretty.activate
39+
def test_find_elements_by_ios_predicate(self):
40+
driver = ios_w3c_driver()
41+
httpretty.register_uri(
42+
httpretty.POST,
43+
appium_command('/session/1234567890/elements'),
44+
body='{"value": [{"element-6066-11e4-a52e-4f735466cecf": "element-id1"}, '
45+
'{"element-6066-11e4-a52e-4f735466cecf": "element-id2"}]}',
46+
)
47+
els = driver.find_elements(by=AppiumBy.IOS_PREDICATE, value='wdName == "UIKitCatalog"')
48+
49+
d = get_httpretty_request_body(httpretty.last_request())
50+
assert d['using'] == '-ios predicate string'
51+
assert d['value'] == 'wdName == "UIKitCatalog"'
52+
assert els[0].id == 'element-id1'
53+
assert els[1].id == 'element-id2'
54+
55+
@httpretty.activate
56+
def test_find_child_elements_by_ios_predicate(self):
57+
driver = ios_w3c_driver()
58+
element = MobileWebElement(driver, 'element_id')
59+
httpretty.register_uri(
60+
httpretty.POST,
61+
appium_command('/session/1234567890/element/element_id/elements'),
62+
body='{"value": [{"element-6066-11e4-a52e-4f735466cecf": "child-element-id1"}, '
63+
'{"element-6066-11e4-a52e-4f735466cecf": "child-element-id2"}]}',
64+
)
65+
els = element.find_elements(by=AppiumBy.IOS_PREDICATE, value='wdName == "UIKitCatalog"')
66+
67+
d = get_httpretty_request_body(httpretty.last_request())
68+
assert d['using'] == '-ios predicate string'
69+
assert d['value'] == 'wdName == "UIKitCatalog"'
70+
assert els[0].id == 'child-element-id1'
71+
assert els[1].id == 'child-element-id2'
72+
73+
@httpretty.activate
74+
def test_find_element_by_ios_class_chain(self):
75+
driver = ios_w3c_driver()
76+
httpretty.register_uri(
77+
httpretty.POST,
78+
appium_command('/session/1234567890/element'),
79+
body='{"value": {"element-6066-11e4-a52e-4f735466cecf": "element-id"}}',
80+
)
81+
el = driver.find_element(by=AppiumBy.IOS_CLASS_CHAIN, value='**/XCUIElementTypeStaticText')
82+
83+
d = get_httpretty_request_body(httpretty.last_request())
84+
assert d['using'] == '-ios class chain'
85+
assert d['value'] == '**/XCUIElementTypeStaticText'
86+
assert el.id == 'element-id'
87+
88+
@httpretty.activate
89+
def test_find_elements_by_ios_class_chain(self):
90+
driver = ios_w3c_driver()
91+
httpretty.register_uri(
92+
httpretty.POST,
93+
appium_command('/session/1234567890/elements'),
94+
body='{"value": [{"element-6066-11e4-a52e-4f735466cecf": "element-id1"}, '
95+
'{"element-6066-11e4-a52e-4f735466cecf": "element-id2"}]}',
96+
)
97+
els = driver.find_elements(by=AppiumBy.IOS_CLASS_CHAIN, value='**/XCUIElementTypeStaticText')
98+
99+
d = get_httpretty_request_body(httpretty.last_request())
100+
assert d['using'] == '-ios class chain'
101+
assert d['value'] == '**/XCUIElementTypeStaticText'
102+
assert els[0].id == 'element-id1'
103+
assert els[1].id == 'element-id2'
104+
105+
@httpretty.activate
106+
def test_find_child_elements_by_ios_class_chain(self):
107+
driver = ios_w3c_driver()
108+
element = MobileWebElement(driver, 'element_id')
109+
httpretty.register_uri(
110+
httpretty.POST,
111+
appium_command('/session/1234567890/element/element_id/elements'),
112+
body='{"value": [{"element-6066-11e4-a52e-4f735466cecf": "child-element-id1"}, '
113+
'{"element-6066-11e4-a52e-4f735466cecf": "child-element-id2"}]}',
114+
)
115+
els = element.find_elements(by=AppiumBy.IOS_CLASS_CHAIN, value='**/XCUIElementTypeStaticText')
116+
117+
d = get_httpretty_request_body(httpretty.last_request())
118+
assert d['using'] == '-ios class chain'
119+
assert d['value'] == '**/XCUIElementTypeStaticText'
120+
assert els[0].id == 'child-element-id1'
121+
assert els[1].id == 'child-element-id2'

0 commit comments

Comments
 (0)