Events

<< <%SKIN-STRTRANS-SYNTOC%> >>

Navigation:  Agent Commands > Action Commands > Action Configuration >

Events

If a command action type is set to fire events, then you can specify the events that should be fired on the selected web element.

 

Action Command - Action Events

The Events tab

 

In most cases, you can check the Use default events check box, which will fire all appropriate events that the web element supports. In special cases, you may want to remove some of the default events. For example, an action may try to open a drop-down box for an input form field.

 

Firing the focus or click event on the input form field may cause the drop-down box to open, but the blur event may cause the drop-down box to close. In that case, firing all the default events would open the drop-down box but quickly close it again. To prevent this, uncheck the Use default events box and remove the blur event from the list.

 

Supported Events and Functions

 

Content Grabber supports all the default events for the chosen web element and some custom events and functions. The following list includes only the most common events, and is not a complete list of all available events. Please see a JavaScript reference guide for all available events.

 

Event Name

Description

mousedown

Emulates the press of a mouse button onto the chosen web element without releasing the button.

mouseup

Following a mousedown event, emulates releasing a mouse button onto the chosen web element.

click

In immediate succession, emulates a press and a release of a mouse button on the chosen web element .

keydown

Emulates pressing a key in relation to the chosen web element without releasing it.

keyup

Emulates releasing a key in relation to the chosen web element .

keypress

In immediate succession, emulates a press and a release of a key in relation to the chosen web element.

focus

Emulates bringing input focus to the chosen web element.

blur

Emulates removing input focus to the chosen web element.

change

Emulates changing the input value of the chosen web element.

 

The following list includes custom functions that can be used along with the standard events:

Function

Description

exec(JavaScript)

Executes a JavaScript on the selected web element.

 

Example 1:   exec($(element).unbind('blur'))

 

This example removes all blur events from the chosen web element. This example requires JQuery to be available on the web page, but the exec function works on non-JQuery JavaScript as well.

 

Example 2:   exec(element.click())

 

This example fires the click event on the selected web element.

 

Example 3:   exec(window.history.back())

 

This example moved the current page back to the previous page.

 

The variable element is always defined as the selected web element.

unbind(Event)

Removes all events of type Event from the selected web element. This function requires JQuery to be available on the web page.

 

Example:     unbind(blur)

 

This example is equivalent to calling exec($(element).unbind('blur')) or exec($(element).off('blur'))

click()

Fires the following 3 events:

mousedown

mouseup

click

delay(milliseconds)

Pauses execution of the command for a specific number of milliseconds.

 

Example:     delay(2000)

 

This example inserts a delay of 2 seconds.

 

Important note: The activity timeouts include any event delay. So, if you have a single activity that waits 500 milliseconds, and all events take longer than 500 milliseconds to fire, then the action will time out before all the events have had time to fire.

setinputtext()

 

setinputtext(text)

The function inserts text into the chosen form field, and is only compatible with Form Field commands. If the form field is a select box, the function selects the option with the text attribute equal to the specified text.

 

If this function call contains no text, the function inserts the input data for the Form Field command.

 

Example: sendinputtext("hotels")

 

Typically, a Form Field command sets the value of the chosen form field and then fires the specifies events. This function gives you the ability to fire events before setting the value of a form field.

 

NOTE: Often, this function is used when the corresponding Form Field command property Set Value is set to false.

sendtext()

 

sendtext(text)

This function activates the web browser, sets the focus to the chosen web element, and sends text to that element. This will trigger the same events as standard user input and may be necessary for some very complex websites-sites on which it can be very difficult to determine the exact order of events.

 

If the function call contains no text, the function inserts the input data for the Form Field command.

 

Example: sendtext("hotels")

 

This will send the text "hotels" to the chosen web element.

 

Some complex websites may open a drop-down when a user enters text into an input box, and the drop-down box may close automatically when the focus moves away from the input box. When you are working in the Content Grabber designer, the input focus automatically moves off the web browser after an action executes, so you may need to remove the blur events from the chosen web element.

 

Example:     unbind(blur)

                  sendtext("hotels")

 

NOTE: the unbind function requires JQuery to be available on the web page.

sendkey(keycode)

This function activates the web browser, sets the focus to the chosen web element, and sends a key code to that element. This will trigger the same events as standard user input and maybe required for some very complex websites where it can be very difficult to determine the exact order of events.

 

Example:     sendkey(down)

                  sendkey(return)

 

This will send two instructions to the chosen web element: one instruction that is equivalent to a press of the down arrow key and another instruction that is equivalent to a press of the Return key.

 

Some complex websites may open a drop-down when a user enters text into an input box, and the drop-down box may close automatically when the focus moves away from the input box. When you are working in the Content Grabber designer, the input focus automatically moves off the web browser after an action executes, so you may need to remove the blur events from the chosen web element.

 

Example:     unbind(blur)

         sendkey(down)

                 

NOTE: the unbind function requires JQuery to be available on the web page.

scroll()

 

scroll(percentage)

This function scrolls downward on the page containing the chosen web element, to ensure adequate coverage for pages that load content dynamically.

 

Often, the function call is used along with the option Repeat Link Action, which will repeat a downward scroll to the bottom-until the scroll no longer loads new content.

 

Example 1:       scroll()

 

This example will scroll all the way to the bottom of the content. Optionally, you can specify an the amount to scroll in terms of percentage.

 

Example 2:       scroll(50)

 

This example will scroll half way down through the content.

windowscroll()

 

windowscroll

(percentage)

This function scrolls down to the bottom of the page containing the chosen web element, to ensure adequate coverage for pages that load content dynamically.

 

If the web browser contains multiple frames, you should choose a web element within the frame to which you want to scroll. The chosen web element has no other influence on this function.

 
Often, the function call is used along with the option Repeat Link Action, which will repeat a downward scroll to the bottom - until the scroll no longer loads new content.

 

The Scroll to End of Page action option combines the windowscroll event with the action option Repeat Link Action, so this option can be used as an alternative to the windowscroll function.

 

Example 1:       windowscroll()

 

This example will scroll all the way to the bottom of the web page. Optionally, you can specify an the amount to scroll in terms of percentage.

 

Example 2:       windowscroll(50)

 

This example will scroll half way down the web page.

Back()

Move back to the previous page by calling the JavaScript function window.history.back()

 

If the action command is a Form Field, then the input value is available for all event functions by using the variable [input]. For example, you can call the function sendtext to set the input value of a form field:

 

 sendtext([input])

 

Or, the input value could be set using JQuery:

 

 exec($(element).val('[input]'))

 

If you set a form field value using any of these event functions, you may want to uncheck the form field box Set Value, so that the form field value cannot be set automatically, but rather only by an event function.

 

Query Selectors & Google's Geolocation Search

JavaScript query selectors can be used to fire events on other web elements than the action web element. Query selectors must be specified before the event name and must be enclosed in double quotes.

 

Example:

 

"#search".focus

 

The above event configuration fires the focus event on a web element with the ID search.

 

One important application for query selectors are websites using Google's Geolocation Search. The following event configuration is required to select a drop down item in the Google's Geolocation Search plugin.

 

"#search".focus

mouseover

"#search".blur

 

where search is the ID of the input field used by Google's Geolocation Search. This input field is custom defined, so you may need to use different query selectors for different websites. For example, if the Geolocation Search uses an input field name name city, the event configuration would look like this:

 

"input[name='city']".focus

mouseover

"input[name='city']".blur