appium启动app

appium启动apk

刚开始接触,记录一下.

appium启动app,有两种,浏览器和非浏览器,启动参数是不一样的,现在很多的apk内部是使用的webview,要操作就要切换进相应webview,启动参数要增加相应的driver。

demo:

if __name__ == '__main__':
    desired_caps = dict()
    desired_caps['platformName'] = 'Android'
    desired_caps['platformVersion'] = '8'
    desired_caps['deviceName'] = '[HUAWEI] EVA-AL00'
    desired_caps['appPackage'] = 'com.seewo.picbook.demo'
    desired_caps['appActivity'] = 'com.seewo.picbook.component.guide.ui.GuideActivity'

    # desired_caps['appPackage'] = 'com.seewo.push.sign'
    # desired_caps['appActivity'] = 'com.seewo.library.push.demo.MainActivity'

    desired_caps['noReset'] = 'True'
    desired_caps['chromedriverExecutable'] = 'd:\download\chromedriver-77.exe'

    data = [
        "http://172.20.124.43:20000/wd/hub",
        desired_caps
    ]
    akw = AppiumKeyword()
    akw.openApplication(data)
    time.sleep(5)


    # akw.input_text("id=com.seewo.easiblink_apk:id/url","https://enow-kernel.test.seewo.com/view?from=remote&type=EN5_share&accessCode=e66d257a45474ed089595f556c45daa2#/enbx/2018")

    # time.sleep(3)
    # akw.input_text("id=com.seewo.easiblink_apk:id/url", "https://baidu.com")
    webview = akw.get_contexts()
    akw.switch_to_context('WEBVIEW_com.seewo.picbook.demo')
    # akw._element_find("id=main-tool-layer-user-info", True, True).click()
    ele = akw._element_find('css=#main-tool-layer-user-info',True,True)

    akw.Tap(['css=.style_head-img_1hOo0'])


    # akw.pressKeycode(['24'])

    # q = akw.executeScript(["return document.querySelector('video').paused"])
    # akw.
    # _driver = akw._cache.current
    # _driver.open_notifications()

问题:

  1. 使用action操作元素时,报错:
    在这里插入图片描述
    解决:
    添加启动参数:
  desired_caps['chromeOptions'] = {'w3c': False}

你可能感兴趣的:(自动化测试,python)