日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

appium()-The event firing

發布時間:2023/12/10 编程问答 43 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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 interface
  • io.appium.java_client.events.api.general.AlertEventListener?is for the listening to alerts
  • io.appium.java_client.events.api.general.ElementEventListener?is for the listening to actions related to elements
  • io.appium.java_client.events.api.general.JavaScriptEventListener?is for the listening to java script executing
  • io.appium.java_client.events.api.general.ListensToException?is for the listening to exceptions which are thrown
  • io.appium.java_client.events.api.general.NavigationEventListener?is for the listening to events related to navigation
  • io.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 window
  • io.appium.java_client.events.api.mobile.ContextEventListener?is for the listening to the switching to mobile context
  • io.appium.java_client.events.api.mobile.RotationEventListener?is for the listening to screen rotation
  • io.appium.java_client.events.api.general.AppiumWebDriverEventListener?was added to provide the compatibility with user's implementation of?org.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 file?io.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 { ... }

轉載于:https://www.cnblogs.com/superbaby11/p/6101403.html

總結

以上是生活随笔為你收集整理的appium()-The event firing的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。