Skip to content

Commit a3129c1

Browse files
authored
Divide functional appium tests into each module(iOS) (appium#391)
* Divide ios appium_tests to each module * Fix test file name * Add CI status badge
1 parent a8bdf22 commit a3129c1

9 files changed

Lines changed: 242 additions & 86 deletions

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Appium Python Client
33

44
[![PyPI version](https://badge.fury.io/py/Appium-Python-Client.svg)](https://badge.fury.io/py/Appium-Python-Client)
55

6+
[![Build Status](https://travis-ci.org/appium/python-client.svg?branch=master)](https://travis-ci.org/appium/python-client)
7+
[![Build Status](https://dev.azure.com/ki4070ma/python-client/_apis/build/status/appium.python-client?branchName=master)](https://dev.azure.com/ki4070ma/python-client/_build/latest?definitionId=2&branchName=master)
8+
69
An extension library for adding [Selenium 3.0 draft](https://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html) and [Mobile JSON Wire Protocol Specification draft](https://github.com/SeleniumHQ/mobile-spec/blob/master/spec-draft.md)
710
functionality to the Python language bindings, for use with the mobile testing
811
framework [Appium](https://appium.io).

azure-pipelines.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@ jobs:
99
steps:
1010
- template: ./ci-jobs/functional/run_appium.yml
1111
- script: |
12-
py.test test/functional/ios/find_*.py test/functional/ios/push_file_tests.py test/functional/ios/safari_tests.py
12+
cd test/functional/ios
13+
py.test find_*.py remote_fs_tests.py safari_tests.py
1314
displayName: Run functional tests
1415
- job: func_test_ios2
1516
pool:
1617
vmImage: 'macOS-10.14'
1718
steps:
1819
- template: ./ci-jobs/functional/run_appium.yml
19-
- script: py.test test/functional/ios/appium_tests.py
20+
- script: |
21+
cd test/functional/ios
22+
py.test applications_tests.py hw_actions_tests.py keyboard_tests.py screen_record_tests.py webdriver_tests.py
2023
displayName: Run functional tests
File renamed without changes.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 unittest
16+
17+
from appium import webdriver
18+
from appium.webdriver.applicationstate import ApplicationState
19+
from helper import desired_capabilities
20+
21+
22+
class WebDriverTests(unittest.TestCase):
23+
def setUp(self):
24+
desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
25+
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
26+
27+
def tearDown(self):
28+
self.driver.quit()
29+
30+
def test_app_management(self):
31+
# this only works in Xcode9+
32+
if float(desired_capabilities.get_desired_capabilities(
33+
desired_capabilities.BUNDLE_ID)['platformVersion']) < 11:
34+
return
35+
self.assertEqual(self.driver.query_app_state(desired_capabilities.BUNDLE_ID),
36+
ApplicationState.RUNNING_IN_FOREGROUND)
37+
self.driver.background_app(-1)
38+
self.assertTrue(self.driver.query_app_state(desired_capabilities.BUNDLE_ID) <
39+
ApplicationState.RUNNING_IN_FOREGROUND)
40+
self.driver.activate_app(desired_capabilities.BUNDLE_ID)
41+
self.assertEqual(self.driver.query_app_state(desired_capabilities.BUNDLE_ID),
42+
ApplicationState.RUNNING_IN_FOREGROUND)
43+
44+
45+
if __name__ == '__main__':
46+
suite = unittest.TestLoader().loadTestsFromTestCase(WebDriverTests)
47+
unittest.TextTestRunner(verbosity=2).run(suite)
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
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 unittest
16+
17+
from appium import webdriver
18+
from helper import desired_capabilities
19+
20+
21+
class HwActionsTests(unittest.TestCase):
22+
def setUp(self):
23+
desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
24+
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
25+
26+
def tearDown(self):
27+
self.driver.quit()
28+
29+
def test_lock(self):
30+
self.driver.lock(-1)
31+
try:
32+
self.assertTrue(self.driver.is_locked())
33+
finally:
34+
self.driver.unlock()
35+
self.assertFalse(self.driver.is_locked())
36+
37+
def test_shake(self):
38+
# what can we assert about this?
39+
self.driver.shake()
40+
41+
def test_touch_id(self):
42+
# nothing to assert, just verify that it doesn't blow up
43+
self.driver.touch_id(True)
44+
self.driver.touch_id(False)
45+
46+
def test_toggle_touch_id_enrollment(self):
47+
# nothing to assert, just verify that it doesn't blow up
48+
self.driver.toggle_touch_id_enrollment()
49+
50+
51+
if __name__ == '__main__':
52+
suite = unittest.TestLoader().loadTestsFromTestCase(HwActionsTests)
53+
unittest.TextTestRunner(verbosity=2).run(suite)
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
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 unittest
16+
from time import sleep
17+
18+
from appium import webdriver
19+
from helper import desired_capabilities
20+
21+
22+
class KeyboardTests(unittest.TestCase):
23+
def setUp(self):
24+
desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
25+
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
26+
27+
def tearDown(self):
28+
self.driver.quit()
29+
30+
def test_hide_keyboard(self):
31+
self._move_to_textbox()
32+
33+
el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
34+
el.set_value('Testing')
35+
36+
el = self.driver.find_element_by_class_name('UIAKeyboard')
37+
self.assertTrue(el.is_displayed())
38+
39+
self.driver.hide_keyboard(key_name='Done')
40+
41+
self.assertFalse(el.is_displayed())
42+
43+
def test_hide_keyboard_presskey_strategy(self):
44+
self._move_to_textbox()
45+
46+
el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
47+
el.set_value('Testing')
48+
49+
el = self.driver.find_element_by_class_name('UIAKeyboard')
50+
self.assertTrue(el.is_displayed())
51+
52+
self.driver.hide_keyboard(strategy='pressKey', key='Done')
53+
54+
self.assertFalse(el.is_displayed())
55+
56+
def test_hide_keyboard_no_key_name(self):
57+
self._move_to_textbox()
58+
59+
el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
60+
el.set_value('Testing')
61+
62+
el = self.driver.find_element_by_class_name('UIAKeyboard')
63+
self.assertTrue(el.is_displayed())
64+
65+
self.driver.hide_keyboard()
66+
sleep(10)
67+
68+
# currently fails.
69+
self.assertFalse(el.is_displayed())
70+
71+
def test_is_keyboard_shown(self):
72+
self._move_to_textbox()
73+
74+
el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
75+
el.set_value('Testing')
76+
self.assertTrue(self.driver.is_keyboard_shown())
77+
78+
def _move_to_textbox(self):
79+
el1 = self.driver.find_element_by_accessibility_id('Sliders')
80+
el2 = self.driver.find_element_by_accessibility_id('Buttons')
81+
self.driver.scroll(el1, el2)
82+
83+
# Click text fields
84+
self.driver.find_element_by_accessibility_id('Text Fields').click()
85+
86+
87+
if __name__ == '__main__':
88+
suite = unittest.TestLoader().loadTestsFromTestCase(KeyboardTests)
89+
unittest.TextTestRunner(verbosity=2).run(suite)
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,12 @@
1919
from helper import desired_capabilities
2020

2121

22-
class PushFileTests(unittest.TestCase):
23-
@classmethod
24-
def setUpClass(self):
22+
class RemoteFsTests(unittest.TestCase):
23+
def setUp(self):
2524
desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
2625
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
2726

28-
@classmethod
29-
def tearDownClass(self):
27+
def tearDown(self):
3028
self.driver.quit()
3129

3230
def test_push_file(self):
@@ -38,5 +36,5 @@ def test_push_file(self):
3836

3937

4038
if __name__ == '__main__':
41-
suite = unittest.TestLoader().loadTestsFromTestCase(PushFileTests)
39+
suite = unittest.TestLoader().loadTestsFromTestCase(RemoteFsTests)
4240
unittest.TextTestRunner(verbosity=2).run(suite)
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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 unittest
16+
from time import sleep
17+
18+
from appium import webdriver
19+
from helper import desired_capabilities
20+
21+
22+
class ScreenRecordTests(unittest.TestCase):
23+
def setUp(self):
24+
desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
25+
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
26+
27+
def tearDown(self):
28+
self.driver.quit()
29+
30+
def test_screen_record(self):
31+
self.driver.start_recording_screen()
32+
sleep(10)
33+
result = self.driver.stop_recording_screen()
34+
self.assertTrue(len(result) > 0)
35+
36+
37+
if __name__ == '__main__':
38+
suite = unittest.TestLoader().loadTestsFromTestCase(ScreenRecordTests)
39+
unittest.TextTestRunner(verbosity=2).run(suite)
Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,17 @@
1717

1818
from appium import webdriver
1919
from appium.webdriver.applicationstate import ApplicationState
20-
from appium.webdriver.common.mobileby import MobileBy
2120
from helper import desired_capabilities
2221

2322

24-
class AppiumTests(unittest.TestCase):
23+
class WebDriverTests(unittest.TestCase):
2524
def setUp(self):
2625
desired_caps = desired_capabilities.get_desired_capabilities('UICatalog.app.zip')
2726
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
2827

2928
def tearDown(self):
3029
self.driver.quit()
3130

32-
def test_lock(self):
33-
self.driver.lock(-1)
34-
try:
35-
self.assertTrue(self.driver.is_locked())
36-
finally:
37-
self.driver.unlock()
38-
self.assertFalse(self.driver.is_locked())
39-
40-
def test_screen_record(self):
41-
self.driver.start_recording_screen()
42-
sleep(10)
43-
result = self.driver.stop_recording_screen()
44-
self.assertTrue(len(result) > 0)
45-
4631
def test_app_management(self):
4732
# this only works in Xcode9+
4833
if float(desired_capabilities.get_desired_capabilities(
@@ -57,67 +42,6 @@ def test_app_management(self):
5742
self.assertEqual(self.driver.query_app_state(desired_capabilities.BUNDLE_ID),
5843
ApplicationState.RUNNING_IN_FOREGROUND)
5944

60-
def test_shake(self):
61-
# what can we assert about this?
62-
self.driver.shake()
63-
64-
def test_touch_id(self):
65-
# nothing to assert, just verify that it doesn't blow up
66-
self.driver.touch_id(True)
67-
self.driver.touch_id(False)
68-
69-
def test_toggle_touch_id_enrollment(self):
70-
# nothing to assert, just verify that it doesn't blow up
71-
self.driver.toggle_touch_id_enrollment()
72-
73-
def test_hide_keyboard(self):
74-
self._move_to_textbox()
75-
76-
el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
77-
el.set_value('Testing')
78-
79-
el = self.driver.find_element_by_class_name('UIAKeyboard')
80-
self.assertTrue(el.is_displayed())
81-
82-
self.driver.hide_keyboard(key_name='Done')
83-
84-
self.assertFalse(el.is_displayed())
85-
86-
def test_hide_keyboard_presskey_strategy(self):
87-
self._move_to_textbox()
88-
89-
el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
90-
el.set_value('Testing')
91-
92-
el = self.driver.find_element_by_class_name('UIAKeyboard')
93-
self.assertTrue(el.is_displayed())
94-
95-
self.driver.hide_keyboard(strategy='pressKey', key='Done')
96-
97-
self.assertFalse(el.is_displayed())
98-
99-
def test_hide_keyboard_no_key_name(self):
100-
self._move_to_textbox()
101-
102-
el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
103-
el.set_value('Testing')
104-
105-
el = self.driver.find_element_by_class_name('UIAKeyboard')
106-
self.assertTrue(el.is_displayed())
107-
108-
self.driver.hide_keyboard()
109-
sleep(10)
110-
111-
# currently fails.
112-
self.assertFalse(el.is_displayed())
113-
114-
def test_is_keyboard_shown(self):
115-
self._move_to_textbox()
116-
117-
el = self.driver.find_elements_by_class_name('XCUIElementTypeTextField')[0]
118-
el.set_value('Testing')
119-
self.assertTrue(self.driver.is_keyboard_shown())
120-
12145
def test_clear(self):
12246
self._move_to_textbox()
12347

@@ -157,5 +81,5 @@ def _move_to_textbox(self):
15781

15882

15983
if __name__ == '__main__':
160-
suite = unittest.TestLoader().loadTestsFromTestCase(AppiumTests)
84+
suite = unittest.TestLoader().loadTestsFromTestCase(WebDriverTests)
16185
unittest.TextTestRunner(verbosity=2).run(suite)

0 commit comments

Comments
 (0)