·
Selenium is one
of the most well known testing frameworks in the world that is in use which is
introduced by Jason Huggins in 2004.
·
It is an open
source project that allows testers and developers alike to develop functional
tests to drive the browser.
·
It can be used to
record the workflows and used to prevent the future regressions of code.
·
It supports Java
Scripts and has been built with the same
The components of Selenium are :
1. IDE
2. RC
3. Web Driver &
4. Grid
SELENIUM IDE
The selenium IDE is a Firefox Add-on developed by Shinya Kasatani.
It has been developed using Java Scripts so that it can interact with DOM (Document
Object Model) using native JavaScript calls.
You can install the Firefox first and also install the selenium
IDE from the link,
Install fire pathàhttps://addons.mozilla.org/en-US/firefox/addon/firepath/
Open you Firefox browser where toolsà Selenium IDE
The items in the IDE,
Base URL: All open command will be relative to
the base URL (full path). This is the URL that the test will start at.
Speed Slider: This slider is used to fast or
slow mode during the play back.
(Triangle with 3
lines): Run all the tests in the id
(Triangle
with 1 line): Run only single test
(||): Pause
a test that is currently running
(bended
down arrow): Step through the test once it has paused
Red
button- This is the Record button. By default when we open the selenium IDE it
will be enabled.
Command
- It is a select box has a list of
all the commands that are needed to create the test. It is an auto complete
functionality or use the drop down.
Target
- the location of the element
Value
- where you place the value that needs to be change.
Table
view – Will keep track all the commands, targets and values.
Source
View – You will be able to see the HTML that will store the test.
Log
– will show what is happening during the test run.
Reference
– Documentation on the command highlighted.
Record your first Test with the
Selenium IDE
1.
First need to
start the Mozilla Firefox and need to start the Selenium IDE. It will be
automatically in the record mode.
2.
Now in browser
navigate to http://theautomatedtester.co.uk/chapter1
3.
Do some action on
the web application like click on the links radio buttons etc
4.
Once the actions
are done come back to IDE and stop recording.
5.
Your test has
been recorded
6.
Now you can play
the test and see the result.
7.
If any failures
it will display the number of failures and errors can be viewed in the log
VERIFY AND ASSERT
Verify – is going to verify the
element present on the page. If not it will throw the error and carry on
executing.
Assert- Is very similar to verify but
the difference is, this allows the test to check if the element is on the page.
If not the test will stop on the step that failed.
How to use Verify or Assert?
1.
Open Selenium IDE
and start recording
2.
Right on the text
which you would like to verify
3.
Show all available
commands and select verify text
4.
Do few more
action and stop recording
5.
Now run the test
When it verifies that particular step
will be highlighted in dark green color. If it does not match or verify it will
throw error and carry on executing remaining commands.
Same procedures for Assert:
Right click on the text you need to
verify and select assert text.
Here if it matches or verifies same
procedure like verify, but when it does not verifies it will fail and stop
executing the remaining steps.
How we have verified the text, in the
same procedure we can verify the element present like buttons, checkbox, text
area etc in the chapter 1. You can try yourself. The result will be like the
following,
How to
Comment?
1. Click on any step that you want to comment.
2. Right click and click on Insert New Comment
3. A new line will appear
4. Type your comments in the command.
5. You can see a pink color line ie. Comment
How to use multiple windows?
In this
section we will have a look at creating a test that can move between windows.
1.
Open the IDE
2.
Launch http://theautomatedtester.co.uk/
3.
Click on Chapter 1
4.
Click on the element “Click this to
launch another window”
5.
A small window will appear where you
can even verify the text.
How to
store an information from the page in the test?
1.
Open the IDE and launch the site :
chapter 1
2.
Right click on any text that you need
to store in the text box available in the page
3.
Select store Text
4.
A dialog box will appear and ask you
to enter the name of the variable
5.
Enter a variable name eg: abc
6.
Now stop recording
7.
Click on the next blank step where the
steps are recording
8.
Type: Type in the command
9.
Type: storeinput in the target
10. Type:
${abc} in the value
11. Now
run the test
12. You
can view the selected text in the text box.
Note: in
the target I asked you to type storeinput which is nothing but the id of the
text box.
How to find the ID?
In the
Mozilla Firefox you should have installed the firebug and fire path. Go to the
chapter 1 page press F12. Where using the Locator you can get the id or name or
link or css or class which are nothing but the xpath.
What is X path?
The x path
is nothing but the Location of the element. Each element in the page has its unique
id. Example: Like our address. The address of the element is called as the ID.
For detailed ppt for Selenium IDE, kindly visit:
http://www.slideshare.net/Aneshare/selenium-over
For detailed ppt for Selenium IDE, kindly visit:
http://www.slideshare.net/Aneshare/selenium-over
No comments:
Post a Comment