Appium-Hybrid Mobile App

定义

可以理解为通过 Web 网络技术(如 HTML,CSS 和 JavaScript)与 Native 相结合的混合移动应用程序。H5主要用于界面的编写,比如按钮、单选框以及下拉框等; CSS3用于对界面细节化的修饰,设置不同的样式;JS实现数据交互。Native与HTML相比,性能稳定、交互流畅,可以调用本地硬件和访问本地资源,但是开发和维护成本高,发布周期长。而HTML有着跨平台,开发成本第,更新快等有点。

现在很多app都是由原生页面(native)和webview页面(H5)组成,在自动化测试中需要判断页面是native还是webview。

Hybrid 测试流程

  1. 进入的页面具有webview
  2. 使用uiautomatorviewer工具或contexts方法进行判断存在webview
  3. 使用context方法切换进webview
  4. 定位,操作
  5. 再次使用context方法返回native

webview与native的判断

  1、uiautomatorviewer中判断
  在UI Automator Viewer中,查看结构,如果节点的class 是android.webkit.WebView 则可判断为 H5页面

  

 

  2、通过contexts方法判断
    driver.contexts

# ['NATIVE_APP', 'WEBVIEW_com.tencent.xxx']
contexts打印结果为:['NATIVE_APP', 'WEBVIEW_com.tencent.xxx']
NATIVE_APP则表示为app原生页面。
webview_com.XXXX 表示为 webview 页面

webview 操作

由于 native 和 webview 是两种不同页面,所以要在native中操作webview需要先切换到webview页面,切换方法:
由于driver.contexts返回的是一个列表,当然可以使用index获取webview
driver.switch_to.context(driver.contexts[1])
在webview中操作完成后,需要切换到NATIVE_APP继续操作。可以使用driver.contexts返回值的index=0操作,或者直接使用NATIVE_APP进行操作
driver.switch_to.context(driver.contexts[0])driver.switch_to.context(“NATIVE_APP”)

 

错误一解决:

出现:Original error: No Chromedriver found that can automate Chrome ‘80.0.3987.122’表示浏览器版本与驱动版本不匹配
解决方法:下载匹配的chrome浏览器版本与驱动,手机与PC端chrome的版本最后一致
chrome driver 下载地址:https://npm.taobao.org/mirrors/chromedriver

chrome driver下载后存放在 ~\Appium\resources\app\node_modules\appium\node_modules\appium-chromedriver\chromedriver\win 下
或者:在脚本的caps中添加driver:
caps["chromedriverExecutable"] = r"xxxxxxxxxx\projectAutoTest\chromedriver.exe"
或者:
caps["chromedriverExecutableDir"] = r"xxxxxxxxxx\projectAutoTest\"

错误二解决:

使用contexts无法获取webview
1、android4.4以上需要开启webView的远程调试开关
2、测试中开启debug

 

 

Ionic : Hybrid Mobile App Development by Rahat Khanna English | 14 Jun. 2017 | ASIN: B072N8FRG8 | 544 Pages | AZW3 | 18.96 MB An end–to-end journey, empowering you to build real-time, scalable, and interactive mobile applications with the Ionic framework About This Book Develop engaging mobile experiences with a native-looking UI in Ionic and AngularJS. Use out-of-the-box Ionic functionalities, customize existing components, and add new components with this comprehensive course. Learn Ionic by creating three complete mobile applications Who This Book Is For If you are a web developer who wants to build hybrid mobile app development using the Ionic framework, then this comprehensive course is best-suited for you. What You Will Learn Get to know about Hybrid Apps and AngularJS Set up a development environment to build Hybrid Apps Navigate around components and routing in Ionic Authenticate users using an e-mail password, Twitter, Facebook, Google+, and LinkedIn Retrieve data and store it using Firebase Access native device functionalities such as the camera, contact list, e-mail, and maps using NG-Cordova Integrate PhoneGap plugins with NG-Cordova Test your apps to improve and optimize performance In Detail Hybrid Apps are a promising choice in mobile app development to achieve cost-effectiveness and rapid development. Ionic has evolved as the most popular choice for Hybrid Mobile App development as it tends to match the native experience and provides robust components/tools to build apps. The Ionic Complete Developers course takes you on an end–to-end journey, empowering you to build real-time, scalable, and interactive mobile applications with the Ionic framework. Starting with an introduction to the Ionic framework to get you up and running, you will gradually move on to setting up the environment, and work through the multiple options and features available in Ionic to build amazing hybrid mobile apps. You will learn how to use Cordova plugins to include native functionality in your hybrid apps. You will work through three complete projects and build a basic to-do list app, a London tourist app, and a complete social media app. All three projects have been designed to help you learn Ionic at its very best. From setting up your project to developing on both the server side and front end, and best practices for testing and debugging your projects, you'll quickly be able to deliver high-performance mobile apps that look awesome. You will then hone your skills with recipes for cross-platform development. Integrating Ionic with Cordova will bring you native device features, and you will learn about the best modules from its ecosystem. Creating components and customizing the theme will allow you to extend Ionic. You'll see how to build your app to deploy to all platforms to make you a confident start-to-finish mobile developer. This Learning Path combines some of the best that Packt has to offer in one complete, curated package. It includes content from the following Packt products: Getting Started with Ionic – by Rahat Khanna Ionic by Example – by Sani Yusuf Ionic Cookbook – by Hoc Phan Style and approach This course shows you how to get up and running with the Ionic framework. It doesn't just give you instructions, expecting you to follow them. Instead, with a hands-on approach, it demonstrates what Ionic is capable of through a series of practical projects that you can build yourself.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值