appium()-The event firing
原文地址:https://github.com/appium/java-client/blob/master/docs/The-event_firing.md
since 4.1.0
The purpose
This feature allows end user to organize the event logging on the client side. Also this feature may be useful in a binding with standard or custom reporting frameworks.//这个功能是用来组织客户端事件日志,便于分析测试细节和撰写测试报告。
The API
The API was designed the way which allows end user to select events (searching, navigation, exception throwing etc.) which should be listened to. It contains the following list of interfaces (new items may be added further)://有如下API。
io.appium.java_client.events.api.Listeneris the basic interfaceio.appium.java_client.events.api.general.AlertEventListeneris for the listening to alertsio.appium.java_client.events.api.general.ElementEventListeneris for the listening to actions related to elementsio.appium.java_client.events.api.general.JavaScriptEventListeneris for the listening to java script executingio.appium.java_client.events.api.general.ListensToExceptionis for the listening to exceptions which are thrownio.appium.java_client.events.api.general.NavigationEventListeneris for the listening to events related to navigationio.appium.java_client.events.api.general.SearchingEventListeneris for the listening to events related to the searching.io.appium.java_client.events.api.general.WindowEventListeneris for the listening to actions on a windowio.appium.java_client.events.api.mobile.ContextEventListeneris for the listening to the switching to mobile contextio.appium.java_client.events.api.mobile.RotationEventListeneris for the listening to screen rotationio.appium.java_client.events.api.general.AppiumWebDriverEventListenerwas added to provide the compatibility with user's implementation oforg.openqa.selenium.support.events.WebDriverEventListener. Also it extends some interfaces above.
Briefly about the engine.
This is pretty similar solution as the org.openqa.selenium.support.events.EventFiringWebDriver of the Selenium project. You can read about this thing there The blog post.//这个功能来源于selenium,但克服了selenium中每次只能监听一个事件的缺点。
Here we were trying to improve existing drawbacks and restrictions using:
API splitting, see above.
the binding of some Spring framework engines with AspectJ.
How to use
It is easy.//使用方法:将driver和被监听的事件传入EventFiringWebDriverFactory。
import io.appium.java_client.events.api.general.AlertEventListener;
public class AlertListener implements AlertEventListener {
...
}
...
import io.appium.java_client.events.api.general.ElementEventListener;
public class ElementListener implements ElementEventListener {
...
}
//and so on
...
import io.appium.java_client.events.EventFiringWebDriverFactory;
import io.appium.java_client.events.api.Listener;
...
AndroidDriver driver = new AndroidDriver(parameters);
driver = EventFiringWebDriverFactory.getEventFiringWebDriver(driver, new AlertListener(),
new ElementListener());
//or
AndroidDriver driver2 = new AndroidDriver(parameters);
List<Listener> listeners = new ArrayList<>();
listeners.add(new AlertListener());
listeners.add(new ElementListener());
driver = EventFiringWebDriverFactory.getEventFiringWebDriver(driver2, listeners);
What if there are listeners which used everywhere by default.
In order to avoid the repeating actions an end user is free to do these things://高级用法:将监听事件作为一种自动启动的服务,不必显式地监听。这种用法来源于java自身的SPI。
- create folders
/META-INF/servicesand put the fileio.appium.java_client.events.api.Listenerthere. Please read aboutSPI.//创建/META-INF/services文件夹,把一个文件放到其中。

- define the list of default listeners at the
io.appium.java_client.events.api.Listener//在文件中定义默认的被监听的事件。

