Thursday, November 20, 2008

Assert an Object’s hyperlinked address/URL


Hi All,

Using the Selenium IDE, it is possible


to assert the URL (path/address) of a hyperlink, that is the URL it is pointing

to without left clicking to navigate to that URL.

For example;

If you go to www.google.com

On the top you have the following hyperlinks:

"Image", "Maps", "News", "Shopping",

etc

If you right click on "Image", and

select properties, it gives you

"http://images.google.co.uk/imghp?hl=en&tab=wi".



·

We can assert that the object "Image"

is pointing to "http://images.google.co.uk/imghp?hl=en&tab=wi" on

that www.google.com page.

<tr>

                <td>verifyAttribute</td>
<td>locator@href</td>

<td>url</td>


</tr>        

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="" />
<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>pause</td>
<td>1000</td>
<td></td>
</tr>
<tr>
<td>assertAttribute</td>
<td>link=Images@href</td>
<td>http://images.google.co.in/imghp?hl=en&amp;tab=wi</td>
</tr>
</tbody></table>
</body>
</html>

No comments: