Follow the below Steps to get create your script.
1. Start Selenium and Fitnesse servers by clicking respective Selenium.vbs and Fitnesse.vbs files
2. It opens two cmd windows which shows.
3. Go to http://localhost:8000/ and click on Edit button on Top left corner of the frontPage
4. Paste the following code at the end of the existing data and click on save button
//*** this code is for creating text and link for the test case ***//
| !c '''Test Suite''' |
| !c !style_pass([[Web Test Suites][FitNesse.SuiteWebTests]])| !style_pass(''Simple Test Case'')|
Or simply paste the following if we don’t need any tabular format.
|[[Web Test Suites][FitNesse.SuiteWebTests]]|FitNesse's suite of Web Tests|
5. On clicking save button it shows the page with tabular format of web test suite, click on that link, again click on Edit button and paste the following code.
//*** this code is for declaration of variables and functions needed for testing***//
!*> Class Path & Global Defines
!path C:\Program Files\Fitnesse\selenium-java-client-driver.jar
!path C:\Program Files\Fitnesse \genericfixture.jar
!define IE {*piiexplore}
!define FF {*pifirefox}
!define sel {selenium=}
!define ds {com.thoughtworks.selenium.DefaultSelenium}
!define host {localhost}
!define port {4444}
!define COLLAPSE_SETUP {true}
!define COLLAPSE_TEARDOWN {true}
*!
----
SuiteWebTests.SetUp
SuiteWebTests.TearDown
SuiteWebTests.GoogleTest
6. Click on SuiteWebTests.SetUp ? link and copy paste the following code
//** this code is for declaration of the page related predefined variables and methods***//
!| DSL Adapter |
| user types | % | into | % | field | type | {2}, {1} |
| user starts the browser | start | |
| users opens the URL | % | open | {1} |
| page has the title | getTitle | |
| user sees the text on the page | % | isTextPresent | {1} |
| page has an element named | % | isElementPresent | {1} |
| page loads in less than | % | seconds | waitForPageToLoad | {1}000 |
| page has URL | getLocation | |
| user clicks on submit button | click | //button[@type='submit'] |
| user clicks on the link named | % | click | link={1} |
| user clicks on the button named | % | clickAt | {1},"" |
| get text from element named | % | getText | xpath=id('{1}') |
| user stops the browser | stop | |
| add a key-value with key | % | and value | % | put | {1}, {2} |
| get value for the key | % | get | {1} |
| show | toString | |
!|Generic Fixture|${sel}${ds}|${host}|${port}|${FF}|http://${host}|
| user starts the browser |
7. Go to SuiteWebTests.TearDown link and paste the following code and click on save
!| Generic Fixture | ${sel} |
| user stops the browser |
8. Go to SuiteWebTests.GoogleTests link and paste the following code and click on save
//** this code is for declaration of the page related methods***//
!define q {fitnesse generic fixture}
!| Generic Fixture | ${sel} |
| users opens the URL | http://www.google.com |
| page has the title | | Google |
| page has an element named | btnG | | true |
| user types | ${q} | into | q | field |
| user clicks on the button named | btnG |
| page loads in less than | 5 | seconds |
| page has the title | | ${q} - Google Search |
| user clicks on the link named | Next |
| page loads in less than | 5 | seconds |
| user clicks on the link named | Next |
| page loads in less than | 5 | seconds |
| user sees the text on the page | Results 21 - 30 | | true |