public class EventStream extends BaseClass
Experimental Features for more information.EventStream captures event details as JavaScript objects as they are handled by the EventHandler. The event target canvas ID and
class name as well the locator are included, as available.
Event-specific data (for example, the String for keyboard events) are also included where appropriate. See EventStreamEvent for more information. You can configure the stream to capture
most DOM event types and other useful events, such as relogins and JavaScript
errors that are triggered by events:
| Event Category | Includes (source DOM eventType(s) or description) | Controlling Attribute | From DOM Event? |
|---|---|---|---|
| click events | mouseDown, mouseUp, click,
dblClick | captureClickEvents | Y |
| move events | mouseMove, mouseOut
| captureMoveEvents | Y |
| key events | keyDown, keyPress, keyUp | captureKeyEvents | Y |
| drag events | dragStart, dragMove, dragStop | captureDragEvents | Y |
| context menu events | contextMenu | captureMenuEvents | Y |
| mouse wheel events | mouseWheel | captureWheelEvents | Y |
| page events | load, unload, resize | capturePageEvents | Y |
| login events | Successful relogin via the RPCManager | captureLoginEvents | N |
Reify file events |
Project and screen (auto)saves and loads | captureDSFileEvents | N |
| event errors | JavaScript exceptions | captureEventErrors | N |
Note that several types of DOM events can be collapsed so that one event is
reported instead of many if they occur over the same target. You can enable collapsing for move and drag events, key events, wheel events, and page events. A stream capture limit is also supported via circular buffering,
so that only the most recent events are preserved. All available events can be returned as an array of EventStreamEvent via getEvents().
A EventStream will start capturing events as soon as it's created by default, but if you
set autoStart: false, you can start capturing manually
by calling start(). Calling end() will end capturing and return the EventStreamData.
EventHandler,
RPCManager,
Reify Overview,
Experimental Featuresconfig, configOnly, factoryCreated, factoryProperties, id, scClassName| Constructor and Description |
|---|
EventStream() |
EventStream(com.google.gwt.core.client.JavaScriptObject jsObj) |
| Modifier and Type | Method and Description |
|---|---|
com.google.gwt.core.client.JavaScriptObject |
create() |
EventStreamData |
end()
Ends event capturing and returns the
EventStreamData. |
SeleniumCommand[] |
getAsSeleneseCommands()
Creates and returns Selenese that represents the events captured by the stream as an array of
Selenium commands. |
SeleniumCommand[] |
getAsSeleneseCommands(SeleneseSettings settings)
Creates and returns Selenese that represents the events captured by the stream as an array of
Selenium commands. |
java.lang.String |
getAsSeleneseHTML()
Creates and returns Selenese that represents the events captured by the stream.
|
java.lang.String |
getAsSeleneseHTML(SeleneseSettings settings)
Creates and returns Selenese that represents the events captured by the stream.
|
boolean |
getAutoStart()
Whether the stream should automatically begin capturing events.
|
boolean |
getCaptureClickEvents()
Whether mouse button-driven events (or their touch equivalents) should be captured by the stream.
|
boolean |
getCaptureDragEvents()
Whether dragging-related events should be captured by the stream.
|
boolean |
getCaptureEventErrors()
Whether to capture JavaScript errors.
|
boolean |
getCaptureKeyEvents()
Whether keyboard input events should be captured by the stream.
|
boolean |
getCaptureLoginEvents()
Whether
relogins are captured by the stream. |
boolean |
getCaptureMenuEvents()
Whether opening a context menu should be captured by the stream.
|
boolean |
getCaptureMoveEvents()
Whether mouse or touch motion-related events (other than dragging) should be captured by the stream.
|
boolean |
getCapturePageEvents()
Whether page-level events such as a page load or resize should be captured by the stream.
|
boolean |
getCaptureWheelEvents()
Whether mouse wheel events should be captured by the stream.
|
boolean |
getCollapseKeyEvents()
Whether to collapse adjacent
keyPress events into one event where possible. |
boolean |
getCollapseMoveEvents()
|
boolean |
getCollapsePageEvents()
Whether adjacgent page events with the same
eventType should be collapsed into a single event. |
boolean |
getCollapseWheelEvents()
Whether mouse wheel events with the same
targetID
and scroll directions should be collapsed into a single event, containing a sum of the delta offsets from the original events. |
EventStreamEvent[] |
getEvents()
Returns all available captured events, oldest first.
|
com.google.gwt.core.client.JavaScriptObject |
getJsObj() |
java.lang.Integer |
getMaxSize()
Maximum number of events that will be stored by this
EventStream. |
int |
getMinErrorReportingInterval()
Number of seconds that must elapse before another event error will be reported.
|
com.google.gwt.core.client.JavaScriptObject |
getOrCreateJsObj() |
static EventStream |
getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj) |
java.util.Date |
getStartTime()
Returns when this stream started capturing events (i.e.
|
boolean |
isCreated() |
EventStream |
setAutoStart(boolean autoStart)
Whether the stream should automatically begin capturing events.
|
EventStream |
setCaptureClickEvents(boolean captureClickEvents)
Whether mouse button-driven events (or their touch equivalents) should be captured by the stream.
|
EventStream |
setCaptureDragEvents(boolean captureDragEvents)
Whether dragging-related events should be captured by the stream.
|
EventStream |
setCaptureEventErrors(boolean captureEventErrors)
Whether to capture JavaScript errors.
|
EventStream |
setCaptureKeyEvents(boolean captureKeyEvents)
Whether keyboard input events should be captured by the stream.
|
EventStream |
setCaptureLoginEvents(boolean captureLoginEvents)
Whether
relogins are captured by the stream. |
EventStream |
setCaptureMenuEvents(boolean captureMenuEvents)
Whether opening a context menu should be captured by the stream.
|
EventStream |
setCaptureMoveEvents(boolean captureMoveEvents)
Whether mouse or touch motion-related events (other than dragging) should be captured by the stream.
|
EventStream |
setCapturePageEvents(boolean capturePageEvents)
Whether page-level events such as a page load or resize should be captured by the stream.
|
EventStream |
setCaptureWheelEvents(boolean captureWheelEvents)
Whether mouse wheel events should be captured by the stream.
|
EventStream |
setCollapseKeyEvents(boolean collapseKeyEvents)
Whether to collapse adjacent
keyPress events into one event where possible. |
EventStream |
setCollapseMoveEvents(boolean collapseMoveEvents)
|
EventStream |
setCollapsePageEvents(boolean collapsePageEvents)
Whether adjacgent page events with the same
eventType should be collapsed into a single event. |
EventStream |
setCollapseWheelEvents(boolean collapseWheelEvents)
Whether mouse wheel events with the same
targetID
and scroll directions should be collapsed into a single event, containing a sum of the delta offsets from the original events. |
void |
setEventErrorListener(EventErrorCallback callback)
Installs a callback that will be called when the EventStream reports an
event error, subject to the error reporting interval. |
void |
setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj) |
EventStream |
setMaxSize(java.lang.Integer maxSize)
Maximum number of events that will be stored by this
EventStream. |
EventStream |
setMinErrorReportingInterval(int minErrorReportingInterval)
Number of seconds that must elapse before another event error will be reported.
|
void |
start()
Starts capturing all enabled events.
|
addDynamicProperty, addDynamicProperty, addDynamicProperty, addDynamicProperty, applyFactoryProperties, asSGWTComponent, clearDynamicProperty, createJsObj, destroy, doAddHandler, doInit, error, error, errorIfNotCreated, fireEvent, getAttribute, getAttributeAsBoolean, getAttributeAsDate, getAttributeAsDouble, getAttributeAsElement, getAttributeAsFloat, getAttributeAsInt, getAttributeAsJavaScriptObject, getAttributeAsMap, getAttributeAsString, getAttributeAsStringArray, getClassName, getConfig, getHandlerCount, getID, getRef, getRuleScope, getScClassName, getTestInstance, hasAutoAssignedID, hasDynamicProperty, internalSetID, internalSetID, isConfigOnly, isFactoryCreated, onBind, onInit, registerID, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setConfig, setConfigOnly, setFactoryCreated, setID, setProperty, setProperty, setProperty, setProperty, setRuleScope, setScClassNamepublic EventStream()
public EventStream(com.google.gwt.core.client.JavaScriptObject jsObj)
public static EventStream getOrCreateRef(com.google.gwt.core.client.JavaScriptObject jsObj)
public void setJavaScriptObject(com.google.gwt.core.client.JavaScriptObject jsObj)
setJavaScriptObject in class BaseClasspublic com.google.gwt.core.client.JavaScriptObject create()
public com.google.gwt.core.client.JavaScriptObject getJsObj()
public com.google.gwt.core.client.JavaScriptObject getOrCreateJsObj()
getOrCreateJsObj in class BaseClasspublic EventStream setAutoStart(boolean autoStart) throws java.lang.IllegalStateException
start() is called.autoStart - New autoStart value. Default value is trueEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdpublic boolean getAutoStart()
start() is called.public EventStream setCaptureClickEvents(boolean captureClickEvents) throws java.lang.IllegalStateException
Includes such
eventTypes as mouseDown,
mouseUp, click, doubleClk, pointerDown, pointerUp,
pointerCancel, touchStart, touchEnd, and touchCancel.
captureClickEvents - New captureClickEvents value. Default value is trueEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdpublic boolean getCaptureClickEvents()
Includes such
eventTypes as mouseDown,
mouseUp, click, doubleClk, pointerDown, pointerUp,
pointerCancel, touchStart, touchEnd, and touchCancel.
public EventStream setCaptureDragEvents(boolean captureDragEvents) throws java.lang.IllegalStateException
eventType and targetID will be collapsed into one if collapseMoveEvents is true. Includes such eventTypes as:
dragStart,
dragRepositionStart, dragResizeStart, dragSelectStart, dragMove, dragRepositionMove, dragResizeMove, dragSelectMove,
dragStop, dragRepositionStop, dragResizeStop, dragSelectStop,
drop, dropOver, and dragLeave. captureDragEvents - New captureDragEvents value. Default value is trueEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdpublic boolean getCaptureDragEvents()
eventType and targetID will be collapsed into one if collapseMoveEvents is true. Includes such eventTypes as:
dragStart,
dragRepositionStart, dragResizeStart, dragSelectStart, dragMove, dragRepositionMove, dragResizeMove, dragSelectMove,
dragStop, dragRepositionStop, dragResizeStop, dragSelectStop,
drop, dropOver, and dragLeave. public EventStream setCaptureEventErrors(boolean captureEventErrors) throws java.lang.IllegalStateException
eventType of the last dispatched DOM event (i.e., there
is no special "error" eventType.) EventStreamEvent records annotated or specially-reported with error details will
contain an errorTrace with the error stack
trace, and a threadCode reporting the thread ID
from the EventHandler responsible for the error.
captureEventErrors - New captureEventErrors value. Default value is trueEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdpublic boolean getCaptureEventErrors()
eventType of the last dispatched DOM event (i.e., there
is no special "error" eventType.) EventStreamEvent records annotated or specially-reported with error details will
contain an errorTrace with the error stack
trace, and a threadCode reporting the thread ID
from the EventHandler responsible for the error.
public EventStream setCaptureKeyEvents(boolean captureKeyEvents) throws java.lang.IllegalStateException
keyPress, as
keyDown/keyUp are generally not useful. Conversely, for modifier keys (e.g. Shift), we
capture only the keyDown and keyUp. events, and not the keyPress. If
collapseKeyEvents is true, multiple adjacent
keyPress events may be collapsed into a single event for greater readability and a more compact event trace.
Note
that if an error is thrown while handling an event, it will get reported regardless of this setting and the above
capturing rules, but see minErrorReportingInterval. So for example an error handling a keyDown would still generally end up in the
event trace, even for a self-inserting key such as "A".
captureKeyEvents - New captureKeyEvents value. Default value is falseEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdpublic boolean getCaptureKeyEvents()
keyPress, as
keyDown/keyUp are generally not useful. Conversely, for modifier keys (e.g. Shift), we
capture only the keyDown and keyUp. events, and not the keyPress. If
collapseKeyEvents is true, multiple adjacent
keyPress events may be collapsed into a single event for greater readability and a more compact event trace.
Note
that if an error is thrown while handling an event, it will get reported regardless of this setting and the above
capturing rules, but see minErrorReportingInterval. So for example an error handling a keyDown would still generally end up in the
event trace, even for a self-inserting key such as "A".
public EventStream setCaptureLoginEvents(boolean captureLoginEvents) throws java.lang.IllegalStateException
relogins are captured by the stream. Login events are non-DOM events
originating from the RPCManager rather than the EventHandler. Login events have a transaction URL. Includes the eventType relogin.
captureLoginEvents - New captureLoginEvents value. Default value is trueEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdpublic boolean getCaptureLoginEvents()
relogins are captured by the stream. Login events are non-DOM events
originating from the RPCManager rather than the EventHandler. Login events have a transaction URL. Includes the eventType relogin.
public EventStream setCaptureMenuEvents(boolean captureMenuEvents) throws java.lang.IllegalStateException
Includes the eventType
contextMenu.
captureMenuEvents - New captureMenuEvents value. Default value is trueEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdpublic boolean getCaptureMenuEvents()
Includes the eventType
contextMenu.
public EventStream setCaptureMoveEvents(boolean captureMoveEvents) throws java.lang.IllegalStateException
eventType and
targetID will be collapsed into one if collapseMoveEvents is true. Includes such eventTypes as mouseMove,
pointerMove, touchMove, and mouseOut.
captureMoveEvents - New captureMoveEvents value. Default value is falseEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdpublic boolean getCaptureMoveEvents()
eventType and
targetID will be collapsed into one if collapseMoveEvents is true. Includes such eventTypes as mouseMove,
pointerMove, touchMove, and mouseOut.
public EventStream setCapturePageEvents(boolean capturePageEvents) throws java.lang.IllegalStateException
collapsePageEvents is true. Includes such eventTypes as load, unload,
and resize.
capturePageEvents - New capturePageEvents value. Default value is falseEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdpublic boolean getCapturePageEvents()
collapsePageEvents is true. Includes such eventTypes as load, unload,
and resize.
public EventStream setCaptureWheelEvents(boolean captureWheelEvents) throws java.lang.IllegalStateException
targetID and scroll directions, it will be replaced by
the current one, subject to collapseWheelEvents, with the delta offsets in the
"collapsed" event getting adjusted to be the sum of those from all the original events. Includes the eventType mouseWheel.
captureWheelEvents - New captureWheelEvents value. Default value is trueEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdpublic boolean getCaptureWheelEvents()
targetID and scroll directions, it will be replaced by
the current one, subject to collapseWheelEvents, with the delta offsets in the
"collapsed" event getting adjusted to be the sum of those from all the original events. Includes the eventType mouseWheel.
public EventStream setCollapseKeyEvents(boolean collapseKeyEvents) throws java.lang.IllegalStateException
keyPress events into one event where possible. Self-inserting keys will
generally be collapsed by concatenating them into a single string, EventStreamEvent.keyNames. On the other hand, special
keys such as "Esc" and "Backspace" will only be collapsed for repeating sequences of the same key, which will be
reported as EventStreamEvent.count. Note that if
an error is thrown while handling an event, it won't be collapsed, but see minErrorReportingInterval.
collapseKeyEvents - New collapseKeyEvents value. Default value is trueEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdsetCaptureKeyEvents(boolean)public boolean getCollapseKeyEvents()
keyPress events into one event where possible. Self-inserting keys will
generally be collapsed by concatenating them into a single string, EventStreamEvent.keyNames. On the other hand, special
keys such as "Esc" and "Backspace" will only be collapsed for repeating sequences of the same key, which will be
reported as EventStreamEvent.count. Note that if
an error is thrown while handling an event, it won't be collapsed, but see minErrorReportingInterval.
getCaptureKeyEvents()public EventStream setCollapseMoveEvents(boolean collapseMoveEvents) throws java.lang.IllegalStateException
eventType and targetID should be collapsed into a single event.
Note that if an error is thrown while handling an event, it won't be collapsed, but see minErrorReportingInterval.
collapseMoveEvents - New collapseMoveEvents value. Default value is trueEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdsetCaptureMoveEvents(boolean)public boolean getCollapseMoveEvents()
eventType and targetID should be collapsed into a single event.
Note that if an error is thrown while handling an event, it won't be collapsed, but see minErrorReportingInterval.
getCaptureMoveEvents()public EventStream setCollapsePageEvents(boolean collapsePageEvents) throws java.lang.IllegalStateException
eventType should be collapsed into a single event. Note that if an error is thrown while handling an event, it
won't be collapsed, but see minErrorReportingInterval.
collapsePageEvents - New collapsePageEvents value. Default value is trueEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdsetCapturePageEvents(boolean)public boolean getCollapsePageEvents()
eventType should be collapsed into a single event. Note that if an error is thrown while handling an event, it
won't be collapsed, but see minErrorReportingInterval.
getCapturePageEvents()public EventStream setCollapseWheelEvents(boolean collapseWheelEvents) throws java.lang.IllegalStateException
targetID
and scroll directions should be collapsed into a single event, containing a sum of the delta offsets from the original events. Note that if an
error is thrown while handling an event, it won't be collapsed, but see minErrorReportingInterval.
collapseWheelEvents - New collapseWheelEvents value. Default value is trueEventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdsetCaptureWheelEvents(boolean)public boolean getCollapseWheelEvents()
targetID
and scroll directions should be collapsed into a single event, containing a sum of the delta offsets from the original events. Note that if an
error is thrown while handling an event, it won't be collapsed, but see minErrorReportingInterval.
getCaptureWheelEvents()public EventStream setMaxSize(java.lang.Integer maxSize) throws java.lang.IllegalStateException
EventStream. After maxSize events are
captured, the oldest events will be overwritten. Set this property to null to capture events without ever
overwriting.maxSize - New maxSize value. Default value is 10000EventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdpublic java.lang.Integer getMaxSize()
EventStream. After maxSize events are
captured, the oldest events will be overwritten. Set this property to null to capture events without ever
overwriting.public EventStream setMinErrorReportingInterval(int minErrorReportingInterval) throws java.lang.IllegalStateException
Note that when an error
is reported by the Framework, this property will be ignored if the last captured event triggered the error and has no
errorTrace, so that it effectively only prevents
adding new events to the stream specifically to report errors. However, an errorTrace attached to an event within the reporting
interval of the previous error won't prevent that event from being collapsed.
minErrorReportingInterval - New minErrorReportingInterval value. Default value is 10EventStream instance, for chaining setter callsjava.lang.IllegalStateException - this property cannot be changed after the underlying component has been createdsetCollapseMoveEvents(boolean),
setCollapseKeyEvents(boolean),
setCollapseWheelEvents(boolean),
setCollapsePageEvents(boolean)public int getMinErrorReportingInterval()
Note that when an error
is reported by the Framework, this property will be ignored if the last captured event triggered the error and has no
errorTrace, so that it effectively only prevents
adding new events to the stream specifically to report errors. However, an errorTrace attached to an event within the reporting
interval of the previous error won't prevent that event from being collapsed.
getCollapseMoveEvents(),
getCollapseKeyEvents(),
getCollapseWheelEvents(),
getCollapsePageEvents()public EventStreamData end()
EventStreamData. Once ended, capturing
cannot be restarted without losing all stored events.getAutoStart(),
start()public SeleniumCommand[] getAsSeleneseCommands()
Selenium commands. Compare with getAsSeleneseHTML(), where you'll also find more common
details. Just as when retrieving the Selenese as HTML, if a transformSelenese() function has been defined, it's
called before returning the Selenese.
Automated Testingpublic SeleniumCommand[] getAsSeleneseCommands(SeleneseSettings settings)
Selenium commands. Compare with getAsSeleneseHTML(), where you'll also find more common
details. Just as when retrieving the Selenese as HTML, if a transformSelenese() function has been defined, it's
called before returning the Selenese.
settings - Automated Testingpublic java.lang.String getAsSeleneseHTML()
Selenium overview.
This method returns the Selenese as a string of HTML table rows, just as in an rctest.html
file that you can directly execute with Selenium. Does not include the leading or trailing
HTML, such as the <BODY> and <TBODY> tags; you'll need to wrap what's returned
with the appropriate outer HTML tags to properly embed the table. If you'd rather have the
Selenese returned as an array of Selenium commands, call
getAsSeleneseCommands() instead.
To customize the returned Selenese, see transformSelenese(). Note that if the
stream has rolled over, the Selenese for the lost events
will not be
returned.
For example, in your Entrypoint class definition, you can declare a stream
member like:
EventStream eventStream = new EventStream();
... time passes where end user is interacting with your app ....
Then to retrieve the Selenese you can call something like:
String rcTestHTML = "<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">" +
"<body><table><tbody>" +
MyApp.eventStream.getAsSeleneseHTML(true) +
"</tbody></table></body></html>";
HTMLAutomated Testingpublic java.lang.String getAsSeleneseHTML(SeleneseSettings settings)
Selenium overview.
This method returns the Selenese as a string of HTML table rows, just as in an rctest.html
file that you can directly execute with Selenium. Does not include the leading or trailing
HTML, such as the <BODY> and <TBODY> tags; you'll need to wrap what's returned
with the appropriate outer HTML tags to properly embed the table. If you'd rather have the
Selenese returned as an array of Selenium commands, call
getAsSeleneseCommands() instead.
To customize the returned Selenese, see transformSelenese(). Note that if the
stream has rolled over, the Selenese for the lost events
will not be
returned.
For example, in your Entrypoint class definition, you can declare a stream
member like:
EventStream eventStream = new EventStream();
... time passes where end user is interacting with your app ....
Then to retrieve the Selenese you can call something like:
String rcTestHTML = "<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">" +
"<body><table><tbody>" +
MyApp.eventStream.getAsSeleneseHTML(true) +
"</tbody></table></body></html>";
settings - HTMLAutomated Testingpublic EventStreamEvent[] getEvents()
maxSize events will be returned.end()public java.util.Date getStartTime()
start() got called).start(),
getAutoStart()public void setEventErrorListener(EventErrorCallback callback)
event error, subject to the error reporting interval. The callback will
be passed all retained EventStreamEvents captured by the stream since the last
time it was called.callback - Callback to fire when the stream encounters an event error, subject to the
reporting intervalgetMaxSize(),
getMinErrorReportingInterval()public void start()
EventStream for a
list of filter properties you can configure to control which events are captured. If called after end(), capturing will restart, but all previously stored events will
be lost.
getAutoStart(),
end()