Skip to content

Commit 3cd9fe8

Browse files
committed
Merge pull request #39 from appium/isaac-tests
Add some more tests, fix others
2 parents 4082d0f + 5992658 commit 3cd9fe8

10 files changed

+154
-13
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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 time import sleep
18+
19+
from appium import webdriver
20+
import desired_capabilities
21+
22+
23+
class ChromeTests(unittest.TestCase):
24+
def setUp(self):
25+
desired_caps = {
26+
'platformName': 'Android',
27+
'platformVersion': '4.2',
28+
'deviceName': 'Android Emulator',
29+
'browserName': 'Chrome'
30+
}
31+
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
32+
33+
def tearDown(self):
34+
self.driver.quit()
35+
36+
def test_find_single_element(self):
37+
self.driver.get('http://10.0.2.2:4723/test/guinea-pig')
38+
self.driver.find_element_by_link_text('i am a link').click()
39+
40+
self.assertTrue('I am some other page content' in self.driver.page_source)
41+
42+
43+
if __name__ == "__main__":
44+
suite = unittest.TestLoader().loadTestsFromTestCase(ChromeTests)
45+
unittest.TextTestRunner(verbosity=2).run(suite)

test/functional/android/context_switching_tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def test_contexts_list(self):
3131

3232
def test_move_to_correct_context(self):
3333
self._enter_webview()
34-
self.assertEqual('WEBVIEW_1', self.driver.current_context)
34+
self.assertEqual('WEBVIEW_io.selendroid.testapp', self.driver.current_context)
3535

3636
def test_actually_in_webview(self):
3737
self._enter_webview()
@@ -57,4 +57,5 @@ def _enter_webview(self):
5757

5858

5959
if __name__ == "__main__":
60-
unittest.main()
60+
suite = unittest.TestLoader().loadTestsFromTestCase(ContextSwitchingTests)
61+
unittest.TextTestRunner(verbosity=2).run(suite)

test/functional/android/find_by_accessibility_id_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,5 @@ def test_element_find_multiple_elements(self):
4848

4949

5050
if __name__ == "__main__":
51-
unittest.main()
51+
suite = unittest.TestLoader().loadTestsFromTestCase(FindByAccessibilityIDTests)
52+
unittest.TextTestRunner(verbosity=2).run(suite)

test/functional/android/find_by_uiautomator_tests.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ def tearDown(self):
2727
self.driver.quit()
2828

2929
def test_find_single_element(self):
30-
el = self.driver.find_element_by_android_uiautomator('new UiSelector().description("Animation")')
30+
el = self.driver.find_element_by_android_uiautomator('new UiSelector().text("Animation")')
3131
self.assertIsNotNone(el)
3232

3333
def test_find_multiple_elements(self):
3434
els = self.driver.find_elements_by_android_uiautomator('new UiSelector().clickable(true)')
35-
self.assertTrue(len(els) > 11)
35+
self.assertIsInstance(els, list)
3636

3737
def test_element_find_single_element(self):
3838
el = self.driver.find_element_by_class_name('android.widget.ListView')
@@ -44,8 +44,13 @@ def test_element_find_multiple_elements(self):
4444
el = self.driver.find_element_by_class_name('android.widget.ListView')
4545

4646
sub_els = el.find_elements_by_android_uiautomator('new UiSelector().clickable(true)')
47-
self.assertTrue(len(sub_els) > 11)
47+
self.assertIsInstance(sub_els, list)
48+
49+
def test_scroll_into_view(self):
50+
el = self.driver.find_element_by_android_uiautomator('new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().text("Views").instance(0));')
51+
el.click()
4852

4953

5054
if __name__ == "__main__":
51-
unittest.main()
55+
suite = unittest.TestLoader().loadTestsFromTestCase(FindByUIAutomatorTests)
56+
unittest.TextTestRunner(verbosity=2).run(suite)

test/functional/android/multi_action_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,5 @@ def test_driver_zoom(self):
168168

169169

