zoukankan      html  css  js  c++  java
  • 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需要开发配置好
  • 相关阅读:
    Hadoop HDFS的常用命令
    Spark简介
    Hadoop datanode无法启动的错误
    kafka在虚拟机环境的优化
    kafka的安装和使用
    Strom的安装及使用
    机器学习
    Tomcat启动时为什么要配置CATALINA_HOME环境变量??
    sqoop的安装和使用
    Python Lambda 的简单用法
  • 原文地址:https://www.cnblogs.com/iamshasha/p/11089889.html
Copyright © 2011-2022 走看看