View
422
Download
8
Tags:
Embed Size (px)
DESCRIPTION
This plugin uses the selenium tool to do web navigation simulations using an standard web browser. It generates two modules (generic_proc and generic_data types) for each task. For more information visit the following website: http://pandorafms.com/index.php?sec=Library&sec2=repository&lng=en&action=view_PUI&id_PUI=426
Citation preview
Pandora FMSAdministrator Manual
Selenium Plugin ( Web Navigation)
Administrator Manual PandoraFMS Selenium
© Artica Soluciones Tecnológicas 20052013
Index1changes...............................................................................................................................................32Introduction........................................................................................................................................43Compatibility matrix..........................................................................................................................54Documentation that the area that demands the monitoring should provide.......................................65modules...............................................................................................................................................76Selenium.............................................................................................................................................8
6.1.OpenSUSE.................................................................................................................................86.1.1.System Requirements.........................................................................................................86.1.2.Selenium Installation..........................................................................................................96.1.3.Selenium Execution...........................................................................................................9
6.2.Windows..................................................................................................................................126.2.1.System Requirements.......................................................................................................126.2.2.Selenium Installing..........................................................................................................126.2.3.Executing Selenium ........................................................................................................14
7Selenium Plugin in Pandora fms agent ............................................................................................177.1.Selenium Plugin Configuration ..............................................................................................17
8Selenium Firefox extension for PandoraFMS..................................................................................198.1.Installing the Selenium Extension in Firefox..........................................................................198.2.Use of the Selenium Extension in Firefox..............................................................................21
9Annexe: web monitoring Scripts .....................................................................................................239.1. Examples of Monitoring Scripts.............................................................................................239.2.Monitoring Scripts Command List..........................................................................................25
1 CHANGES
Date Autor Change Version
21/01/13 Miguel de Dios
Document first version v1r1
17/04/13 Mario P. Changes in Document v1r2
Page 3
2 INTRODUCTION
This document has as main objective the description of the monitoring using the Selenium tool that
is integrated in Pandora FMS
In order to do this, we have three tools:
• Selenium (http://seleniumhq.org/): Tool to do web navigation simulations using an
standard web browser.
• Pandora Agent Selenium Plugin, a plugin for the Linux Pandora FMS agents that generates
two modules by each task in the specified file:one that is the result of the task and the other
the time that it has spent doing this task in Selenium.
• Selenium IDE for Pandora FMS, an extension for Firefox to register one navigation as one
task for the Pandora Agent Selenium plugin.
Page 4
3 COMPATIBILITY MATRIX
Systems where it has been tested• Selenium Server Standalone 2.28.0• Java 7
Systems where it should work • Selenium Server Standalone 2.x• Java 7.x
Page 5
4 DOCUMENTATION THAT THE AREA THAT DEMANDS THE MONITORING SHOULD PROVIDE
The documentation to provide for the monitoring will be a file with the session registered by the
navigator recording that will be the data source to execute the plugin. The creation of this file will
be explained later.
Page 6
5 PLUGIN MODULES
The Selenium plugin generates two modules for each task:
• generic_proc: With the name that has the task in “task_begin” and it will be the result of the
navigation simulation.
• generic_data: That is in charge of the time counting that it takes doing the task, if it results
positive, or if it doesn't send it.
Page 7
6 SELENIUM
Selenium, as we have previously mentioned, is a web navigation simulation tool that does the task
getting the control of a browser and executing the tasks step by step. The Selenium is executed as a
demon in a second level and it does the comunication through port 4444 so it could be in a
different machine to the Pandora Agent that is in charge of the Selenium plugin.
6.1. OpenSUSE
6.1.1. System Requirements
The system requirements to install in an OpenSUSE 12.2:
• The Xorg graph sub system that is able to log graphically.
• Java virtual machine.
• Access to the port TCP 4444 from the machine that has the agent that will execute the
plugin.
• Access to the web navigation from this machine to the webs (intranet or internet) that
pretend to execute web monitoring tasks.
• Firefox or Chrome browser or other supported by Selenium (please, be careful, it should be
specified in the Pandora Agent plugin).
6.1.2. Selenium Installation
• If you are using OpenSUSE 12.2 by problems that the Oracle corporation gives to the Open
Source organizations, the Java package is not available in the OpenSUSE oficial repositories,
but you can download it from the following URL:
http://www.java.com/es/download/linux_manual.jsp?locale=es&host=www.java.com
• Download the version packaged in RPM with the link (Linux RPM) if your OpenSUSE is of
32bits and you have installed a system of 64bits with the link (Linux x64 RPM).
Page 8
And to install it you only need to execute with administrator permission:
sudo rpm ivh jre7u10linuxi586.rpm
• And download the Selenium jar package from the official web at:
http://seleniumhq.org/download/
That in this page could be found in the section named:
Selenium Server (formerly the Selenium RC Server)
6.1.3. Selenium Execution
To execute Selenium you only need to have a graphic session in the open machine (directly in the
machine or via VNC) and execute:
java jar seleniumserverstandalone2.28.0.jar
If we want to monitor any website with digital certificates, we run selenium selecting the user
folder who normally work on the computer (User default) located in /root/.mozilla/firefox/.
This will be the execution:
java jar seleniumserverstandalone2.28.0.jar firefoxProfileTemplate /root/.mozilla/
firefox/vx80.Default_User
Must be taken into mind that before running Selenium, you have to download all the certificates
that we will be required for the plugin execution works properly.
To test that Selenium works you only need to enter in a browser in the machine at the URL
http://localhost:4444/wd/hub
Page 9
And you should see something like this screenshot:
And create one Session with the browser that you are going to use for the Web monitoring as you
can see here:
Page 10
And it will show a session in the “Sessions” list in this page, such as the following screeshot shows:
And it also have executed a navigator (Firefox for me) in the machine.
Once the Selenium has been tested, you can destroy the session, so the Pandora Agent Plugin will
be in charge of creating the sessions an execute them automatically.
Page 11
6.2. Windows
6.2.1. System Requirements
The system requirements are:
• Java virtual machine
• Access to the port TCP 4444 from that machine that the agent who will execute the plugin
has.
• Access to the web navigation from this machine to the webs (intranet or internet) that want
to execute web monitoring tasks.
• Firefox or Chrome browsers or other supported by Selenium (please, consider that you
should specify this in the Pandora Agent plugin).
◦ For browsers differents to Firefox, it is necessary to install the “drivers” for each browser.
6.2.2. Selenium Installing
The steps to install Selenium in Microsoft Windows.
• Due to problems of the Microsoft corporation with Oracle, the Java package is not available
in the OpenSUSE official repositories, but you can download it from the following URL:
http://www.java.com
• And download the Selenium jar package from the official web at:
http://seleniumhq.org/download/
• That in this page you can find in the section with the following name:
Selenium Server (formerly the Selenium RC Server)
• To execute the monitoring in the Firefox browser you don't need to do anything, except
having it installed in this machine.
Page 12
• To execute the web navigation monitoring in other browsers, it's necessary to install the
“driver”, fro example to use the Microsoft Internet Explorer (browser that doesn't fulfill the
web standards, but is widely used in desk environments but not in the state of the art
telephony that is almost all derived from the Webkit free engine).
http://code.google.com/p/selenium/downloads/list
http://code.google.com/p/selenium/downloads/detail?
name=IEDriverServer_Win32_2.29.0.zip&can=2&q =
• And copy the executable to IEDriverServer.exe to the execution PATH the the windows in
the machine has.
• Besides, due to an error in Microsoft Internet Explorer is necessary to uncheck in all the
security profiles (Internet, Local Intranet, reliable sites and restricted sites) the option
“Enable Protected Mode” as the following screenshot shows:
Page 13
6.2.3. Executing Selenium
To execute Selenium you only need to have a graphical session in the open machine (directly in the
machine or via VNC) and execute, depending on the Windows version it will ask you to confirm the
permissions of jar execution, as for example passing through the Microsoft Windows firewall:
java jar seleniumserverstandalone2.28.0.jar
To test that Selenium works you only need to enter a browser in the machine to the URL
http://localhost:4444/wd/hub
And you should see something like this:
Page 14
And then create one Session with the browser that you are going to use for the Web monitoring as
we can see in this screenshot.
Then it will show one session in the list “Sessions” of this page, like this screenshot shows:
Besides, it should have executed a browser (Firefox for me) in the machine.
Once the Selenium is tested, you can delete the session, because the Pandora Agent plugin
Page 15
will be in charge of creating sessions and execute them automatically.
7 SELENIUM PLUGIN IN PANDORA FMS AGENT In the machine where the Pandora FMS agent is you should have installed the Enterprise package of
the agent. So in the directory:
/usr/share/pandora_agent/plugins
You need to have the plugin file:
SeleniumPlugin.pl
The Selenium plugin generates two modules for each task:
• generic_proc: With the name that the task would have in “task_begin” and it will be the
result of the navigation simulation.
• generic_data: That counts the time that it takes to do the task, in case it would be positive, if
not it will not send it.
7.1. Selenium Plugin Configuration
From the agent remote configuration edition in the Pandora console, as you can see in this
screenshot:
Page 16
And add one line similar to the one that is marked in red, for example:
module_plugin SeleniumPlugin.pl /var/selenium_plugin_example 192.168.70.198 4444 *iexplore
Where it is:
module_plugin SeleniumPlugin.pl <path_script_tareas_monitorización> <ip_selenium>
<puerto_selenium> <navegador>
And the parameters are:
• path_script_tareas_monitorización: The path to the task script that should have reading
permission from the Pandora agent.
• ip_selenium: The ip from the machine that is executing the Selenium.
• puerto_selenium: The port of the Selenium server, that is usually the 4444.
• navegador: The browser where doing the navigation simulation . You have two options:
*iexplore (only windows) and *firefox (for both is compulsory to have it installed in the
Selenium machine).
The task script could be created in a manual way with a simple text editor or with the tool that we
are going to explain in other sections of this manual, the Selenium Firefox extension for Pandora
FMS. Anyway, you will have an annex with information to create from a text editor or edit one
created by the Firefox extension.
Page 17
8 SELENIUM FIREFOX EXTENSION FOR PANDORAFMSThe Selenium Firefox extension gives you a tool to generate the navigation simulation, saving the
navigation that you do.
8.1. Installing the Selenium Extension in Firefox
The extension will be in an XPI file, so it would be necessary to have a Firefox with version 4 or
higher.
To install it you should go to Menu Tools Complements as you can see in this screenshot.→ →
Page 18
And in the modules window in the “Option button” “To install complement from file...” in the →
dialog box select the extension XPI file.
Firefox will show a security confirmation window with the Installing button disabled for some
seconds so you take your time for reading the warning message of this window, as is show in the
following screenshot. These windows are commons when installing any extension that is not the
official Firefox extension page.
After this, it will ask you to restart the Firefox.
Page 19
And if all is right the installation will be available in the menu:
8.2. Use of the Selenium Extension in Firefox
The tool is quite easy, and mainly it consist in opening the tool, click the save button, browse,
clicking stop and saving it it a file. However we are going to explain it with more detail:
To enable the Selenium extension go to Menu Tools “Selenium IDE for PandoraFMS” and it will →
open a window like the one that is on this screenshot. A complex window, but where only three
control are used.
Page 20
The controls that you will use are:
• Saving button: The one that is on top at the righ side, and that when activate all the
navigation options will be saved in the window.
• Action list: The one that is in the middle of the window. This will be filling in with the
navigation actions that you do, they even could be edit or you can add more from here.
• File Menu: the one that is on top at the left side. You only need to click on “Save test
case”once the navigation is over.
Since version V2R1 Pandora Selenium plugin for Firefox, keeps both two types of files, the first is a
file format for use with Pandora plugin for Selenium agent Pandora, and the second is a file
selenium format plugin for firefox. The second file can be used to enlarge or edit easily from firefox.
A very interesting thing is that the check option that exist to search an specific text in the web that
is trying to monitor, for example, in the web navigation for a filling in form that when is sucessfully
fulfilled returns a text like for example “correct operation” or in the search form that show an
specific product in the search. And from the contextual menu once a text is selected you have this
option to add this step to the script, as you can see in the following shootscreeen:
Page 21
Page 22
9 ANNEXE: WEB MONITORING SCRIPTS The Web Monitoring Scripts are in plain text and are executed in a sequential way. You should
consider that not all the commands from the Firefox command are supported, but the Selenium
more common ones are supported. Besides, the extension doesn't support all the monitoring
commands.
9.1. Examples of Monitoring Scripts
All of them are generated by the Firefox extension:
Check that in the Pandora FMS Demo would be the agent “Summarize Energy Data” in the agent
list and in an unknow status.
Page 23
task_begin http://firefly.artica.es/pandora_demo/index.phpopen http://firefly.artica.es/pandora_demo/index.phptype id=nick,demotype id=pass,democlick id=imageLogin1wait_for_page_to_load 5000click css=img.toggleclick link=Vista de agenteswait_for_page_to_load 5000click id=group_idselect id=group_id,label=regexp:\s+Energy Efficiencywait_for_page_to_load 5000click css=option[value="19"]click id=statusclick id=statusselect id=status,label=Desconocidowait_for_page_to_load 5000click id=textsearchtype id=textsearch,Sclick id=submitsrcbuttonwait_for_page_to_load 5000is_text_present Summarize Energy Datatask_end
It is possible to remark from the code with educative aim the following command lines:
• The scripts though they would be several in only one file start with a command line:
“task_begin” and “task_end”, besides “task_begin” has as parameter the name of the scritp
and that of the two modules that it is going to create (one for status or data got from the
web) and other for the time in seconds that the web monitoring has taken.) when the script
is generated by the Firefox extension is the complete URL of the navigation simulation.
• Always, after the “task_begin” comes the “open” command that has as parameter the
complete URL where the navigation is started.
• Commands like “type” or “select” use to have two parameters: the first one is the aim of the
action (it's usually an id html or other element that identifies this item at an html code level)
and the second is separared by a comma (please, be careful not to put blank spaces) is the
value that is entered in the text box or that is selected if it is a dropdown menu.
• During navigation you pass from one page to another in the same domain or not , this takes
time for loading pages, so it is necessary to put the command “wait_for_page_to_load” in
the middle and after the parameter in miliseconds and not recive that the script has not
been configured right. So consider that though it has a high time parameter it won't affect to
the time module that it takes executing the web monitoring. It's only a time to wait for the
web loads correctly.
• Usually, to end the process, you will have a command “is_text_present” followed by the text
or regular expression that you want to check that exist in the monitored web. But this
command couldn't exist because it only want to check that the web is navigable and it
doesn't freeze loading or there's a link broken or if you want to extract a text from the web.
All these things will be documented later in this annex in the command line.
9.2. Monitoring Scripts Command List
The following commands are the ones that are supported by the Selenium plugin in the Pandora
agent. Some of them are not supported by the Firefox extension.
• Comentario: Any line that starts by the # character.
• answer_on_next_prompt: command that pass the text given as first parameter to the
pormpt window that is genertaed by javascrit in the web.
Page 24
• attach_file: Command that adds the file to the control that upload files from the form given
as first parameter. The second parameter is the path to the file to upload to the web.
• capture_entire_page_screenshot: saves an screenshot of the browser in that moment, with
the first parameter to the file to save the screenshot.
• capture_entire_page_screenshot_to_string: Saves a browser screenshot in one string in
BASE64 and PNG format.
• check: Select the web confirmation box passed as first parameter.
• choose_cancel_on_next_confirmation: In the confirmation window that is generated by
the web javascript, press on the cancel button.
• click: The Selenium click on the web item that has passed as first parameter the objective of
clicking.
• close: The Selenium at this stage of the script line will close the browser.
• create_cookie: Creates a cookie of the web in the browse, with the pair name:value, where
the name is first parameter and the value is the second.
• delete_all_visible_cookies: Delete the name pairs from the browser: Value of a cookie from
the web.
• delete_cookie: Delete the name pair :Value of the cookie from the browser.
• double_click: does double click on the web item that has passed as first parameter the
objective of doing double click.
• focus: focus in the browser the web item that has passed as first parameter the objective to
do focus.
• get_attribute:gets the value of the attribute of the html item that is passed as first
parameter.
• get_body_text: Extracts all the content of the browser web page as it would be a text. It's
possible to pass as first parameter one regular expression that will try match instead of
return all the page content.
• get_cookie_by_name: Returns the value of the cookie passing as first parameter the name
of that cookie.
• get_html_source: Returns the content as html of all the browser web page as if it would be
a text. It is possible to pass as first parameter a regular expression that will try to match
instead of return all the page content.
• get_location: Returns the complete URL in this specific moment of the script, of the browser
Page 25
in the navigation simulation.
• get_text: Returns the text of an item selected through the first parameter.
• get_table: Returns the content of a table selected through the first parameter.
• get_title: Returns the title of the page where the script is in the moment when the command
is called.
• get_value: Returns the value of a form field that is selected through the first parameter.
• go_back: Does the web browser task of “going back”.
• is_cookie_present: Checks if the cookie value that is passed through the first parameter
exists.
• is_text_present: Checks that the text is present in the web, passing a regular expression as
first parameter.
• is_visible: Checks that the item is visible, passed the location in the first parameter.
• open: Open the web in Selenium with the URL passed as first parameter.
• pause: Wait for the Selenium simulation during the time in miliseconds selected in the first
parameter.
• refresh: Refresh in the browser when Selenium finds this command line in the script.
• select: Select a value from a drop list, being the first parameter the location of the drop list
in the web, and the second parameter is the value of the list to select.
• select_window: Select the float window selected by the ID that comes in the first
parameter.
• set_timeout: Pass some time in miliseconds as first parameter to Selenium in order that the
script would be completed, if it doesn't meet the requirements, it returns status error of the
task module.
• submit: Executes the data sending from a form selected by the first parameter.
• type: Writes in the text box selected by the first parameter, and with the second parameter
the text to fill in by Selenium.
• type_keys: Writes also in the text box but key by key as the taping of a real user in
navigation. The box text is selected in the first parameter and the second the keys to press
selected as text.
• uncheck: Does an unchecking in the checking box selected by the first parameter.
• wait_for_page_to_load: Selenium wait as many miliseconds as there are passed in the first
parameter to the page finish loading.
Page 26
• wait_for_element_present: Wait for the item would be present in the browser, passed the
location by the first parameter and the second parameter is the time in miliseconds to wait if
it doesn't returns error in the Pandora agent plugin module status.
• wait_for_text_present: Wait for the text that has been passed in the first parameter would
be present in the browser as a regular expression and the second parameter is the time in
miliseconds to wait, and if the error is not returned in the Pandora agent plugin module
status.
Page 27