WUX monitoring with WUX server and Selenium 3

Introduction

User experience monitoring consists of making recordings of automated tasks of both web browsing (PWR/WUX) and interaction with the desktop and Windows system applications (PDR). These recordings can range from a mouse click on a web browser, typing text or performing a web search, to opening an application on the desktop. This allows functions to be configured and automatically recorded for later execution in search of results.

Differences between UX and WUX monitoring

Both monitoring systems are used to execute automated web browsing tasks using Pandora Web Robot Daemon (PWRD) system.

The UX system performs these monitoring tasks using the software agent installed on a machine, while WUX monitoring is based on a server integrated within Pandora FMS.

Pandora Web Robot Daemon (PWRD) is a service that provides the necessary tools to automate web browsing sessions. To do it, it uses a file that contains a list of the actions necessary to navigate the user's web portal.

Additionally, UX monitoring enables the execution of the automated tasks that interact with MS Windows® desktop and system applications. These types of tasks cannot be performed with WUX.

Pandora FMS UX is a system that executes automated tasks, giving Pandora FMS a report with the execution results, time spent and screenshots with the errors that may be found.

If you have a task automation system, Pandora FMS UX also allows you to execute the scripts you already have and monitor their execution.

It is important to specify the use of this type of monitoring. Both methods are based on monitoring execution by means of a plugin in the software agents installed in the corresponding machines.

PWR UX monitoring

Taking into account the differences between UX and WUX monitoring, UX monitoring must follow a series of prerequisites related to the environment to be monitored, with the following previous steps:

  • Install Java®.
  • Configure a profile in Mozilla Firefox®.
  • Install a Selenium® service.
  • Distribute PWR on the system.
  • Install the Selenium® IDE for Mozilla Firefox®.
  • Save a PWR session.

For the standard execution of pre-recorded sessions use the Pandora UX Plugin in its latest version 28-04-2022.

Web User Experience (WUX) with Selenium 3

For Selenium deployment on WUX servers, a container-based stack will be used for fast deployment and easy scaling.

Previous settings

Docker and Docker Compose must be previously installed.

For this installation, we recommend following the Docker documentation at:

The official Selenium images will be used for the installation and deployment of the stack. You may find them at:

Different images with browsers are available in the Selenium repository. For Pandora FMS, we recommend Firefox® and Chrome® containers.

Selenium Stack Deployment

To deploy the Selenium stack, it will be necessary to first create a YAML file with the necessary configuration:

# To execute this docker-compose yml file use `docker-compose -f  up`
# Add the `-d` flag at the end for detached execution
version: "3"
services:
  selenium-hub:
    image: pandorafms/pandorafms-selenium-hub
    mem_limit: 2G
    container_name: selenium-hub-v3
    logging:
        driver: "json-file"
        options:
            max-file: "5"
            max-size: "4m"
            mode: "non-blocking"
    environment:
      - TZ=Europe/Amsterdam
    ports:
      - "4444:4444"

  chrome:
    image: pandorafms/pandorafms-selenium-node-chrome
    mem_limit: 2G
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
    logging:
        driver: "json-file"
        options:
            max-file: "5"
            max-size: "4m"
            mode: "non-blocking"
    environment:
      - TZ=Europe/Amsterdam
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444

  firefox:
    image: pandorafms/pandorafms-selenium-node-firefox
    mem_limit: 2G
    volumes:
      - /dev/shm:/dev/shm
    depends_on:
      - selenium-hub
    logging:
        driver: "json-file"
        options:
            max-file: "5"
            max-size: "4m"
            mode: "non-blocking"
    environment:
      - TZ=Europe/Amsterdam
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444

In the previous example, make the necessary modifications for each case, such as memory limit, time zone, number of nodes, etc.

It can be saved as docker-compose.yml to make identifying it easier.

To activate the container with the defined settings, just run the following command (replace <compose-file> with the name you chose for the file):

docker-compose -f <compose-file> up -d

