库实例没有属性'id'

时间:2015-10-16 19:18:28

标签: python appium robotframework

尝试解决AppiumLibrary中的问题时无法完成此处的最后一步(滑动,点按在RF中不起作用)。

我不得不按照建议创建一个python库但出现此错误:

 AttributeError: AppiumTests instance has no attribute 'id'

有错误的行是:

action.tap(x, y, count).perform()

这是python lib代码

from selenium import webdriver
from robot.libraries.BuiltIn import BuiltIn
from AppiumLibrary import AppiumLibrary
from appium.webdriver.common.touch_action import TouchAction

class AppiumTests():

    def set_up():
        desired_caps = {}
        desired_caps['platformName'] = 'Android'
        desired_caps['platformVersion'] = '5.1.1'
        desired_caps['deviceName'] = 'NNNNNN'
        desired_caps['app'] = 'NNNNN'
        desired_caps['appActivity'] = 'NNNNNN'
        url = str("http://localhost:4723/wd/hub")
        driver = webdriver.Remote(url, desired_caps)

    def tear_down(self):
        self.driver.quit()

    def tap_loc(x, y, count=1):
        driver = BuiltIn().get_library_instance('AppiumLibrary')._current_application()
        action = TouchAction(driver)
        action.tap(x, y, count).perform()

    def get_driver(self):
        return self._current_application()

0 个答案:

没有答案