forked from appium/python-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplications_tests.py
More file actions
83 lines (65 loc) · 3.21 KB
/
applications_tests.py
File metadata and controls
83 lines (65 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os
import unittest
from time import sleep
from appium.webdriver.applicationstate import ApplicationState
from .helper.desired_capabilities import PATH
from .helper.test_helper import APIDEMO_PKG_NAME, BaseTestCase
class ApplicationsTests(BaseTestCase):
def test_background_app(self):
self.driver.background_app(1)
sleep(3)
self.driver.launch_app()
def test_is_app_installed(self):
self.assertFalse(self.driver.is_app_installed('sdfsdf'))
self.assertTrue(self.driver.is_app_installed(APIDEMO_PKG_NAME))
def test_install_app(self):
self.assertFalse(self.driver.is_app_installed('io.selendroid.testapp'))
self.driver.install_app(PATH(os.path.join('../..', 'apps', 'selendroid-test-app.apk')))
self.assertTrue(self.driver.is_app_installed('io.selendroid.testapp'))
def test_remove_app(self):
self.assertTrue(self.driver.is_app_installed(APIDEMO_PKG_NAME))
self.driver.remove_app(APIDEMO_PKG_NAME)
self.assertFalse(self.driver.is_app_installed(APIDEMO_PKG_NAME))
def test_close_and_launch_app(self):
self.driver.close_app()
self.driver.launch_app()
activity = self.driver.current_activity
self.assertEqual('.ApiDemos', activity)
def test_app_management(self):
app_id = self.driver.current_package
self.assertEqual(self.driver.query_app_state(app_id),
ApplicationState.RUNNING_IN_FOREGROUND)
self.driver.background_app(-1)
self.assertTrue(self.driver.query_app_state(app_id) <
ApplicationState.RUNNING_IN_FOREGROUND)
self.driver.activate_app(app_id)
self.assertEqual(self.driver.query_app_state(app_id),
ApplicationState.RUNNING_IN_FOREGROUND)
def test_app_strings(self):
strings = self.driver.app_strings()
self.assertEqual(u'You can\'t wipe my data, you are a monkey!', strings[u'monkey_wipe_data'])
def test_app_strings_with_language(self):
strings = self.driver.app_strings('en')
self.assertEqual(u'You can\'t wipe my data, you are a monkey!', strings[u'monkey_wipe_data'])
def test_app_strings_with_language_and_file(self):
strings = self.driver.app_strings('en', 'some_file')
self.assertEqual(u'You can\'t wipe my data, you are a monkey!', strings[u'monkey_wipe_data'])
def test_reset(self):
self.driver.reset()
self.assertTrue(self.driver.is_app_installed(APIDEMO_PKG_NAME))
if __name__ == '__main__':
suite = unittest.TestLoader().loadTestsFromTestCase(ApplicationsTests)
unittest.TextTestRunner(verbosity=2).run(suite)