Skip to content

Commit 3c31002

Browse files
Update The-event_firing.md
1 parent 8467893 commit 3c31002

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/The-event_firing.md

+26
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,29 @@ public class UsersWebDriverEventListener implements AppiumWebDriverEventListener
123123
...
124124
}
125125
```
126+
# Also
127+
128+
As soon as Appium java client has Java 8-style API (methods with default implementation) there was provided the ability to get objects created by these interfaces (anonymous types) listenable. Also there is an option is to make some objects (some single element that has been found, for example) listenable too.
129+
130+
```java
131+
import static io.appium.java_client.events.EventFiringObjectFactory.getEventFiringObject;
132+
...
133+
134+
AppiumDriver<AndroidElement> appiumDriver = new AppiumDriver<AndroidElement>(parameters);
135+
FindsByAndroidUIAutomator<AndroidElement> findsByAndroidUIAutomator =
136+
new FindsByAndroidUIAutomator<AndroidElement>() {
137+
138+
@Override
139+
public AndroidElement findElement(String by, String using) {
140+
return appiumDriver.findElement(String by, String using);
141+
}
142+
143+
@Override
144+
public List<AndroidElement> findElements(String by, String using) {
145+
return appiumDriver.findElements(by, using);
146+
}
147+
};
148+
149+
findsByAndroidUIAutomator =
150+
getEventFiringObject(findsByAndroidUIAutomator, appiumDriver, listeners);
151+
```

0 commit comments

Comments
 (0)