To check the services running in the container, use the following command:

docker-compose -f <compose-file> ps

To see the status and logs of Selenium services, use the following command:

docker-compose -f <compose-file> logs

Once the appropriate checks have been made, to verify the grid works properly and the workers have signed up as you defined in the configuration file, go to the following URL:

http://<ip_selenium_server>:4444/grid/console

If you need to increase the number of workers, just run the following command:

docker-compose -f <compose-file> scale chrome=X firefox=Y

Selenium service infrastructure

Selenium works as a hub where a container, that works as a grid where to deploy the necessary worker containers, is enabled.

Pandora FMS Configuration

To use the centralized mode (WUX) it will be necessary to apply the following configuration to the Pandora FMS server.

Regardless of the chosen mode, once started you may start assigning executions from your browsing sessions, adding the WUX Server configuration parameters to the configuration file of your Pandora FMS server.

Add the following configuration ath the end of the file /etc/pandora/pandora_server.conf (replace <ip_wux_host> by the server's IP address, if it is the same server where Pandora FMS use server runs 127.0.0.1):

 wuxserver 1
 wux_host <ip_wux_host>
 wux_port 4444

The configuration file of Pandora FMS server has a new token to clean queued navigation sessions.

clean_wux_sessions 1 #(default)

Pandora FMS Threads Management

  • The wuxserver threads management is done automatically when starting the pandora_server service.
  • It is done taking into account the number of nodes of a MINOR browser that is in the Selenium hub. For example:
    • If in the hub there are configured 2 Firefox and 2 Chrome nodes, the number of wuxserver threads will be 2.
    • If 1 Firefox node and 4 Chrome nodes are configured in the hub, the number of threads will be 1.
    • If 6 Firefox nodes are configured in the hub, the number of threads will be 6.

Note that each thread indicates the sessions that can be sent simultaneously from the wuxserver to the Selenium hub.

Appendix: Add workers for Internet Explorer and Microsoft Edge

If it is necessary to launch web transactions against Microsoft® browsers, it will be necessary to configure a machine (physical or virtual) with the desired Windows® version and configure the driver following the official documentation.

Internet Explorer® driver installation documentation:

github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver

We recommend using driver 3.141 version 32bit to avoid performance 64bit version problems.

Microsoft Edge® driver installation documentation:

https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/

To run Selenium, Java® must be installed on the Windows® device.

To check whether Java® is installed, run this command:

java -version

You should get an output like the following:

The Selenium JAR file will also be required to run the server locally and register it on your grid.

It can be obtained at:

https://www.selenium.dev/downloads/

To activate the Microsoft Edge® server, the following must be run in a terminal in the directory where you have the JAR file:

java -jar selenium-server-standalone-<VER>.jar -port 5555 -role node -hub
http://<ip_selenium_server>:4444/grid/register -browser "browserName=MicrosoftEdge, platform=WINDOWS, maxInstances=1"

The command is similar to activate the Internet Explorer® server, but the path of the downloaded driver must be specified:

java -Dwebdriver.ie.driver=<PATH>IEDriverServer.exe -jar selenium-server-standalone<VER>.jar -port 5555 -role node -hub
http://ip_selenium_server:4444/grid/register -browser "browserName=internet explorer, platform=WINDOWS, maxInstances=1"

The Windows Firewall must be configured to allow traffic on the ports specified in the run command. In the case of examples 5555 and 4444.

Recording

For Selenium version 3, both old and new recordings will be supported.

In order to record a new session, the Selenium IDE extension must be installed in the desired browser.

Firefox

https://addons.mozilla.org/es/firefox/addon/selenium-ide/

Chrome

https://chrome.google.com/webstore/detail/selenium-ide/mooikfkahbdckldjjndioackbalphokd

The next icon will be the one that allows to start the recording environment once the extension is installed.

A menu that will allow to start new recording projects will open.

Once the recording is made, it will result in something like the following:

Apart from the feature provided by Selenium, Pandora FMS has custom commands to retrieve information from the target to be monitored.

Commands

The list of compatible commands available can be found here.

Recommendations and suggestions when making the recordings

Next, we detail a series of recommendations and advices to make the recording of the transactions with Selenium IDE as well as to integrate the most complex commands with Pandora FMS:

  • Divide the transaction in phases whenever it is possible. In this way, the modules created of state, times and screenshots will be segmented and they will be easier to locate when the transaction has failed.
  • Use the selenium command set speed and wait for to avoid false negatives. When executing a transaction, the selenium commands don't have any default delay from the end of one until the next one is executed, and some of them don't have timeout either. This makes the transaction run in the shortest time possible, but by doing it so quickly, if the web is somewhat slow or takes an extra second to load it is possible that the check will end in failure. For instance, after executing a click command and go to other page, if we then have a command that interacts with an element on the new page and the loading of this is delayed by one second, it will not find the element on the new page and the check will end in failure. To avoid these situations, there is the command set speed, which adds a delay of the amount of milliseconds that we indicate in the Target field between each command. We recommend to set it at the beginning of the transaction. There are also for cases where we know that the loading of a page or the appearance of an element can take a few seconds, the commands wait for element present, wait for visible and wait for text in which we can set the time in milliseconds that will wait for the element to appear on the page before marking the transaction as a failure. It is important to emphasize that the use of these commands, although they increase very much the reliability of the check, they will also increase the time that it takes to execute the transaction.
  • Checking the existing elements. For this we will use commands like assert and verify, in their different aspects. Finishing a transaction with a click, for example, does not guarantee that the new page that should open the element you clicked on will open, only guarantee that it is possible to click on the element. If after the click we introduce a verify text to a text that we know will only be loaded after the click, it would be a way to check that the page that the click sends us is available.
  • Usestore window handle in transactions where you are going to navigate between windows or tabs. The change of window (with a select window) can give failure if you have not previously stored an identifier to the initial window.
  • Use xpath when the Target by CSS identifier fails or when we want to search content in the page. By default, the Selenium IDE recorder load in the Target of the element the CSS locator, but it also loads the locator by xpath, it is possible to see all the locators that it saves if we click on the Target box in the recorder:In addition, when using xpath, it is possible to search texts inside the tags of the pages to make more dynamic recordings. In the previous capture we see that it is possible to use an xpath that looks for the text “Monitoring Innovators” in all the span tags of the page, not in a specific locator.
  • Correct use of theexecute script command. This command executes a snippet of JavaScript in the context of the currently selected frame or window. We recommend to read this guide to learn about its use and the different options that it offers: https://ui.vision/rpa/docs/selenium-ide/executescript However, the use of the variables previously stored (by a store text command for example) should go between double quotes so that the Pandora FMS webdriver interprets them correctly. Here is an example of a variable stored with store text and its later use in execute script so that the Pandora FMS server interprets it correctly. Note that this use of the variable between quotes will fail to execute the script in the Selenium IDE recorder:

Data management and display

Create a web analysis module in Pandora FMS Console

Once the browsing session is recorded, it is time to deploy it as a module in Pandora FMS console.

To do it, access any agent linked to a server with the WUX feature enabled and create a new module with the option Create a new web analysis module:

Once Create is selected, fill in all the fields the form presents:

Module name

WUX Module (Parent). All sub-modules with the monitoring results will rely on this new module.

Run performance tests

It indicates that you wish to monitor not only the browsing experience, but also the performance statistics of access to the target website.

Execute test from

Set the WUX server that will execute the test.

Browser

Web browser that will run the test.

The indicated browser must be on the Selenium grid or server used by the WUX server.

User data dir

(Version 764 or later) Optional: It allows you to specify a data directory.

User data dir option only works on Google Chrome web browser.


Profile

(Version 764 or later) Optional: It allows to specify a user profile. If the profile name does not exist, use the default profile.

The Profile option only works on Google Chrome web browser.

Accept insecure certificates

If enabled, any insecure certificate (self-signed, expired, etc.) that is part of the navigation will be accepted.

This option is only available for Google Chrome and Mozilla Firefox browsers, and will only take effect if the test is run by a Selenium 3 server.

Data history

To save or not the historical information of the modules that monitor this user experience.

Text area section

Text box where to copy (or load) the content of the files from the browsing session that you previously recorded.

FF interval

Module execution flip flop time interval (in seconds).

Retries

Number of module launch retries.

Custom macros

Custom macros enabled involve replacing certain text strings present in your browsing session file with certain custom values.

This feature has been improved for web analysis modules, enabling dynamic macros that allow these values to be translated into variable dates and times.

Why this feature?

Suppose you need to monitor, through a browsing session, the correct operation of a meeting room booking web application.

If you set a fixed date and time when filling in the form data, it is possible that the system canceled the booking because at some point it is in the past. For example, you might be trying to book a room for the past week.

It is also possible that you find a time limit to make that reservation, and that the system forces you to book the room within a specific time period, for example, no farther than the current month.

To avoid having to edit the macro every few days, and not worry about the configuration section, you may use dynamic macros, telling the system to always book the room for the next day at the time of performing the test.

In order to use this feature, the values must have a specific format, achieving the following possible replacements:

  • @DATE_FORMAT current date/time with user-defined format.
  • @DATE_FORMAT_nh hours.
  • @DATE_FORMAT_nm minutes.
  • @DATE_FORMAT_nd days.
  • @DATE_FORMAT_ns seconds.
  • @DATE_FORMAT_nM month.
  • @DATE_FORMAT_nY year.

Where “n” can be an unsigned (positive) or negative number.

And FORMAT follows the standard of strftime of perl

For example:

 @DATE_%Y-%m-%d %H:%M:%S
 @DATE_%H:%M:%S_300s
 @DATE_%H:%M:%S_-1h

Data display

The information generated by WUX will be displayed in the form of modules as follows. Enabling the view in hierarchical mode in the module list will help you see the information much more clearly:

Within this hierarchy you find the following modules:

  • module_Global_Status: It will indicate the global state of the complete navigation.
    • If there is a recording, it gives the status of the WUX recording.
    • In the case that the run performance Test is enabled but the recording is not included, the Global Status module status is the status of the check that is performed when obtaining these modules.
  • module _ Global_Time: It will indicate the global time spent in full navigation.
  • module_ Global_Screenshot: It contains an image with the result of the navigation error, it will only be generated in case of error
  • module_Phase X: Phase name_ Status: It will indicate the navigation status during phase X.
  • module_Phase X: Phase name_Time: It will indicate the time spent in phase X.

Example: Error screenshot view.

Warning: If you have updated from previous versions to Pandora FMS 7.0NG 712, you must make a small change.

In order to store the screenshots generated by WUX Server, you will need to launch the following operations in your database schema:

 alter table tagente_estado modify column datos mediumtext;
 alter table tagente_datos_string modify column datos mediumtext;

Note: Pay attention to table names.

If you do not perform, you may not see the full screenshot.

By accessing the WUXsection of the agent, you may see additional details of the transaction and its stages:

Website statistics are summarized in the following concepts:

  • Stats_TT: Total time to load the website.
  • Stats_TDNS: Total time to solve the target's IP address.
  • Stats_TTCP: Time spent connecting through TCP.
  • Stats_TSSL: Time spent establishing SSL communication.
  • Stats_TST: Time elapsed until data transfer started.
  • Stats_TTC: Time transferring data. It will group all the resource transfer times.
  • Stats_TTR: Time taken to transfer the content of the page.
  • Stats_TTR_main: Time used to transfer the HTML code.
  • Stats_TTR_image: Time spent transferring image type resources (png|jpg|jpeg|bmp|tiff|gif|webp|svg).
  • Stats_TTR_css: Time taken to transfer style sheets.
  • Stats_TTR_js: Time spent transferring JavaScript files.

Assign alerts to a web analytics module

The alerts associated with the web analysis modules follow the same operating dynamics as the entire alert system in Pandora FMS.

For compatibility purposes, it is recommended to assign the alert templates on the sub-elements self-generated by the web analysis module, such as:

  • The status of global navigation.
  • Alerts about time thresholds.
  • Alerts with warning template set to “always” for result screenshot modules.

New widgets for Dashboards

In order to represent user navigation information, two new types of widgets have been added:

Navigation phase status widget:

Website statistics widget:

Compatible commands list

Internal Commands

  • run: It runs a test.
  • build_transaction: It prebuilds a transaction based on the past test (internal).
  • get_transaction: It returns the current transaction, always used to retrieve the results, the order of the stages and the variables.
  • sessions: It retrieves the list of sessions present in the hub.
  • kill_sessions: It deletes all existing sessions in the hub.

Extra Commands

  • extract: It combines source and own code for extraction.
  • storeExtraction: It stores the result of the extraction in a variable.
  • dispatchEvent: It fires a Javascript event on a given element.
  • takeElementScreenshot: It takes a screenshot of a specific element.
  • phase_start: It starts a stage and transforms the test into a WUX transaction.
  • phase_end: It completes a stage.

Commands that generate modules

  • getValue Retrieve a value:

getValue;module_name;module_type;REGEX_capture

  • getVariable It retrieves a specific alue from a variable:

getVariable;module_name;module_type;variable_name

  • getScreenshot Retrieves a screenshot:

getScreenshot;module_name

All own commands must appear in the test file (.side) as comments. Otherwise, it will fail to test the test in the Selenium extension.

Commands provided by the recording extension (v3)

  • addSelection
  • answerOnNextPrompt
  • assert
  • assertAlert
  • assertChecked
  • assertConfirmation
  • assertEditable
  • assertElementPresent
  • assertElementNotPresent
  • assertNotChecked
  • assertNotEditable
  • assertNotSelectedValue
  • assertNotText
  • assertPrompt
  • assertSelectedValue
  • assertSelectedLabel
  • assertText
  • assertTitle
  • assertValue
  • check
  • chooseCancelOnNextConfirmation
  • chooseCancelOnNextPrompt
  • chooseOkOnNextConfirmation
  • click
  • clickAt
  • close
  • doubleClick
  • doubleClickAt
  • dragAndDropToObject
  • echo
  • editContent
  • else
  • elseIf
  • end
  • executeScript
  • executeAsyncScript
  • if
  • mouseDown
  • mouseDownAt
  • mouseOver
  • mouseUp
  • mouseUpAt
  • open
  • pageLoadTimeout
  • pause
  • removeSelection
  • select
  • selectFrame
  • selectWindow
  • sendKeys
  • setSpeed
  • setWindowSize
  • store
  • storeAttribute
  • storeJson
  • storeText
  • storeTitle
  • storeValue
  • storeWindowHandle
  • storeXpathCount
  • submit
  • type
  • uncheck
  • verify
  • verifyChecked
  • verifyEditable
  • verifyElementPresent
  • verifyElementNotPresent
  • verifyNotChecked
  • verifyNotEditable
  • verifyNotSelectedValue
  • verifyNotText
  • verifySelectedLabel
  • verifySelectedValue
  • verifyText
  • verifyTitle
  • verifyValue
  • waitForElementEditable
  • waitForElementNotEditable
  • waitForElementNotPresent
  • waitForElementNotVisible
  • waitForElementPresent
  • waitForElementVisible
  • waitForText
  • webdriverAnswerOnVisiblePrompt
  • webdriverChooseCancelOnVisibleConfirmation
  • webdriverChooseOkOnVisibleConfirmation

Go back to Pandora FMS documentation index