Use Firefox's xpather to locate the xpath and then update the original script.
Difficulty Level: Hard
What you will learn?
- xpaths
- xpather for firefox
- Firefox browser with Selenium IDE installed ,use link How to install Selenium IDE?
- Open up Firefox
- install xpather by following "How to install xpather in Firefox?"
- copy the original script below into Selenium IDE
- run the original script
- notice in particular the 'assertTextPresent' command and then use xpather tool to replace with an xpath.
- now rerun the script with the xpath
Conclusions
Related Entries
Solution:
Zip file location: ( download from here)
C:\FoundationSelenium\Ex10\BeforeXpather.html, C:\FoundationSelenium\Ex10\AfterXpather.html
Here is the script in HTML texts before using xpather (original 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>BeforeXpather</title> </head> <body> <table cellpadding="1" cellspacing="1" border="1"> <thead> <tr><td rowspan="1" colspan="3">BeforeXpather</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> </tbody></table> </body> </html>
Here is the script in HTML texts after using xpather ( modified with xpather)
BeforeXpather
| BeforeXpather | ||
| open | / | |
| clickAndWait | link=Log in | |
| assertTextPresent | Username | |
| assertTextPresent | Password | |
| type | //input[@id='user_login'] | admin |
| type | //input[@id='user_pass'] | time4test |
| clickAndWait | id=wp-submit | |
| waitForElementPresent | //div[@id='user_info']/p/a[2] | |
| clickAndWait | //li[@id='menu-posts']/a | |
| clickAndWait | //li[@id='menu-posts']/div[3]/ul/li[2]/a | |
| click | id=title-prompt-text | |
| type | id=title | New Post |
| clickAndWait | id=publish | |
| clickAndWait | link=Log Out | |
Helpful Video
notes
ReplyDelete1. the video needs to show the script before using xpather
2. video needs to show xpather install
3. video needs to show how to use xpather to get the xpath
4. video needs to show the new script using xpaths
I have updated video file as per your comments, please review.
ReplyDeletethe html text in the blog is not correctly formatted.
ReplyDeletealso, post the original script before entering the xpaths into the blog
ReplyDeleteDONE, I have added original script as well and previous one also in correct format.
ReplyDeleteOne of the scripts needs to be placed in the html highlighter syntaxer.
ReplyDeletetodo: can you go through the video and create bullet points of the main steps that the video is showing and place the content at the beginning of the blog.
ReplyDeletenotes for viresh
ReplyDeleteadd links to install xpather
ensure that the video shows xpather in use
add steps on what the exercise is showing.
Also, need to establish the aim of the exercise.
ReplyDeleteHi Viresh, what changes you want here, please explain little bit in detail so that I can make changes accordingly.
ReplyDelete