Monday, 7 March 2011

Exercise 2 - Test Suite

Aim:
Create a test suite using the IDE

What you will learn?
  • creation of a test suite
  • running a test suite
  • how to modify the suite using notepad++
Difficulty level: Easy


Pre-requisites:


Exercise Steps
  1. Copy the script from the blog and save it on PC to make testcase1.html in a folder 'X'
  2. Copy the script from the blog and save it on PC to make testcase2.html in same folder 'X'
  3. Copy the script from the blog and save it on PC to make testcase3.html in same folder 'X'
  4. Launch Firefox
  5. Open IDE
  6. From the File Menu, select 'New Suite' option
  7. In the test suite add the saved three test cases
  8. save as suite within the IDE and call this "solution2Suite.html"
  9. Run the TestSuite via the IDE



Solution:
The solution contains 4 selenium scripts ( one test suite which links to 3 test cases)
Zip file location: ( download from here)

  • C:\foundationSelenium\Ex2\testcase1.html,
  • C:\foundationSelenium\Ex2\testcase2.html,
  • C:\foundationSelenium\Ex2\testcase3.html,
  • C:\foundationSelenium\Ex2\Solution2Suite.html.


Test Script 1













Here is the first test script in HTML format:

<?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://foundation.time2test.co.uk/" />
<title>TestCase1</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">TestCase1</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>/</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Log in</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Username</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Password</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=user_login</td>
<td>admin</td>
</tr>
<tr>
<td>type</td>
<td>id=user_pass</td>
<td>time4test</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=wp-submit</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@id='user_info']/p/a[2]</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>



Here is the second test script in HTML format:
<?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://foundation.time2test.co.uk/" />
<title>TestCase3</title>
</head>
<body>
<table border="1" cellpadding="1" cellspacing="1"><thead>
<tr><td colspan="3" rowspan="1">TestCase2</td></tr>
</thead><tbody>
<tr>
<td>clickAndWait</td>
<td>link=Posts</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@id='wpbody-content']/div[3]/h2</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Add New</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=title</td>
<td>MyPost</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=publish</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>



Here is the third test script in HTML format:
<?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://foundation.time2test.co.uk/" />
<title>TestCase3</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">TestCase3</td></tr>
</thead><tbody>
<tr>
<td>clickAndWait</td>
<td>link=Users</td>
<td></td>
</tr>
<tr>
<td>assertTextPresent</td>
<td>Users</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>//li[@id='menu-users']/div[3]/ul/li[2]/a</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=user_login</td>
<td>javascript{&quot;Test&quot; + new Date().getMilliseconds();}</td>
</tr>
<tr>
<td>type</td>
<td>id=email</td>
<td>javascript{&quot;Test&quot; + new Date().getMilliseconds()+&quot;@gmail.com&quot;;}</td>
</tr>
<tr>
<td>type</td>
<td>id=first_name</td>
<td>TestFirst</td>
</tr>
<tr>
<td>type</td>
<td>id=last_name</td>
<td>TestLast</td>
</tr>
<tr>
<td>type</td>
<td>id=url</td>
<td>http://www.google.com/</td>
</tr>
<tr>
<td>type</td>
<td>id=pass1</td>
<td>time2test</td>
</tr>
<tr>
<td>type</td>
<td>id=pass2</td>
<td>time2test</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=addusersub</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Log Out</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>



Here is the TestSuite in HTML format:
<?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>
<meta content="text/html; charset=UTF-8" http-equiv="content-type" />
<title>Test Suite</title>
</head>
<body>
<table id="suiteTable" cellpadding="1" cellspacing="1" border="1" class="selenium"><tbody>
<tr><td><b>Test Suite</b></td></tr>
<tr><td><a href="testcase1.html">testcase1</a></td></tr>
<tr><td><a href="testcase2.html">testcase2</a></td></tr>
<tr><td><a href="testcase3.html">testcase3</a></td></tr>
</tbody></table>
</body>
</html>



Helpful video:


6 comments:

  1. notes:
    1. add scripts as snippets
    2. change the slide to indicate wordpress and not google

    ReplyDelete
  2. I have added scripts as snippets, now I need to change the slide to indicate wordpress and not google.

    ReplyDelete
  3. I have updated Exercise slide as well.

    ReplyDelete
  4. Notes:
    the scripts do not all seem to be here
    should be able to see 4 test scripts ( one suite and 3 test cases)

    ReplyDelete
  5. Viresh Note:
    The test steps need to be clearer:
    step 1 - use the existing script from exercise 1 to make testcase1.html
    step 2 - copy and paste the test case 2 from here and save as testcase2html
    step 3 - copy and paste the tes case 3 from here and save as testcase3.html
    step 4 - save as suite within the IDE and call this "solution2Suite.html"
    step 5 - Run the TestSuite via the IDE

    ReplyDelete

Thank you for your comment
- Time2test Team