使用robotframework运行时获取当前的Appium实例驱动程序

时间:2018-07-31 09:38:21

标签: python python-3.x appium robotframework python-appium

我正在尝试获取appium的当前正在运行的会话驱动程序实例, 有一篇帖子试图回答类似的问题,但实际上并非Robot Framework - passing Appium driver to python script

这是到目前为止的代码

from appium.webdriver.common.touch_action import TouchAction
from appium.webdriver.common.multi_action import MultiAction
from AppiumLibrary import AppiumLibrary

class Custom(AppiumLibrary):
    def __init__(self):
        super().__init__()
        self.driver = self._current_application() #line with error

#The code below just to show an example of usage
def zoomin(locator, percent, steps):
    customobj = Custom() 
    action1 = TouchAction(customobj.driver)
    action2 = TouchAction(customobj.driver)
    m_action = MultiAction(customobj.driver)
    xx = customobj.driver.get_window_size()['width'] / 2
    yy = customobj.driver.get_window_size()['height'] / 2
    action1.long_press(x=xx, y=yy).move_to(x=0, y=50).wait(500).release()
    action2.long_press(x=xx, y=yy).move_to(x=0, y=-50).wait(500).release()
    m_action.add(action1, action2)

我在“ 未打开任何应用程序

上面提到的行上收到此错误

请注意,我的应用程序是通过robotframework启动并运行的,我希望能够:

    -通过pybot(robotframework)完成并正常运行
    -添加用于robotframework测试套件的自定义python库,并正确导入
    -在库中编写我自己的关键字,并在robot testsuite =>中使用它们,为此,我需要驱动程序实例

0 个答案:

没有答案