Modify this script and use verify and assert and notice the differences in operation.
Pre-requisites:
- Firefox browser with Selenium IDE installed ,use link How to install Selenium IDE?
key steps:
1. use an existing script ( provide a script with verify command)
2. run the script with command verify and observe what happens during execution and the results
3. now use an existing script ( provide a script with asset command)
4. run the script with command verify and observe what happens during execution and the results
Background:
Assert vs verify: If you use seleniums verify command - then the test suite/case - will still run - and fail at the end. Hence in most cases you should use assert command which will cause the test to stop.
Zip file location: ( download from here)
C:\FoundationSelenium\AssertAndVerify\AssertScript.html, C:\FoundationSelenium\AssertAndVerify\VerifyScript.html.
Assert Example's 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>AssertScript</title> </head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> <tr><td rowspan="1" colspan="3">AssertScript</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>assertTextPresent</td> <td>Posts</td> <td></td> </tr> <tr> <td>clickAndWait</td> <td>link=Add New</td> <td></td> </tr> <tr> <td>click</td> <td>id=title-prompt-text</td> <td></td> </tr> <tr> <td>type</td> <td>id=title</td> <td>New Post</td> </tr> <tr> <td>assertTextNotPresent</td> <td>Add New Post</td> <td></td> </tr> <tr> <td>clickAndWait</td> <td>id=publish</td> <td></td> </tr> <tr> <td>clickAndWait</td> <td>link=Log Out</td> <td></td> </tr> </tbody></table> </body> </html>
Verify Example's 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>VerifyScript</title> </head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> <tr><td rowspan="1" colspan="3">VerifyScript</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> <tr> <td>clickAndWait</td> <td>link=Posts</td> <td></td> </tr> <tr> <td>verifyTextNotPresent</td> <td>Posts</td> <td></td> </tr> <tr> <td>clickAndWait</td> <td>link=Add New</td> <td></td> </tr> <tr> <td>click</td> <td>id=title-prompt-text</td> <td></td> </tr> <tr> <td>type</td> <td>id=title</td> <td>New Post</td> </tr> <tr> <td>verifyTextPresent</td> <td>Add New Post</td> <td></td> </tr> <tr> <td>clickAndWait</td> <td>id=publish</td> <td></td> </tr> <tr> <td>clickAndWait</td> <td>link=Log Out</td> <td></td> </tr> </tbody></table> </body> </html>
Solution Video File
I have added the solution video file.
ReplyDeletefeedback for Vipin:
ReplyDelete1. you need to add the scripts into the blog like the other posts.
This is an exercise, so the blog should be presetned in a way that allows the delegate to learn something. So, here we want them to take an existing script ( we should provide that script) then instructions to change the script , which is the point of the exercise and then the final result and we then conclude it with an explanation.
yes, I have done
ReplyDelete