Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions appium/webdriver/common/multi_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ def add(self, *touch_actions):
if self._touch_actions is None:
self._touch_actions = []

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

def perform(self):
"""Perform the actions stored in the object.
Expand Down
3 changes: 0 additions & 3 deletions test/functional/android/chrome_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,7 @@

import unittest

from time import sleep

from appium import webdriver
import desired_capabilities


class ChromeTests(unittest.TestCase):
Expand Down
10 changes: 5 additions & 5 deletions test/functional/android/ime_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,15 @@
import unittest
from time import sleep

from selenium.common.exceptions import NoSuchElementException

from appium import webdriver
import desired_capabilities


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

LATIN_IME = u'com.android.inputmethod.latin/.LatinIME'
ANDROID_LATIN = 'com.android.inputmethod.latin/.LatinIME' # Android L/M/N
GOOGLE_LATIN = 'com.google.android.inputmethod.latin/com.android.inputmethod.latin.LatinIME' # Android O/P


class IMETests(unittest.TestCase):
Expand All @@ -39,13 +38,14 @@ def tearDown(self):
def test_available_ime_engines(self):
engines = self.driver.available_ime_engines
self.assertIsInstance(engines, list)
self.assertTrue(LATIN_IME in engines)
self.assertTrue(ANDROID_LATIN in engines or GOOGLE_LATIN in engines)

def test_is_ime_active(self):
self.assertTrue(self.driver.is_ime_active())

def test_active_ime_engine(self):
self.assertIsInstance(self.driver.active_ime_engine, unicode)
engines = self.driver.available_ime_engines
self.assertTrue(self.driver.active_ime_engine in engines)

def test_activate_ime_engine(self):
engines = self.driver.available_ime_engines
Expand Down
36 changes: 23 additions & 13 deletions test/functional/android/multi_action_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@
from time import sleep

from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.common.multi_action import MultiAction

import desired_capabilities
from helper.test_helper import wait_for_element

# the emulator is sometimes slow and needs time to think
SLEEPY_TIME = 1
SLEEPY_TIME = 3


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

def test_parallel_actions(self):
el1 = self.driver.find_element_by_name('Content')
el2 = self.driver.find_element_by_name('Animation')
el1 = self.driver.find_element_by_accessibility_id('Content')
el2 = self.driver.find_element_by_accessibility_id('Animation')
self.driver.scroll(el1, el2)

el = self.driver.find_element_by_name('Views')
el = self.driver.find_element_by_accessibility_id('Views')
action = TouchAction(self.driver)
action.tap(el).perform()

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

el = self.driver.find_element_by_name('Splitting Touches across Views')
el = self.driver.find_element_by_accessibility_id('Splitting Touches across Views')
action.tap(el).perform()

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

def test_actions_with_waits(self):
el1 = self.driver.find_element_by_name('Content')
el2 = self.driver.find_element_by_name('Animation')
el1 = self.driver.find_element_by_accessibility_id('Content')
el2 = self.driver.find_element_by_accessibility_id('Animation')
self.driver.scroll(el1, el2)

el = self.driver.find_element_by_name('Views')
el = self.driver.find_element_by_accessibility_id('Views')
action = TouchAction(self.driver)
action.tap(el).perform()

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

el = self.driver.find_element_by_name('Splitting Touches across Views')
el = self.driver.find_element_by_accessibility_id('Splitting Touches across Views')
action.tap(el).perform()

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

def test_driver_multi_tap(self):
el = self.driver.find_element_by_name('Graphics')
el = self.driver.find_element_by_accessibility_id('Graphics')
action = TouchAction(self.driver)
action.tap(el).perform()

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

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

el = self.driver.find_element_by_name('Touch Paint')
el = self.driver.find_element_by_accessibility_id('Touch Paint')
action.tap(el).perform()

positions = [(100, 200), (100, 400)]
Expand Down