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.Listener
is the basic interfaceio.appium.java_client.events.api.general.AlertEventListener
is for the listening to alertsio.appium.java_client.events.api.general.ElementEventListener
is for the listening to actions related to elementsio.appium.java_client.events.api.general.JavaScriptEventListener
is for the listening to java script executingio.appium.java_client.events.api.general.ListensToException
is for the listening to exceptions which are thrownio.appium.java_client.events.api.general.NavigationEventListener
is for the listening to events related to navigationio.appium.java_client.events.api.general.SearchingEventListener
is for the listening to events related to the searching.io.appium.java_client.events.api.general.WindowEventListener
is for the listening to actions on a windowio.appium.java_client.events.api.mobile.ContextEventListener
is for the listening to the switching to mobile contextio.appium.java_client.events.api.mobile.RotationEventListener
is for the listening to screen rotationio.appium.java_client.events.api.general.AppiumWebDriverEventListener
was 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/services
and put the fileio.appium.java_client.events.api.Listener
there. 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, ...
随机推荐
- 我的js为什么会触发两次
$(function() { $(".show").off("click").on("click",function(e){ e.preve ...
- 牛客网 牛客练习赛7 D. 珂朵莉的无向图(多源BFS)
题目链接 Problem D 比赛的时候完全想不到 直接对给定的这些点做多源$BFS$,把给定的这些点全都压到队列里,然后一个个做. 最后统计被访问的点的个数即可. #include <bit ...
- 洛谷——P2296 寻找道路
P2296 寻找道路 题目描述 在有向图G 中,每条边的长度均为1 ,现给定起点和终点,请你在图中找一条从起点到终点的路径,该路径满足以下条件: 1 .路径上的所有点的出边所指向的点都直接或间接与终点 ...
- 轻量级Web渗透测试工具jSQL
轻量级Web渗透测试工具jSQL jSQL是Kali集成的一款轻量级的Web渗透测试工具.最初该工具主要实施SQL注入,后来增加更多的功能,扩展形成一个综合性的Web渗透测试工具.Kali提供的版本较 ...
- k8s之pod控制器
1.生产中,很少会跑一个自主式pod,一般由控制器去创建pod,其配置文件中内嵌了pod的创建方式. pod控制器:ReplicaSet.Deployment.DaemonSet.Job.Cronjo ...
- 我的VIM
我的vim 压缩包地址:https://pan.baidu.com/s/1bo1kt8j
- 快速掌握分布式搜索引擎ElasticSearch(一)
前言 由于最近在项目中接触使用到了ElasticSearch,从本篇博客开始将给大家分享这款风靡全球的产品.将涉及到ElasticSearch的安装.基础概念.基本用法.高级查询.中文分词器.与Spr ...
- Go -- LFU类(缓存淘汰算法)(转)
1. LFU类 1.1. LFU 1.1.1. 原理 LFU(Least Frequently Used)算法根据数据的历史访问频率来淘汰数据,其核心思想是“如果数据过去被访问多次,那么将来被访问的频 ...
- mysql数据库连接状态,不要做修改数据库表结构的操作;数据库迁移操作;
在开发过程中,python的flask框架使用sqlalmysql连接mysql数据库. 在程序连接数据量过程中,不要修改数据表的结构.比如在连接状态中使用下面的软件修改数据表结构,这个软件立即就会卡 ...
- [反汇编练习] 160个CrackMe之037
[反汇编练习] 160个CrackMe之037. 本系列文章的目的是从一个没有任何经验的新手的角度(其实就是我自己),一步步尝试将160个CrackMe全部破解,如果可以,通过任何方式写出一个类似于注 ...