本文整理汇总了Python中appium.webdriver.common.multi_action.MultiAction.perform方法的典型用法代码示例。如果您正苦于以下问题:Python MultiAction.perform方法的具体用法?Python MultiAction.perform怎么用?Python MultiAction.perform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类appium.webdriver.common.multi_action.MultiAction
的用法示例。
在下文中一共展示了MultiAction.perform方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_parallel_actions
# 需要导入模块: from appium.webdriver.common.multi_action import MultiAction [as 别名]
# 或者: from appium.webdriver.common.multi_action.MultiAction import perform [as 别名]
def test_parallel_actions(self):
el1 = self.driver.find_element_by_name('Content')
el2 = self.driver.find_element_by_name('Animation')
self.driver.scroll(el1, el2)
el = self.driver.find_element_by_name('Views')
action = TouchAction(self.driver)
action.tap(el).perform()
el = self.driver.find_element_by_name('Expandable Lists')
# simulate a swipe/scroll
action.press(el).move_to(x=100, y=-1000).release().perform()
el = self.driver.find_element_by_name('Splitting Touches across Views')
action.tap(el).perform()
els = self.driver.find_elements_by_class_name('android.widget.ListView')
a1 = TouchAction()
a1.press(els[0]) \
.move_to(x=10, y=0).move_to(x=10, y=-75).move_to(x=10, y=-600).release()
a2 = TouchAction()
a2.press(els[1]) \
.move_to(x=10, y=10).move_to(x=10, y=-300).move_to(x=10, y=-600).release()
ma = MultiAction(self.driver, els[0])
ma.add(a1, a2)
ma.perform();
示例2: test_zoom_image
# 需要导入模块: from appium.webdriver.common.multi_action import MultiAction [as 别名]
# 或者: from appium.webdriver.common.multi_action.MultiAction import perform [as 别名]
def test_zoom_image(self):
# 查找元素 操作 校验
self.driver.find_element_by_xpath("//UIAButton[@label='Gesture']").click()
self.driver.find_element_by_accessibility_id("Image (Zoom and Pinch)").click()
image = self.driver.find_element_by_accessibility_id("imageScrollView")
location = image.location
# 获取image的坐标,为(20,90)
print location
x = location["x"]
y = location["y"]
print x
print y
# 获取image的宽和高,分别为300,300
size = image.size
print size
a1 = TouchAction()
a1.press(x=x, y=y).move_to(x=x, y=y+x).release()
a2 = TouchAction()
a2.press(x=x, y=y).move_to(x=x, y=y-x).release()
# MultiAction(self.driver).add(a1, a2).perform()这个写法是错误的,必须分3行,不能合并到1行!
multi_touch = MultiAction(self.driver)
multi_touch.add(a1, a2)
multi_touch.perform()
sleep(3)
示例3: tap
# 需要导入模块: from appium.webdriver.common.multi_action import MultiAction [as 别名]
# 或者: from appium.webdriver.common.multi_action.MultiAction import perform [as 别名]
def tap(self, positions, duration=None):
"""Taps on an particular place with up to five fingers, holding for a
certain time
:Args:
- positions - an array of tuples representing the x/y coordinates of
the fingers to tap. Length can be up to five.
- duration - (optional) length of time to tap, in ms
:Usage:
driver.tap([(100, 20), (100, 60), (100, 100)], 500)
"""
if len(positions) == 1:
action = TouchAction(self)
x = positions[0][0]
y = positions[0][1]
if duration:
action.long_press(x=x, y=y, duration=duration).release()
else:
action.tap(x=x, y=y)
action.perform()
else:
ma = MultiAction(self)
for position in positions:
x = position[0]
y = position[1]
action = TouchAction(self)
if duration:
action.long_press(x=x, y=y, duration=duration).release()
else:
action.press(x=x, y=y).release()
ma.add(action)
ma.perform()
return self
示例4: test_services_map_multi_touch
# 需要导入模块: from appium.webdriver.common.multi_action import MultiAction [as 别名]
# 或者: from appium.webdriver.common.multi_action.MultiAction import perform [as 别名]
def test_services_map_multi_touch(self):
enter_menu(self)
self.driver.find_element_by_android_uiautomator('textContains("Map")').click()
el = self.driver.find_element_by_accessibility_id('Google Map')
els = el.find_elements_by_class_name('android.view.View')
if len(els) > 3:
action0 = TouchAction().tap(els[0])
action1 = TouchAction().tap(els[1])
action2 = TouchAction().tap(els[2])
ma = MultiAction(self.driver, els[0])
ma.add(action0, action1, action2)
ma.perform()
self.driver.back()
self.driver.back()
示例5: test_by_multiaction
# 需要导入模块: from appium.webdriver.common.multi_action import MultiAction [as 别名]
# 或者: from appium.webdriver.common.multi_action.MultiAction import perform [as 别名]
def test_by_multiaction(self):
print "By multiaction"
self.method_name = sys._getframe().f_code.co_name
# self.driver.find_element_by_accessibility_id("Image (Zoom and Pinch)").click()
self.driver.find_element_by_accessibility_id("Test Gesture").click()
# 选取两个点
action1 = TouchAction(self.driver)
action1.press(x=87, y=150).move_to(x=45, y=150).release()
action2 = TouchAction(self.driver)
action2.press(x=120, y=150).move_to(x=150, y=150).release()
# action2.press(x=200, y=150).move_to(x=280, y=150).release() # 无法执行
ma = MultiAction(self.driver)
ma.add(action1, action2)
ma.perform()
sleep(5)
示例6: test_multitouch
# 需要导入模块: from appium.webdriver.common.multi_action import MultiAction [as 别名]
# 或者: from appium.webdriver.common.multi_action.MultiAction import perform [as 别名]
def test_multitouch(self):
driver = self.driver
driver.implicitly_wait(90)
action1 = TouchAction(driver)
action1.long_press(None,1181,665).wait(500).release()
action2 = TouchAction(driver)
action2.long_press(None,838,1104).wait(500).release()
action3 = TouchAction(driver)
action3.long_press(None,588,1652).wait(500).release()
multi = MultiAction(driver)
multi.add(action1,action2,action3)
multi.perform()
示例7: test_actions_with_waits
# 需要导入模块: from appium.webdriver.common.multi_action import MultiAction [as 别名]
# 或者: from appium.webdriver.common.multi_action.MultiAction import perform [as 别名]
def test_actions_with_waits(self):
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_accessibility_id('Views')
action = TouchAction(self.driver)
action.tap(el).perform()
# simulate a swipe/scroll
el = wait_for_element(self.driver, MobileBy.ACCESSIBILITY_ID, 'Expandable Lists')
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_accessibility_id('Splitting Touches across Views')
action.tap(el).perform()
wait_for_element(self.driver, MobileBy.CLASS_NAME, 'android.widget.ListView')
els = self.driver.find_elements_by_class_name('android.widget.ListView')
a1 = TouchAction()
a1.press(els[0]) \
.move_to(x=10, y=0) \
.move_to(x=10, y=-75) \
.wait(1000) \
.move_to(x=10, y=-600) \
.release()
a2 = TouchAction()
a2.press(els[1]) \
.move_to(x=10, y=10) \
.move_to(x=10, y=-300) \
.wait(500) \
.move_to(x=10, y=-600) \
.release()
ma = MultiAction(self.driver, els[0])
ma.add(a1, a2)
ma.perform()
示例8: test_smiley_face
# 需要导入模块: from appium.webdriver.common.multi_action import MultiAction [as 别名]
# 或者: from appium.webdriver.common.multi_action.MultiAction import perform [as 别名]
def test_smiley_face(self):
# just for the fun of it.
# this doesn't really assert anything.
self.driver.find_element_by_accessibility_id('Graphics').click()
els = self.driver.find_elements_by_class_name('android.widget.TextView')
self.driver.scroll(els[len(els)-1], els[0])
el = None
try:
el = self.driver.find_element_by_accessibility_id('Touch Paint')
except Exception as e:
els = self.driver.find_elements_by_class_name('android.widget.TextView')
self.driver.scroll(els[len(els)-1], els[0])
if el is None:
el = self.driver.find_element_by_accessibility_id('Touch Paint')
el.click()
# paint
e1 = TouchAction()
e1.press(x=150, y=100).release()
e2 = TouchAction()
e2.press(x=250, y=100).release()
smile = TouchAction()
smile.press(x=110, y=200) \
.move_to(x=1, y=1) \
.move_to(x=1, y=1) \
.move_to(x=1, y=1) \
.move_to(x=1, y=1) \
.move_to(x=1, y=1) \
.move_to(x=2, y=1) \
.move_to(x=2, y=1) \
.move_to(x=2, y=1) \
.move_to(x=2, y=1) \
.move_to(x=2, y=1) \
.move_to(x=3, y=1) \
.move_to(x=3, y=1) \
.move_to(x=3, y=1) \
.move_to(x=3, y=1) \
.move_to(x=3, y=1) \
.move_to(x=4, y=1) \
.move_to(x=4, y=1) \
.move_to(x=4, y=1) \
.move_to(x=4, y=1) \
.move_to(x=4, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=-1) \
.move_to(x=5, y=-1) \
.move_to(x=5, y=-1) \
.move_to(x=5, y=-1) \
.move_to(x=5, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=1, y=-1) \
.move_to(x=1, y=-1) \
.move_to(x=1, y=-1) \
.move_to(x=1, y=-1) \
.move_to(x=1, y=-1)
smile.release()
ma = MultiAction(self.driver)
ma.add(e1, e2, smile)
ma.perform()
# so you can see it
sleep(10)
示例9: test_smiley_face
# 需要导入模块: from appium.webdriver.common.multi_action import MultiAction [as 别名]
# 或者: from appium.webdriver.common.multi_action.MultiAction import perform [as 别名]
def test_smiley_face(self):
# just for the fun of it.
# this doesn't really assert anything.
# paint
eye1 = TouchAction()
eye1.press(x=150, y=100).release()
eye2 = TouchAction()
eye2.press(x=250, y=100).release()
smile = TouchAction()
smile.press(x=110, y=200) \
.move_to(x=1, y=1) \
.move_to(x=1, y=1) \
.move_to(x=1, y=1) \
.move_to(x=1, y=1) \
.move_to(x=1, y=1) \
.move_to(x=2, y=1) \
.move_to(x=2, y=1) \
.move_to(x=2, y=1) \
.move_to(x=2, y=1) \
.move_to(x=2, y=1) \
.move_to(x=3, y=1) \
.move_to(x=3, y=1) \
.move_to(x=3, y=1) \
.move_to(x=3, y=1) \
.move_to(x=3, y=1) \
.move_to(x=4, y=1) \
.move_to(x=4, y=1) \
.move_to(x=4, y=1) \
.move_to(x=4, y=1) \
.move_to(x=4, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=-1) \
.move_to(x=5, y=-1) \
.move_to(x=5, y=-1) \
.move_to(x=5, y=-1) \
.move_to(x=5, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=1, y=-1) \
.move_to(x=1, y=-1) \
.move_to(x=1, y=-1) \
.move_to(x=1, y=-1) \
.move_to(x=1, y=-1)
smile.release()
ma = MultiAction(self.driver)
ma.add(eye1, eye2, smile)
ma.perform()
# so you can see it
sleep(10)
示例10: test_scroll
# 需要导入模块: from appium.webdriver.common.multi_action import MultiAction [as 别名]
# 或者: from appium.webdriver.common.multi_action.MultiAction import perform [as 别名]
def test_scroll(self):
sleep(2)
els = self.driver.find_element_by_class_name('android.widget.ImageButton')
els.click()
sleep(10)
btn = self.driver.find_element_by_class_name('android.webkit.WebView')
btn.click()
sleep(10)
webview = self.driver.contexts
print ('>>%s<<' % len(webview))
contexts = self.driver.contexts
self.driver.switch_to.context('WEBVIEW')
e1 = TouchAction()
e1.press(x=150, y=100).release()
e2 = TouchAction()
e2.press(x=250, y=100).release()
smile = TouchAction()
smile.press(x=400, y=800) \
.move_to(x=-1, y=1) \
.move_to(x=-1, y=1) \
.move_to(x=-1, y=1) \
.move_to(x=-1, y=1) \
.move_to(x=-1, y=1) \
.move_to(x=-2, y=1) \
.move_to(x=-2, y=1) \
.move_to(x=-2, y=1) \
.move_to(x=-2, y=1) \
.move_to(x=-2, y=1) \
.move_to(x=-3, y=1) \
.move_to(x=-3, y=1) \
.move_to(x=-3, y=1) \
.move_to(x=-3, y=1) \
.move_to(x=-3, y=1) \
.move_to(x=-4, y=1) \
.move_to(x=-4, y=1) \
.move_to(x=-4, y=1) \
.move_to(x=-4, y=1) \
.move_to(x=-4, y=1) \
.move_to(x=-5, y=1) \
.move_to(x=-5, y=1) \
.move_to(x=-5, y=1) \
.move_to(x=-5, y=1) \
.move_to(x=-5, y=1) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=-1) \
.move_to(x=-5, y=-1) \
.move_to(x=-5, y=-1) \
.move_to(x=-5, y=-1) \
.move_to(x=-5, y=-1) \
.move_to(x=-4, y=-1) \
.move_to(x=-4, y=-1) \
.move_to(x=-4, y=-1) \
.move_to(x=-4, y=-1) \
.move_to(x=-4, y=-1) \
.move_to(x=-3, y=-1) \
.move_to(x=-3, y=-1) \
.move_to(x=-3, y=-1) \
.move_to(x=-3, y=-1) \
.move_to(x=-3, y=-1) \
.move_to(x=-2, y=-1) \
.move_to(x=-2, y=-1) \
.move_to(x=-2, y=-1) \
.move_to(x=-2, y=-1) \
.move_to(x=-2, y=-1) \
.move_to(x=-1, y=-1) \
.move_to(x=-1, y=-1) \
.move_to(x=-1, y=-1) \
.move_to(x=-1, y=-1) \
.move_to(x=-1, y=-1)
smile.release()
ma = MultiAction(self.driver)
ma.add(e1,e2,smile)
ma.perform()
sleep(10)
示例11: test_scroll
# 需要导入模块: from appium.webdriver.common.multi_action import MultiAction [as 别名]
# 或者: from appium.webdriver.common.multi_action.MultiAction import perform [as 别名]
#.........这里部分代码省略.........
els = self.driver.find_element_by_class_name('android.widget.ImageButton')
els.click()
sleep(10)
#btn = self.driver.find_element_by_class_name('android.webkit.WebView')
#btn.click()
#
selfview = self.driver.contexts[0]
webview = self.driver.contexts[1]
print ('>>%s<<' % webview)
#contexts = self.driver.contexts
self.driver.switch_to.context(webview)
self.driver.get("http://m.nike.com/us/en_us/pd/air-zoom-pegasus-32-running-shoe/pid-10294427/pgid-10266840")
sleep(10)
print ('>>%s<<' % selfview)
self.driver.switch_to.context(selfview)
print ('Now trying TouchAction')
e1 = TouchAction()
e1.press(x=150, y=100).release()
e2 = TouchAction()
e2.press(x=250, y=100).release()
smile = TouchAction()
smile.press(x=400, y=800) \
.move_to(x=-1, y=1) \
.move_to(x=-1, y=1) \
.move_to(x=-1, y=1) \
.move_to(x=-1, y=1) \
.move_to(x=-1, y=1) \
.move_to(x=-2, y=1) \
.move_to(x=-2, y=1) \
.move_to(x=-2, y=1) \
.move_to(x=-2, y=1) \
.move_to(x=-2, y=1) \
.move_to(x=-3, y=1) \
.move_to(x=-3, y=1) \
.move_to(x=-3, y=1) \
.move_to(x=-3, y=1) \
.move_to(x=-3, y=1) \
.move_to(x=-4, y=1) \
.move_to(x=-4, y=1) \
.move_to(x=-4, y=1) \
.move_to(x=-4, y=1) \
.move_to(x=-4, y=1) \
.move_to(x=-5, y=1) \
.move_to(x=-5, y=1) \
.move_to(x=-5, y=1) \
.move_to(x=-5, y=1) \
.move_to(x=-5, y=1) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=0) \
.move_to(x=-5, y=-1) \
.move_to(x=-5, y=-1) \
.move_to(x=-5, y=-1) \
.move_to(x=-5, y=-1) \
.move_to(x=-5, y=-1) \
.move_to(x=-4, y=-1) \
.move_to(x=-4, y=-1) \
.move_to(x=-4, y=-1) \
.move_to(x=-4, y=-1) \
.move_to(x=-4, y=-1) \
.move_to(x=-3, y=-1) \
.move_to(x=-3, y=-1) \
.move_to(x=-3, y=-1) \
.move_to(x=-3, y=-1) \
.move_to(x=-3, y=-1) \
.move_to(x=-2, y=-1) \
.move_to(x=-2, y=-1) \
.move_to(x=-2, y=-1) \
.move_to(x=-2, y=-1) \
.move_to(x=-2, y=-1) \
.move_to(x=-1, y=-1) \
.move_to(x=-1, y=-1) \
.move_to(x=-1, y=-1) \
.move_to(x=-1, y=-1) \
.move_to(x=-1, y=-1)
smile.release()
ma = MultiAction(self.driver)
ma.add(e1,e2,smile)
ma.perform()
sleep(10)
示例12: test_find_elements
# 需要导入模块: from appium.webdriver.common.multi_action import MultiAction [as 别名]
# 或者: from appium.webdriver.common.multi_action.MultiAction import perform [as 别名]
def test_find_elements(self):
# pause a moment, so xml generation can occur
sleep(2)
self.driver.get("http://m.nike.com/us/en_us/pd/air-zoom-pegasus-32-running-shoe/pid-10294427/pgid-10266840")
#els = self.driver.find_elements_by_xpath('//android.widget.TextView')
#Eself.assertEqual('API Demos', els[0].text)
#el = self.driver.find_element_by_xpath('//android.widget.TextView[contains(@text, "Animat")]')
#self.assertEqual('Animation', el.text)
#el = self.driver.find_element_by_accessibility_id("App")
#el.click()
#els = self.driver.find_elements_by_android_uiautomator('new UiSelector().clickable(true)')
# there are more, but at least 10 visible
#self.assertLess(10, len(els))
# the list includes 2 before the main visible elements
#self.assertEqual('Action Bar', els[2].text)
#els = self.driver.find_elements_by_xpath('//android.widget.TextView')
#self.assertLess(10, len(els))
#self.assertEqual('Action Bar', els[1].text)
smile = TouchAction()
smile.press(x=110, y=200) \
.move_to(x=1, y=1) \
.move_to(x=1, y=1) \
.move_to(x=1, y=1) \
.move_to(x=1, y=1) \
.move_to(x=1, y=1) \
.move_to(x=2, y=1) \
.move_to(x=2, y=1) \
.move_to(x=2, y=1) \
.move_to(x=2, y=1) \
.move_to(x=2, y=1) \
.move_to(x=3, y=1) \
.move_to(x=3, y=1) \
.move_to(x=3, y=1) \
.move_to(x=3, y=1) \
.move_to(x=3, y=1) \
.move_to(x=4, y=1) \
.move_to(x=4, y=1) \
.move_to(x=4, y=1) \
.move_to(x=4, y=1) \
.move_to(x=4, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=1) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=0) \
.move_to(x=5, y=-1) \
.move_to(x=5, y=-1) \
.move_to(x=5, y=-1) \
.move_to(x=5, y=-1) \
.move_to(x=5, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=4, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=3, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=2, y=-1) \
.move_to(x=1, y=-1) \
.move_to(x=1, y=-1) \
.move_to(x=1, y=-1) \
.move_to(x=1, y=-1) \
.move_to(x=1, y=-1)
smile.release()
ma = MultiAction(self.driver)
ma.add(smile)
ma.perform()
# so you can see it
sleep(10)