Appium0.18.x迁移到Appium1.x须知事项(灰常实用,解答了本人几个疑问)
英文原版:https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/migrating-to-1-0.md
Migrating your tests from Appium 0.18.x to Appium 1.x
把你的測试从Appium版本号0.18.x迁移至Appium1.x版本号
what needs to change in your test suite to take advantage of Appium 1.0.
Appium1.0把一些陈旧无效的功能从老版本号中踢走,假设你想把你的測试升级到基于Appium1.0的话,本向导会告诉你须要怎么搞。
New
client libraries
新的client库
The biggest thing you need to worry about is using the new Appium client libraries instead of the vanilla WebDriver clients you are currently using. Visit the Appium
client list to find the client for your language. Downloads and instructions for integrating into your code are available on the individual client websites.
你须要做得最重大的事情是用我们最新的Appiumclient库来代替掉原来在用的普通平庸的WebDriverclient库,请查看Appium
client list 来找到你在使用的相应开发语言的客户端版本号。至于怎么下载和集成到你的代码的话里面各自有相应的页面做解答。
Ultimately, you'll be doing something like (to use Python as an example):
终于事实上你须要做得事情大概例如以下(以Python为例):
from appium import webdriver
Instead of:
代替原来的:
from selenium import webdriver
New
desired capabilities
新的capabilities选项
The following capabilities are no longer used:
下面的capabilities将不再使用:
deviceversion
Instead, use these capabilities:
下面的capabilities将取而代之:
platformName(either "iOS" or "Android")platformVersion(the mobile OS version you want)deviceName(the kind of device you want, like "iPhone Simulator")automationName("Selendroid" if you want to use Selendroid, otherwise, this can be omitted)
The app capability remains the same, but now refers exclusively to non-browser apps. To use browsers like
Safari or Chrome, use the standard browserName cap. This means that app and browserName are
exclusive.
之前的app这项capability保留不变,但该项如今专门用在非browser类型的app上面。假设你要測试的是基于Safari或Chrome等浏览器的应用,请使用标准的browserName这项capability。也就是说app和browserName都是专用的选项。
We have also standardized on camelCase for Appium server caps. That means caps like app-package or app-wait-activity are
now appPackage and appWaitActivity respectively.
Of course, since Android app package and activity are now auto-detected, you should be able to omit them entirely in most cases.
同一时候我们也用骆驼命名法又一次统一命名了我们的Appium Server的capabilities。比方说原来的app-package和app-wait-activity将改成appPackage和appWaitActivity。当然,鉴于我们能自己主动检測到Android应用的包和activity,所以你能够大多时候忽略掉这些选项了。
New
locator strategies
新的控件查找器策略
We've removed the following locator strategies:
我们把下面的控件查找器策略给移除掉了:
nametag name
We have now added the accessibility_id strategy to do what name used
to do. The specifics will be relative to your Appium client.
我们如今引入了accessibility_id这个策略来代替原来name所做的事情(译者注:也就是说原来的AppiumDriver.findElementByName将会被如今的AppiumDriver.findElementByAccessibilityId代替)。其中细节将会依据你使用的Appiumclient(译者注:client语言)而有所不同。
tag name has been replaced by class. So to find an element by its UI type, use the class name locator strategy for your client.
name
新的class name将会代替原来的tag name(译者注:也就说原来的findElementByTagName将会被想在的findElementByClassName代替),所以假设你要依据一个控件的UI类型来查找出该控件,请使用class name这个控件查找器。
Note about class name and xpath strategies:
these now require the fully-qualified class name for your element. This means that if you had an xpath selector that looked like this:
注意class name和xpath策略的变化:你如今须要使用FQCN来描写叙述你的控件。也就是说假设你由一个xpath选择子例如以下所述:
//table/cell/button
It would now need to be:
那么如今要改为(译者注:也就是说原来的findElementByXpath(""//TextView[contains(@text,'Add note')]"")将须要改成findElementByXpath("//android.widget.TextView[contains(@text,'Add note')]"):
//UIATableView/UIATableCell/UIAButton
(And likewise for Android: button now needs to be android.widget.Button)
(如此类推:button如今就要写成android.widget.Button)
We've also added the following locator strategies:
同一时候我们也加入�了例如以下的控件定位器策略(译者注:也就是说入Andoid添加�了AppiumDriver.findElementByUiAutomator):
-ios uiautomation-android uiautomator
Refer to your client for ways to use these new locator strategies.
请依据你使用的client(依据不同语言)库来确定怎样使用新的控件定位器策略。
XML,
not JSON
使用JSON代替XML
App source methods, which previously returned JSON, now return XML, so if you have code that relies on parsing the app source, it will need to be updated.
取得当前窗体的源代码(译者注:也就是AppiumDriver.getPageSource函数)返回的格式将从原来的JSON改成XML。所以假设你之前的代码有依赖分析控件源代码的地方必须做对应的更新。
Hybrid
support through context, not window
混合应用通过context而非window进行支持
Hybrid apps were previously supported by switching between "windows" using:
之前的混合应用是通过切换"windows"来获得支持的:
window_handleswindowswitch_to.window
Now Appium supports the more conceptually consistent concept of "context". To get all of the available contexts, or the particular context the application is is, you use
现在Appium支持(跟切换上下文这个概念)更加概念一致的的“context”。为了取得全部可用的上下文或者你的应用特有的上下文,请使用例如以下方式:
# python
driver.contexts
current = driver.context
// javascript
driver.contexts().then(function (contexts) { /*...*/ })
// c#
driver.GetContexts ()
driver.GetContext ()
// java
Set<String> contextNames = driver.getContextHandles();
String context = driver.getContext();
// php
$contexts = $this->contexts();
$context = $this->context();
# ruby
contexts = available_contexts
context = current_context
And to switch between them, you use
请使用例如以下方式进行切换:
# python
driver.switch_to.context("WEBVIEW")
// javascript
driver.currentContext().then(function (context) { /*...*/ })
// c#
driver.SetContext ("WEBVIEW");
java
driver.context(contextName);
// php
$this->context('WEBVIEW');
# ruby
set_context "WEBVIEW"
No
more execute_script("mobile: xxx")
execute_script("mobile: xxx")将销声匿迹
All the mobile: methods have been removed, and have been replaced by native methods in the Appium client
libraries. This means that a method call like driver.execute("mobile: lock", [5]) will now look something
more likedriver.lock(5) (where lock has
been turned into a native client method). Of course, the details on calling these methods will differ by client.
全部”mobile:”相关的方法讲都会被剔除掉,而且被Appiumclient库的原生方法给替代掉。比如原来的driver.execute("mobile:lock",[5])将会被如今的driver.lock(5)所代替(这里lock这个功能已经成为了原生的客户方法了)。当然,详细的调用方法将会依据你所使用的不同的client库而有所不同了。
Of particular note, the gesture methods have been replaced by the new TouchAction / MultiAction API which allows for a much more powerful and general way of putting gestural automation together. Refer to your Appium client for usage notes on TouchAction
/ MultiAction.
须要特别声明的是,手势操作相关的方法将会被新的TouchAction/MultiAction API所替代,把这些手势操作集合在一起将会使得你的手势操作相关的自己主动化更强大和通俗易懂。更具体的TouchAction/MultiAction的使用请查看你的的Appiumclient。
And that's it! Happy migrating!
完!迁移快乐!
Appium0.18.x迁移到Appium1.x须知事项(灰常实用,解答了本人几个疑问)的更多相关文章
- Appium0.18.x迁移到Appium1.x须知事项
英文原版:https://github.com/appium/appium/blob/master/docs/en/advanced-concepts/migrating-to-1-0.md Migr ...
- 将数据从MySQL迁移到Oracle的注意事项
将数据从MySQL迁移到Oracle的注意事项1.自动增长的数据类型处理MYSQL有自动增长的数据类型,插入记录时不用操作此字段,会自动获得数据值.ORACLE没有自动增长的数据类型,需要建立一个自动 ...
- Django学习系列18:使用迁移创建生产数据库
Django生成一个很有帮助的错误信息,大意是说没有正确设置数据库. 你可能会有疑惑,为什么在单元测试一切都运行ok,这是因为Django为单元测试创建了专用的测试数据库——这是Django中Test ...
- TP框架中用tp模版迁移smarty模版的注意事项
ThinkPHP使用Smarty模板引擎的流程及注意事项在多人合作的项目中,Smarty模板使用的最多,具体原因百度. 而ThinkPHP中默认使用的模板是Think自己的模板,这就需要修改默认的模板 ...
- Xamarin迁移到 Unified API 注意事项
参考官方文档: Migrating to Unified API for Components #if __UNIFIED__ ... // Mappings Unified CoreGraphic ...
- 第二章 Vue快速入门-- 18 v-for中key的使用注意事项
注意:如果属性和方法还没定义直接使用的话,就会报 xxx is not defined 导致界面不能正常显示.我看视频教程里老师的可以直接使用,而且界面正常显示,可能是vue版本不同吗?还不清楚 ...
- 【转】Appium基于安卓的各种FindElement的控件定位方法实践
原文地址:http://blog.csdn.net/zhubaitian/article/details/39754041#t11 AppiumDriver的各种findElement方法的尝试,尝试 ...
- Appium基于安卓的各种FindElement的控件定位方法实践和建议
AppiumDriver的各种findElement方法的尝试,尝试的目标应用是SDK自带的Notepad应用. 1. findElementByName 1.1 示例 el = driver.fin ...
- Appium基于安卓的各种FindElement的控件定位
转自:http://www.2cto.com/kf/201410/340345.html 1. findElementByName 1.1 示例 ? 1 2 el = driver.findEleme ...
随机推荐
- Android---两个视图间的淡入淡出
本文译自:http://developer.android.com/training/animation/crossfade.html 淡入淡出动画(也可以作为溶解动画)是指在渐渐的淡出一个UI组件的 ...
- M I S 开发与管理
今天是开学的第一天,很意外的一天没课.但是我知道还有很多事情在等待这我,不能懈怠!安排好计划,把重要不紧急的事情逐渐蚕食掉,切不可养虎为患,等拖到它变成重要紧急事件后,那就后悔莫及了. 下午看了看自考 ...
- POJ 2365 Rope(水题)
[题意简述]:给出我们钉子个数与半径,让我们求出缠绕在钉子上的绳子有多长. [分析]:从题目中我们能够看出,绳子长度的和等于每两个钉子的距离的和加上接触在钉子上的绳子的长度,不难发现这部分长度事实上就 ...
- Boost中timer的简易用法
boost::asio::deadline_timer timer_; timer_(io_service), timer_.expires_from_now(boost::posix_time::s ...
- CentOS 7没有ifconfig命令处理
新安装CentOS 7 64位后发现查看ip配置的时候没有ifconfig,百度后发现# yum install net-tools软件包即可.
- dell服务器各类raid 和磁盘在阵列卡上的实验
听很多人说,做好阵列的硬盘从阵列上移除后,重新从硬盘导入阵列信息的时候不能打乱位置,昨天用两台Dell R710,四块sas 300G HP硬盘做实验,实验步骤如下: 一.dell R710首先用三块 ...
- 通过HttpURLConnection模拟post表单提交
通过HttpURLConnection模拟post表单提交 package junit; import java.io.InputStream; import java.net.HttpURLConn ...
- Nagios+pnp4nagios+rrdtool 安装配置nagios被监控端NRPE配置(二)
NRPE监控插件基础 NRPE总共由两部分组成: (1).check_nrpe插件,运行在监控主机上. (2).NRPE daemon,运行在远程的linux主机上(通常就是被监控机) 整个的监控过程 ...
- 使用CSS3制图
参考资料:http://blog.csdn.net/fense_520/article/details/37892507 本文非转载.为个人原创,转载请先联系博主,谢谢~ 准备: <!DOCTY ...
- windows phone (27) 基础Button
原文:windows phone (27) 基础Button Button 在wp7中因其灵活性经常会用到,我们在ContentPanel中直接添加Button,button默认状态下是把整个grid ...