And then it is enough//使用监听事件。
//and so on
...
import io.appium.java_client.events.EventFiringWebDriverFactory;
... AndroidDriver driver = new AndroidDriver(parameters);
driver = EventFiringWebDriverFactory.getEventFiringWebDriver(driver);
If there are listeners defined externally when this collection is merged with default set of listeners.
How to reuse customized WebDriverEventListener
If an end user has their own org.openqa.selenium.support.events.WebDriverEventListener implementation then in order to make it compatible with this engine it is enough to do the following.//高级用法:扩展被监听的事件。
import org.openqa.selenium.support.events.WebDriverEventListener;
import io.appium.java_client.events.api.general.AppiumWebDriverEventListener; public class UsersWebDriverEventListener implements WebDriverEventListener, AppiumWebDriverEventListener {
...
}
or just
import io.appium.java_client.events.api.general.AppiumWebDriverEventListener;
public class UsersWebDriverEventListener implements AppiumWebDriverEventListener {
...
}
appium()-The event firing的更多相关文章
- Programmatically Disable Event Firing on List Item Update in SharePoint 2010
1. Microsoft.SharePoint.dll Create EventFiring.cs 1.Right-click on the project, select Add and click ...
- appium()-java-client-api
//appium java-client-api 介绍 原文地址:http://appium.github.io/java-client/index-all.html#_S_ A B C D E F ...
- appium(11)-java-client
Welcome to the Appium Java client wiki! This framework is an extension of the Selenium Java client. ...
- AngularJS 系列 01 - HelloWorld和数据绑定
目录导读: AngularJS 系列 学习笔记 目录篇 前言: 好记性不如烂键盘,随笔就是随手笔记,希望以后有用. 本篇目录: 1. Hello World 2. AngularJS中的数据绑定 3. ...
- seajs源码分析
seajs主要做了2件事 1.定义什么是模块,如何声明模块:id.deps.factory.exports ----define=function(id,deps,factory){return ex ...
- 自己修改的两个js文件
sea-base.js /** * Sea.js 2.2.3 | seajs.org/LICENSE.md */ (function(global, undefined) { // Avoid con ...
- HelloWorld和数据绑定
HelloWorld和数据绑定 目录导读: AngularJS 系列 学习笔记 目录篇 前言: 好记性不如烂键盘,随笔就是随手笔记,希望以后有用. 本篇目录: 1. Hello World 2. An ...
- seajs源码
/*** Sea.js 3.0.0 | seajs.org/LICENSE.md 中文注释由 李祥威 添加,为个人对细节的理解,官方解释很详细的地方就不说了 难免有错漏,联系我: chuangweil ...
- 5 Protocols For Event-Driven API Architectures
The internet is a system of communication, and as such, the relationship between client and server, ...
随机推荐
- 关于django rest framework里token auth的实现及答疑
http://stackoverflow.com/questions/14838128/django-rest-framework-token-authentication ============= ...
- unity3d Resources.Load动态加载资源
初步整理并且学习unity3d资源加载方法,预计用时两天完成入门学习Unity3d常用两种加载资源方案:Resources.Load和AssetBundle Resources.Load就是从一个缺省 ...
- 某考试 T3 Try to find out the wrong in the test
Discription Hint: 对于 100% 的数据, n<=10^6.
- PyTorch学习笔记之CBOW模型实践
import torch from torch import nn, optim from torch.autograd import Variable import torch.nn.functio ...
- Java中HashMap的初始容量设置
根据阿里巴巴Java开发手册上建议HashMap初始化时设置已知的大小,如果不超过16个,那么设置成默认大小16: 集合初始化时, 指定集合初始值大小. 说明: HashMap使用HashMap(in ...
- -[__NSCFString longValue]: unrecognized selector sent to instance
You can use NSString methods intValue longLongValue. 这个使用longvalue会crash报上面的错误
- Windows Server 2008R2 设置SMTP邮件转发服务
最近因业务需求在Windows Server 2008R2server上设置SMTP转发服务,主要是在业务审批过程中邮件通知相关人员审批情况, 1.在server上加入服务 2.打开服务 3.新建一个 ...
- C# 线程中更新ListView某单元格导致闪烁问题的解决
项目中需要用线程处理一些事务.处理结果(已经处理的比例)随时显示在ListView的某区域. 由于线程循环动作较快,导致被更新的单元格甚至所在行都有闪烁现象. 后来考虑到线程算的值整数部分未必变化很快 ...
- ThinkPHP5.0中Request请求对象的常用操作
获取当前系统参数 // 获取当前域名 echo '获取当前域名:'.$request->domain() . '<br/>'; // 获取当前入口文件 echo '获取当前入口文件: ...
- 自己定义UITextField
目的是实现例如以下的效果: UITextField的leftView是自己定义的UIView,当中: 1.包括一个居中显示的icon.而且上,左,下各有1px的间隙 2.左上和左下是圆角,右边没有圆角 ...