Skip to content

Commit 710d1bc

Browse files
authored
Fix functional tests failed (android, ime/multi_action) (appium#372)
* Fix test failed: ime_tests, multi_action_tests * revert change and add impl for python3 * Remove py3 dependency * Change deepcopy to copy * Update ime_tests
1 parent ca08cf5 commit 710d1bc

File tree

4 files changed

+29
-23
lines changed

4 files changed

+29
-23
lines changed

appium/webdriver/common/multi_action.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def add(self, *touch_actions):
4747
if self._touch_actions is None:
4848
self._touch_actions = []
4949

50-
# deep copy, so that once they are in here, the user can't muck about
51-
self._touch_actions.append(copy.deepcopy(touch_action))
50+
self._touch_actions.append(copy.copy(touch_action))
5251

5352
def perform(self):
5453
"""Perform the actions stored in the object.

test/functional/android/chrome_tests.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,7 @@
1414

1515
import unittest
1616

17-
from time import sleep
18-
1917
from appium import webdriver
20-
import desired_capabilities
2118

2219

2320
class ChromeTests(unittest.TestCase):

test/functional/android/ime_tests.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@
1616
import unittest
1717
from time import sleep
1818

19-
from selenium.common.exceptions import NoSuchElementException
20-
2119
from appium import webdriver
2220
import desired_capabilities
2321

2422

2523
# the emulator is sometimes slow and needs time to think
2624
SLEEPY_TIME = 1
2725

28-
LATIN_IME = u'com.android.inputmethod.latin/.LatinIME'
26+
ANDROID_LATIN = 'com.android.inputmethod.latin/.LatinIME' # Android L/M/N
27+
GOOGLE_LATIN = 'com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME' # Android O/P
2928

3029

3130
class IMETests(unittest.TestCase):
@@ -39,13 +38,14 @@ def tearDown(self):
3938
def test_available_ime_engines(self):
4039
engines = self.driver.available_ime_engines
4140
self.assertIsInstance(engines, list)
42-
self.assertTrue(LATIN_IME in engines)
41+
self.assertTrue(ANDROID_LATIN in engines or GOOGLE_LATIN in engines)
4342

4443
def test_is_ime_active(self):
4544
self.assertTrue(self.driver.is_ime_active())
4645

4746
def test_active_ime_engine(self):
48-
self.assertIsInstance(self.driver.active_ime_engine, unicode)
47+
engines = self.driver.available_ime_engines
48+
self.assertTrue(self.driver.active_ime_engine in engines)
4949

5050
def test_activate_ime_engine(self):
5151
engines = self.driver.available_ime_engines

test/functional/android/multi_action_tests.py

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@
1616
from time import sleep
1717

1818
from appium import webdriver
19+
from appium.webdriver.common.mobileby import MobileBy
1920
from appium.webdriver.common.touch_action import TouchAction
2021
from appium.webdriver.common.multi_action import MultiAction
22+
2123
import desired_capabilities
24+
from helper.test_helper import wait_for_element
2225

2326
# the emulator is sometimes slow and needs time to think
24-
SLEEPY_TIME = 1
27+
SLEEPY_TIME = 3
2528

2629

2730
class MultiActionTests(unittest.TestCase):
@@ -33,21 +36,24 @@ def tearDown(self):
3336
self.driver.quit()
3437

3538
def test_parallel_actions(self):
36-
el1 = self.driver.find_element_by_name('Content')
37-
el2 = self.driver.find_element_by_name('Animation')
39+
el1 = self.driver.find_element_by_accessibility_id('Content')
40+
el2 = self.driver.find_element_by_accessibility_id('Animation')
3841
self.driver.scroll(el1, el2)
3942

40-
el = self.driver.find_element_by_name('Views')
43+
el = self.driver.find_element_by_accessibility_id('Views')
4144
action = TouchAction(self.driver)
4245
action.tap(el).perform()
4346

44-
el = self.driver.find_element_by_name('Expandable Lists')
4547
# simulate a swipe/scroll
48+
el = wait_for_element(self.driver, MobileBy.ACCESSIBILITY_ID, 'Expandable Lists', SLEEPY_TIME)
49+
action.press(el).move_to(x=100, y=-1000).release().perform()
50+
el = self.driver.find_element_by_accessibility_id('Layouts')
4651
action.press(el).move_to(x=100, y=-1000).release().perform()
4752

48-
el = self.driver.find_element_by_name('Splitting Touches across Views')
53+
el = self.driver.find_element_by_accessibility_id('Splitting Touches across Views')
4954
action.tap(el).perform()
5055

56+
wait_for_element(self.driver, MobileBy.CLASS_NAME, 'android.widget.ListView', SLEEPY_TIME)
5157
els = self.driver.find_elements_by_class_name('android.widget.ListView')
5258
a1 = TouchAction()
5359
a1.press(els[0]) \
@@ -62,21 +68,24 @@ def test_parallel_actions(self):
6268
ma.perform()
6369

6470
def test_actions_with_waits(self):
65-
el1 = self.driver.find_element_by_name('Content')
66-
el2 = self.driver.find_element_by_name('Animation')
71+
el1 = self.driver.find_element_by_accessibility_id('Content')
72+
el2 = self.driver.find_element_by_accessibility_id('Animation')
6773
self.driver.scroll(el1, el2)
6874

69-
el = self.driver.find_element_by_name('Views')
75+
el = self.driver.find_element_by_accessibility_id('Views')
7076
action = TouchAction(self.driver)
7177
action.tap(el).perform()
7278

73-
el = self.driver.find_element_by_name('Expandable Lists')
7479
# simulate a swipe/scroll
80+
el = wait_for_element(self.driver, MobileBy.ACCESSIBILITY_ID, 'Expandable Lists', SLEEPY_TIME)
81+
action.press(el).move_to(x=100, y=-1000).release().perform()
82+
el = self.driver.find_element_by_accessibility_id('Layouts')
7583
action.press(el).move_to(x=100, y=-1000).release().perform()
7684

77-
el = self.driver.find_element_by_name('Splitting Touches across Views')
85+
el = self.driver.find_element_by_accessibility_id('Splitting Touches across Views')
7886
action.tap(el).perform()
7987

88+
wait_for_element(self.driver, MobileBy.CLASS_NAME, 'android.widget.ListView', SLEEPY_TIME)
8089
els = self.driver.find_elements_by_class_name('android.widget.ListView')
8190
a1 = TouchAction()
8291
a1.press(els[0]) \
@@ -99,18 +108,19 @@ def test_actions_with_waits(self):
99108
ma.perform()
100109

101110
def test_driver_multi_tap(self):
102-
el = self.driver.find_element_by_name('Graphics')
111+
el = self.driver.find_element_by_accessibility_id('Graphics')
103112
action = TouchAction(self.driver)
104113
action.tap(el).perform()
105114

115+
wait_for_element(self.driver, MobileBy.CLASS_NAME, 'android.widget.TextView', SLEEPY_TIME)
106116
els = self.driver.find_elements_by_class_name('android.widget.TextView')
107117
self.driver.scroll(els[len(els) - 1], els[0])
108118

109119
els = self.driver.find_elements_by_class_name('android.widget.TextView')
110120
if els[len(els) - 1].get_attribute('name') != 'Xfermodes':
111121
self.driver.scroll(els[len(els) - 1], els[0])
112122

113-
el = self.driver.find_element_by_name('Touch Paint')
123+
el = self.driver.find_element_by_accessibility_id('Touch Paint')
114124
action.tap(el).perform()
115125

116126
positions = [(100, 200), (100, 400)]

0 commit comments

Comments
 (0)