Execute Selenium RC via command line against Firefox, Chrome and Internet explorer.
Difficulty level:
Easy/Medium
What you will learn?
- Selenium RC
- Multi browser execution
- Command line
- Viewing the results file
- Selenium RC parameters
Tips:
- Use the below test cases or test suite or alternatively use your own test example.
- Create the command in Notepad++ and then paste into the command prompt.
- ensure you point Selenium RC to the suite and not the test script
- Installed Firefox , Chrome and IE.
- Selenium RC
Exercise Steps
1. Use the script below or use your own scripts.
2. Locate the location of the Selenium Jar
3. Run the Selenium Command from the Jar directory
4. notice the results file.
Conclusions
- execution using Selenium RC against various different browsers
- Command line execution
Related Entries
C:\FoundationSelenium\Ex6.1\testcase1.html, C:\FoundationSelenium\Ex6.1\testcase2.html, C:\FoundationSelenium\Ex6.1\testcase3.html, C:\FoundationSelenium\Ex6.1\Solution2Suite.html, C:\FoundationSelenium\Ex6.1\command.txt.
Solution:
Here are the used commands:
----------------------------------------
Firefox:
java -jar selenium-server-standalone-2.0b2.jar -htmlSuite "*firefox" "http://foundation.time2test.co.uk/" "C:\FoundationSelenium\Ex6.1\Solution2Suite.html" "C:\FoundationSelenium\Ex6.1\Result.html"
Chrome:
java -jar selenium-server-standalone-2.0b2.jar -htmlSuite "*googlechrome"
"http://foundation.time2test.co.uk/" "C:\FoundationSelenium\Ex6.1\Solution2Suite.html" "C:\FoundationSelenium\Ex6.1\Result.html"
Internet Explorer:
java -jar selenium-server-standalone-2.0b2.jar -htmlSuite "*iehta" "http://foundation.time2test.co.uk/" "C:\FoundationSelenium\Ex6.1\Solution2Suite.html" "C:\FoundationSelenium\Ex6.1\Result.html"
-----------------------------------------
here is the test suite in HTML texts:
-----------------------------------------------------
<?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>
Here is the script in HTML texts which is included as first test case in suite:
--------------------------------------------------------------------
<?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>verifyTextPresent</td>
<td>Username</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</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 script in HTML texts included as second test case in test suite:
-------------------------------------------------------------
<?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>TestCase2</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">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>javascript{"Post" + new Date().getMilliseconds();}</td>
</tr>
<tr>
<td>clickAndWait</td>
<td>id=publish</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>css=#menu-posts > div.wp-submenu > ul > li.wp-first-item > a.wp-first-item</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Post Tags</td>
<td></td>
</tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[@id='col-left']/div/div/h3</td>
<td></td>
</tr>
<tr>
<td>type</td>
<td>id=tag-name</td>
<td>NewTag</td>
</tr>
<tr>
<td>type</td>
<td>id=tag-description</td>
<td>This is new tag........</td>
</tr>
<tr>
<td>click</td>
<td>id=submit</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
Here is the script in HTML texts which is included as third test case in test suite:
---------------------------------------------------------------------
<?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{"TestUser" + new Date().getMilliseconds();}</td>
</tr>
<tr>
<td>type</td>
<td>id=email</td>
<td>javascript{"TestUser" + new Date().getMilliseconds()+"@yahoo.com";}</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>
Helpful Video:
1. add the full command to use as text into the blog entry so user can copy and paste.
ReplyDelete2. video should show firefox, chrome and internet explorer run via command line
3. video should show opening up the command line
4. video should show copy and paste command
Solution is updated with your provided suggested points.
ReplyDeleteNotes for viresh
ReplyDeleteRename to mention "cross browser test exercise"
It's done.
ReplyDeletePlease update the commands section so that they point to the "zip file" location as per the course.
ReplyDeleteFor Internet explorer browser - you will need to disable Protected Mode for the IE cross browser testing to execute correctly
ReplyDelete