• appium webview切换native界面操作方法


    webview界面:
    print(driver.contexts)
    driver.switch_to.context(输入待测试webview名字))

    native界面:
    driver.switch_to.content(输入待测试native界面‘NATIVE_APP’)

    代码如下:

    from appium import webdriver
    import time,traceback

    desired_caps = {}
    desired_caps['platformName'] = 'Android'#测试平台
    desired_caps['platforVersion'] = '7'#平台版本
    desired_caps['deviceName'] = 'test'#设备名称 随便填写一个值
    #desired_caps['browserName'] = 'Chrome'
    desired_caps['appPackage'] = 'com.example.jcy.wvtest'#app packagem包名
    desired_caps['appActivity'] = 'com.example.jcy.wvtest.MainActivity'#主activity信息
    desired_caps['unicodeKeyboard'] = True#自动化输入内容有中文字符加此参数
    desired_caps['noReset'] = True#测试完成 还原输入法 重要参数保证app测试前数据不被删除
    desired_caps['newCommandTimeout'] = 6000#超过6000毫秒 无命令 appium会断开
    desired_caps['automationName'] = 'uiautomator2'
    desired_caps['chromedriverExecutable'] = r'D:for myselfGoogleChromeApplicationchromedriver.exe'
    driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
    driver.implicitly_wait(10)
    #启动手机浏览器
    try:
    time.sleep(3)
    print(driver.contexts)#打印出待测试的webview名字
    driver.switch_to.context('WEBVIEW_com.example.jcy.wvtest')#输入待测试webview名字 切换至webview界面
    driver.find_element_by_id('index-kw').send_keys('哈哈哈哈 ')
    driver.switch_to.contextt('NATIVE_APP')#切换至native界面
    time.sleep(2)
    driver.find_element_by_id('com.example.jcy.wvtest:id/navigation_notifications').click()#切换至通知面板

    except:
    print(traceback.format_exc())

    input('**** Press to quit..')
    driver.quit()


    测试webview界面前提是webview需要开发配置好
  • 相关阅读:
    POWERDESIGNER中显示样式设置
    DatagridView 最后编辑状态数据无法自动提交的问题
    oracle 10G以上版本 树形查询新加的几个功能
    net farmework 4安装不了 原因是 HRESULT 0xc8000222
    npoi 导出
    oracle rowtype
    fiddler https
    一次linux站点安装经验
    小米手机安装https证书报错:无法安装该证书 因为无法读取该证书文件
    日志系统
  • 原文地址:https://www.cnblogs.com/iamshasha/p/11089889.html
Copyright © 2020-2023  润新知