我有以下代码点击屏幕中心。我不想点击任何元素。就在中心,解雇一些开放式面板。我怎么做?
touch = TouchAction()
dimension = driver.get_window_size()
touch.tap(element=None, x=int(dimension['width']/2),y=int(dimension['height']/2)).perform()
以上代码会产生此错误
self = <appium.webdriver.common.touch_action.TouchAction object at 0x7f6aa32a2810>
def perform(self):
"""Perform the action by sending the commands to the server to be operated upon
"""
params = {'actions': self._actions}
> self._driver.execute(Command.TOUCH_ACTION, params)
E AttributeError: 'NoneType' object has no attribute 'execute'
在上面的代码中,初始化TouchAction()时驱动程序缺少参数 所以我需要做的就是
touch = TouchAction(driver)
和代码工作....
答案 0 :(得分:2)
你可以使用TouchAction,例子是在python客户端github页面上
el = self.driver.find_element_by_accessibility_id('Animation')
action = TouchAction(self.driver)
action.tap(el).perform()
el = self.driver.find_element_by_accessibility_id('Bouncing Balls')
self.assertIsNotNone(el)
您也可以使用坐标(Java示例)
new TouchAction(driver).press(802, 1770).release().perform();
我希望它会帮助你;)