Monday, September 21, 2009

Selenium - Verify Element Properties

While doing the automation through selenium we also need to verify the tooltip of the image or it's path(location, URL). selenium has provided API to check the attirbutes of any element. Now let's see how to do this.

let's first see how to do this in selenium. The following script will navigate to http://qtp-help.blogspot.com. Then it will fetch the URL of the profile photo and will open the photo.

storeAttribute //img[@alt='My Photo']@src imagePath
open ${imagePath}


<!-- Purpose:- To show how to verfiy the Properties of a image
Created By:- Gaurang Shah
Email:- gauragnnshah@gmail.com
-->

<?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://qtp-help.blogspot.com/" />
<title>Verify Image Property</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>/</td>
<td></td>
</tr>
<tr>
<td>storeAttribute</td>
<td>//img[@alt='My Photo']@src</td>
<td>imagePath</td>
</tr>
<tr>
<td>open</td>
<td>${imagePath}</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>

0 comments:

Post a Comment