Monday, November 24, 2008

Example for gotoLabel command in Selenium IDE

Hi All,

Here is the example for gotoLabel command. When Selenium IDE encounters gotoLabel command, it searches for targetted label name in the rest of the script and passes the control to targetted Label and the executes the steps from Label command and skips the steps that are in between gotoLabel and Label commands. When the targetted label is not found it throws error.

Extension for Label Command:

Selenium.prototype.doLabel = function(){};

Example:

<?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://www.google.co.in/" />
<title>New Test</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">New Test</td></tr>
</thead><tbody>
<tr>
<td>open</td>
<td>http://www.google.co.in/</td>
<td></td>
</tr>
<tr>
<td>verifyText</td>
<td>link=Go to Google.com</td>
<td>Go to Google.com</td>
</tr>
<tr>
<td>gotolabel</td>
<td>label1</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Go to Google.com</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>this wont execute</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Go to Google India</td>
<td></td>
</tr>
<tr>
<td>label</td>
<td>label1</td>
<td></td>
</tr>
<tr>
<td>verifyTitle</td>
<td>Google</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>

No comments: