Twist - Creating a Google Test

- Create a Twist Project, by clicking on File - New - Twist Project.
- A wizard will be opened, Enter a project name and choose advanced option to selenium driver. (That's the driver needed for web testing)

- Leave other options unchanged, if you want selenium server to run on another port change the port number.

Once Project is created , It will ask you to create a new scenario, enter some name to it and click on Finish.

To make it a executable test, one need to create a work flow.

- Click on Work flow button on top of the test, it will add a blank scenario something like.



New Work flow:


A bullet point will also be inserted, specifying that as scenario step.

- Change the scenario name if needed and then put the cursors on scenario name to make it executable.
- Click "Ctrl+1" to create a workflow (That is java class with the workflow name), after that is done the color and font style of the workflow name will be changed to Black and Normal from Italic respectively. It denotes that workflow has been created, however there are no tests specified in that.

- Now create test steps - Create one test step each against a bullet point.

  • Open website "www.google.co.uk"
  • Enter search criteria "Testing"
  • Verify Search Result "Testing"

Once Testing steps are defined, one need to elaborate them to make it executable.

Sale rule as we did with workflow, put the cursor on the step name and click "Ctrl+1", it will give two options

1) To create the blank method in the Java class created above.
2) To record the method using "Firefox " (Does not support any other browser for recording at the moment).

If option 2) is selcted then a browser is launched and user can perform actions ..

Lets record out first step - 1) Open website "www.google.co.uk"

Once the browser is launched, type "www.google.co.uk", and then to mark the recording finished click on "Done" on recording pane (Can be seen on right hand side).

Now, Twist must have inserted some code for this methods 1) Open website "xxx"

Code can be seen by pressing "F3" on the method name, it will then navigate to the specific method , by highlighting the method in the code.

That's what we get in the code..


public void openWebsite(String string1) {
selenium.open("www.google.co.uk");

}



Now, this method can be made reusable by using parameter string1, that is the google url in the test, instead of using hard coded value. So, now the method would look like.



public void openWebsite(String url) {
selenium.open("url);

}



Now, this method can be used to open any URL..

0 comments:

Post a Comment