Disclaimer: I've never used any test tools before, as I'm in the developer team, not the QA team.
Our team is tasked with the ultimate goal of writing an automated load test script, which will be hitting on our JS-based web application. We will most likely be using JMeter.
As we're taking it one step at a time, we started with writing test scripts using Selenium IDE with Firefox driver, then migrate to HtmlUnitDriver as we want to eventually run multiple instance of the tests at the same time. We are running selenium-server-standalone-2.41.0.jar in the background. The Selenium IDE has WebDriver playback enabled, and is using "selenium-server-standalone-2.41.0.jar", "htmlunit-2.13.jar", and "htmlunit-core-js-2.13.jar" as the IDE extensions.
The test will load our login page (which, unfortunately, contains <iframe>
), login to our dashboard page, check for existing text, and logout from that page.
Here is a simplified portion of the login page:
<html>
<head><title>footest</title></head>
<body>
<div id="container" align="center">
<div id="login">
<div id="login-panel">
<iframe src="http://localhost/auth/form">
<div id='login-form'>
<form action="http://localhost/auth/form" method="post">
<div class='row'>
<label for='username' class='vertical'>Username</label>
<input class="text" id="username" name="username" type="text" value="" />
</div>
<div class='row'>
<label for='password' class='vertical'>Password</label>
<input class="text" id="password" name="password" type="password" value="" />
</div>
<div class='row'>
<input class="float-right" id="login" name="login" type="submit" value="Log In" />
</div>
</form>
</div>
</iframe>
</div><!-- login-panel -->
</div><!-- login -->
</div><!-- container -->
</body>
</html>
Here are the steps we recorded with Selenium IDE:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://selenium-ide.openqa.org/profiles/test-case">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="selenium.base" href="http://localhost/dashboards/" />
<title>footest</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">footest</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>http://localhost/dashboards?back=http%3A//localhost/dashboards/main.html</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>10000</td>
<td></td>
</tr>
<tr>
<td>selectFrame</td>
<td>index=0</td>
<td></td>
</tr>
<tr>
<td>waitForText</td>
<td>//label</td>
<td>Username</td>
</tr>
<tr>
<td>type</td>
<td>//input[@id='username']</td>
<td>foo</td>
</tr>
<tr>
<td>typeAndWait</td>
<td>//input[@id='password']</td>
<td>bar1234</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//input[@id='login']</td>
<td></td>
</tr>
<tr>
<td>waitForPageToLoad</td>
<td>20000</td>
<td></td>
</tr>
<tr>
<td>pause</td>
<td>2000</td>
<td></td>
</tr>
<tr>
<td>waitForText</td>
<td>id=graph-table</td>
<td>No records found</td>
</tr>
<tr>
<td>click</td>
<td>//a[@id='logout']</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
When we run the tests with WebDriver playback + firefox browser, we are able to run the test successfully. However, when we switch to using htmlunit, we were not able to run it. The error is as follows:
17:28:25.432 INFO - Command request: getText[//label, ] on session 87338f89-7d2f-4387-b85e-3685a1a8a2ac
17:28:27.135 INFO - Got result: ERROR,Element //label not found on session 87338f89-7d2f-4387-b85e-3685a1a8a2ac
Similar error occured on selecting the input field with id='username', or clicking on the logout button at the end.
The questions are:
- How can we reliably run the scripts without spawning a browser?
- Are we going in the right direction with using HtmlUnit?
- Any other tools / hints / etc. we should consider to test this without browser?