To demonstrate using a simple example a regular expression
Pre-requisites:
- Firefox browser with Selenium IDE installed ,use link How to install Selenium IDE?
Key Steps
1. Save the script from blog to the PC in .html file format
2. Launch Firefox
3. Open IDE
4. Open the saved script
5. Run the script
6. See how regular expression works in recognizing elements.
Conclusions
Related Entries
Zip file location: ( download from here)
C:\FoundationSelenium\RegularExpression\RegularExpressionScript.html.
HTML test script
<?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>RegularExpression</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
<thead>
<tr><td rowspan="1" colspan="3">RegularExpression</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>
<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=a.wp-first-item.current</td>
<td></td>
</tr>
<tr>
<td>verifyTextPresent</td>
<td>regexpi: Post[0-9]{2,3}</td>
<td></td>
</tr>
<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{"Test" + new Date().getMilliseconds();}</td>
</tr>
<tr>
<td>type</td>
<td>id=email</td>
<td>javascript{"Test" + new Date().getMilliseconds()+"@gmail.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>verifyTextPresent</td>
<td>regexpi: Test[0-9]{2,3}</td>
<td></td>
</tr>
<tr>
<td>clickAndWait</td>
<td>link=Log Out</td>
<td></td>
</tr>
</tbody></table>
</body>
</html>
Helpful Video File
is this complete?
ReplyDeleteYep, it's done.
ReplyDelete