170170
if __name__ == "__main__":
171-
unittest.main()
171+
suite = unittest.TestLoader().loadTestsFromTestCase(MultiActionTests)
172+
unittest.TextTestRunner(verbosity=2).run(suite)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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.common.exceptions import NoSuchContextException
19+
import desired_capabilities
20+
from time import sleep
21+
22+
from selenium.webdriver.common.touch_actions import TouchActions
23+
24+
25+
class SelendroidTests(unittest.TestCase):
26+
def setUp(self):
27+
desired_caps = desired_capabilities.get_desired_capabilities('ApiDemos-debug.apk')
28+
desired_caps['automationName'] = 'Selendroid'
29+
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
30+
31+
def test_contexts_list(self):
32+
el = self.driver.find_element_by_class_name('android.widget.ListView')
33+
els = el.find_elements_by_class_name('android.widget.TextView')
34+
35+
ta = TouchActions(self.driver).flick_element(el, 0, -300, 0)
36+
ta.perform()
37+
sleep(5)
38+
39+
def tearDown(self):
40+
self.driver.quit()
41+
42+
def _enter_webview(self):
43+
btn = self.driver.find_element_by_name('buttonStartWebviewCD')
44+
btn.click()
45+
self.driver.switch_to.context('WEBVIEW')
46+
47+
48+
if __name__ == "__main__":
49+
suite = unittest.TestLoader().loadTestsFromTestCase(SelendroidTests)
50+
unittest.TextTestRunner(verbosity=2).run(suite)

test/functional/android/touch_action_tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,11 @@ def test_driver_drag_and_drop(self):
231231
def test_driver_swipe(self):
232232
self.assertRaises(NoSuchElementException, self.driver.find_element_by_name, 'Views')
233233

234-
self.driver.swipe(100, 500, 100, 100, 1.2)
234+
self.driver.swipe(100, 500, 100, 100, 800)
235235
el = self.driver.find_element_by_name('Views')
236236
self.assertIsNotNone(el)
237237

238238

239239
if __name__ == "__main__":
240-
unittest.main()
240+
suite = unittest.TestLoader().loadTestsFromTestCase(TouchActionTests)
241+
unittest.TextTestRunner(verbosity=2).run(suite)

test/functional/ios/find_by_uiautomation_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@ def test_element_find_multiple_elements(self):
5252

5353

5454
if __name__ == "__main__":
55-
unittest.main()
55+
suite = unittest.TestLoader().loadTestsFromTestCase(FindByUIAutomationTests)
56+
unittest.TextTestRunner(verbosity=2).run(suite)

test/functional/ios/multi_action_tests.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_driver_pinch_zoom(self):
3838
el.click()
3939

4040
sleep(1)
41-
el = self.driver.find_element_by_xpath('//window[1]/UIAMapView[1]')
41+
el = self.driver.find_element_by_xpath('//UIAApplication[1]/UIAWindow[1]/UIAMapView[1]')
4242
self.driver.zoom(el)
4343

4444
sleep(5)
@@ -47,4 +47,5 @@ def test_driver_pinch_zoom(self):
4747

4848

4949
if __name__ == "__main__":
50-
unittest.main()
50+
suite = unittest.TestLoader().loadTestsFromTestCase(MultiActionTests)
51+
unittest.TextTestRunner(verbosity=2).run(suite)

test/functional/ios/safari_tests.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python
2+
3+
import unittest
4+
from time import sleep
5+
6+
7+
from appium import webdriver
8+
9+
10+
class SafariTests(unittest.TestCase):
11+
def setUp(self):
12+
desired_caps = {
13+
'browserName': 'safari',
14+
'platformName': 'iOS',
15+
'platformVersion': '7.1',
16+
'deviceName': 'iPhone Simulator',
17+
'nativeWebTap': True,
18+
'safariIgnoreFraudWarning': True
19+
}
20+
self.driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
21+
22+
def tearDown(self):
23+
self.driver.quit()
24+
25+
def test_context(self):
26+
self.assertEqual([u'NATIVE_APP', u'WEBVIEW_1'], self.driver.contexts)
27+
self.assertEqual('WEBVIEW_1', self.driver.current_context)
28+
29+
def test_get(self):
30+
self.driver.get("http://google.com")
31+
self.assertEqual('Google', self.driver.title)
32+
33+
if __name__ == "__main__":
34+
suite = unittest.TestLoader().loadTestsFromTestCase(SafariTests)
35+
unittest.TextTestRunner(verbosity=2).run(suite)

0 commit comments

Comments
 (0)