Appium系列分享
61.元素是否可操作性
driver.find_element_by_accessibility_id('leizishuoceshi').is_enabled()
62.元素是否可见
driver.find_element_by_accessibility_id('leizishuoceshi').is_displayed()
64.获得元素定位
driver.find_element_by_accessibility_id('leizishuoceshi').location
65.获取元素大小
driver.find_element_by_accessibility_id('leizishuoceshi').size
66.获取元素矩形
driver.find_element_by_accessibility_id('leizishuoceshi')
67.获取CSS元素的值
driver.find_element_by_accessibility_id('leizishuoceshi').value_of_css_property("style")
68.获取视图中的元素位置
element = self.driver.find_element_by_accessibility_id('leizishuoceshi')element.location_in_view
69.表单提交
el = self.driver.find_element_by_accessibility_id('leizishuoceshi')el.submit()
70.获取焦点元素
driver.switch_to.active_element
71.获取当前Context
context = driver.current_context
72.设置当前Context
webview = driver.contexts[1]driver.switch_to.context(webview)
73.移动到点
actions = ActionChains(driver)actions.move_to(element, 10, 10)actions.perform()
74.Click单击
actions = ActionChains(driver)actions.move_to_element(element)actions.click()actions.perform()
75.双击
actions = ActionChains(driver)actions.move_to_element(element)actions.double_click()actions.perform()
76.轻按屏幕启用设备
from appium.webdriver.common.touch_action import TouchActionactions = TouchAction(driver)actions.tap(element)actions.perform()
77.双击
from appium.webdriver.common.touch_action import TouchActionactions = TouchAction(driver)actions.double_tap(element)actions.perform()
78.手指在屏幕上移动
from appium.webdriver.common.touch_action import TouchActionactions = TouchAction(driver)actions.tap_and_hold(element)actions.move_to(element, 50, 50)actions.perform()
79.手指长按触摸屏的事件
from appium.webdriver.common.touch_action import TouchActionactions = TouchAction(driver)actions.long_press(element)actions.perform()
80.手指在触摸屏上滚动的运动事件
from appium.webdriver.common.touch_action import TouchActionactions = TouchAction(driver)actions.scroll_from_element(element, 10, 100)actions.scroll(10, 100)actions.perform()
81.手指在触摸屏上滑动的动作事件
from appium.webdriver.common.touch_action import TouchActionactions = TouchAction(driver)actions.flick_element(element, 1, 10, 10)actions.perform()
82.执行多点触控动作序列
from appium.webdriver.common.touch_action import TouchActionfrom appium.webdriver.common.multi_action import MultiActiona1 = TouchAction()a1.press(10, 20)a1.move_to(10, 200)a1.release()a2 = TouchAction()a2.press(10, 10)a2.move_to(10, 100)a2.release()ma = MultiAction(self.driver)ma.add(a1, a2)ma.perform()
83.执行触摸动作序
from appium.webdriver.common.touch_action import TouchActionactions = TouchAction(driver)actions.tap_and_hold(20, 20)actions.move_to(10, 100)actions.release()actions.perform()
84.切换窗口
driver.switch_to.window("handle")
85.关闭窗口
driver.close()
86.获取窗口句柄
driver.current_window_handle()
87.获取窗口所有的句柄
driver.window_handles()
88.获取标题
driver.title
89.获取窗口大小
driver.get_window_size()
90.设置窗口大小
driver.set_window_size(10, 10)