Web Application Testing with Selenium
At first glance, it looks like Selenium RC supports enough parallelism that any additional distributed processing capability would not be needed. After all, a single Selenium RC server allows you to open a number of parallel sessions (that is, drive a number of browsers at the same time) and a single Selenium RC client. In addition to being able to work with multiple concurrent sessions of one server, it can communicate with multiple servers at the same time.
However, in practice, running more than six browsers on the same Selenium RC server is not advisable due to performance issues. Additionally, managing a large number of Selenium RC servers is a major headache and does not scale very well. This is where Selenium Grid can help.
Selenium Grid introduces another component to the Selenium architecture—Selenium Hub, which manages a pool of available Selenium Remote Control entities and is responsible for the following:
Transparently allocating a Selenium RC entity to a specific test.
Limiting the number of concurrent test runs on each Remote Control.
Shielding the tests from the actual grid infrastructure.
As far as your RC client programming is concerned, the move from Selenium RC to Grid requires minimal code changes. All you have to do is to change the infamous browser string parameter. For instance, change "*firefox" to something like "Firefox on Windows" or "Safari on Mac".
Selenium Hub's configuration is a bit more complex. First, you have to modify the grid_configuration.yml file. Let's say you want to use two RC instances—one with Firefox on Linux and another with Internet Explorer on Windows. In that case, your configuration file will look like this:
hub:
port: 4444
environments:
- name: "Firefox on Linux"
browser: "*firefox"
- name: "IE on Windows"
browser: "*iexplore"
After that, you should use ant to launch the Selenium Hub by running ant launch-hub on the hub machine. The RC instances are created by running the following commands, one on a Linux machine and one on a Windows machine.
On the Linux machine:
ant -Denvironment="Firefox on Linux" \
-DhubURL=http://<hub-IP-address>:4444 \
launch-remote-control
On the Windows machine:
ant -Denvironment="IE on Windows" \
-DhubURL=http://<hub-IP-address>:4444 \
launch-remote-control
After that, you can code your RC client to use any of the above RC server instances via the hub.
Comprehensive description of the Selenium API is beyond the scope of this article, but the list below demonstrates what the framework is capable of:
$sel->click($locator) — Clicks on a link, button, check box or radio button.
$sel->context_menu($locator) — Simulates opening the context menu for the specified element (as might happen if a user right-clicks on the element).
$sel->focus($locator) — Moves the focus to the specified element.
$sel->key_press($locator, $key_sequence) — Simulates a user pressing and releasing a key.
$sel->mouse_over($locator) — Simulates a user hovering the mouse over the specified element.
$sel->type($locator, $value) — Sets the value of an input field, as though you typed it in.
$sel->check($locator) — Checks a toggle button (check box/radio).
$sel->select($select_locator, $option_locator) — Selects an option from a drop-down menu using an option locator.
$sel->submit($form_locator) — Submits the specified form.
$sel->open($url) — Opens a URL in the test frame.
$sel->open_window($url, $window_id) — Opens a pop-up window.
$sel->go_back() — Simulates a user clicking the back button in the browser.
$sel->get_location() — Gets the absolute URL of the current page.
$sel->get_body_text() — Gets the entire text of the page.
$sel->get_text($locator) — Gets the text of an element.
$sel->get_selected_indexes($select_locator) — Gets all option indexes for the selected options in the specified select or multi-select element.
$sel->get_all_links() — Returns the IDs of all links on the page.
$sel->wait_for_condition($script, $timeout) — Runs the specified JavaScript snippet repeatedly until it evaluates to “true”.
$sel->get_cookie() — Returns all cookies for the current page under test.
$sel->wait_for_text_present($text, $timeout) — Waits until $text is present in the HTML source.
For more details, check the Perl API link at the end of the article. API documentation for other languages is available as well. If you find that the API is lacking somewhere, you always can extend it by executing your own JavaScript functions using $sel->get_eval($script).
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
Web Development News
Developer Poll
| Dynamic DNS—an Object Lesson in Problem Solving | May 21, 2013 |
| Using Salt Stack and Vagrant for Drupal Development | May 20, 2013 |
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
- Dynamic DNS—an Object Lesson in Problem Solving
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Using Salt Stack and Vagrant for Drupal Development
- New Products
- A Topic for Discussion - Open Source Feature-Richness?
- Drupal Is a Framework: Why Everyone Needs to Understand This
- Validate an E-Mail Address with PHP, the Right Way
- RSS Feeds
- Readers' Choice Awards
- Tech Tip: Really Simple HTTP Server with Python
- BASH script to log IPs on public web server
41 min 23 sec ago - DynDNS
4 hours 17 min ago - Reply to comment | Linux Journal
4 hours 49 min ago - All the articles you talked
7 hours 13 min ago - All the articles you talked
7 hours 16 min ago - All the articles you talked
7 hours 17 min ago - myip
11 hours 42 min ago - Keeping track of IP address
13 hours 33 min ago - Roll your own dynamic dns
18 hours 46 min ago - Please correct the URL for Salt Stack's web site
21 hours 58 min ago








Comments
Interesting article, thanks.
Interesting article, thanks. I've been using Selenium for functional testing, but was forced to running different browsers on different operating systems under VirtualBox for cross browser testing. BrowserSeal looks promising, will check it out.