0% found this document useful (0 votes)
365 views

Selenium Notes

Selenium is an open source tool for automating web applications. It provides several components for testing functionality and browser compatibility including an integrated development environment, remote control, and web driver. The Selenium IDE is a simple Firefox extension that allows users to record, edit, and debug test scripts. Remote control allows running scripts on different browsers and the web driver automates browsers directly.

Uploaded by

Vishnu Mohan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
365 views

Selenium Notes

Selenium is an open source tool for automating web applications. It provides several components for testing functionality and browser compatibility including an integrated development environment, remote control, and web driver. The Selenium IDE is a simple Firefox extension that allows users to record, edit, and debug test scripts. Remote control allows running scripts on different browsers and the web driver automates browsers directly.

Uploaded by

Vishnu Mohan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

SELENIUM

NOTES
Why selenium?

• Open source. Free software

• Easy installation

• Flexibility

• Tests for Functionality and Browser Compatibility

SELENIUM COMPONENTS

• INTEGRATED DEVELOPMENT ENVMNT

-RECORD,EDIT,DEBUG SCRIPTS

-FIREFOX EXTENSION

• REMOTE CONTROL

-RUN (START/STOP/CONTROL) SCRIPT

-EXECUTABLE JAR FILE

• WEB DRIVER

-AUTOMATE BROWSERS

-SUCCESSOR OF RC

• CORE

-CORE ENGINE,BASE

-LIBRARY(JAVA&DHTML)
COMPATIBILITY

• IDE - FIREFOX ONLY

• RC & WD - ANY JAVASCRIPT ENABLED BROWSER

SELENIUM IDE

The ideal environment for creating Selenium tests

Firefox plug in

Contains list of Selenium commands with parameters predefined

Debugging and Breakpoint

Tests can be saved as any other format

Programming languages – HTML, C#, Java, Perl, PHP, Python and Ruby

SELENIUM RC

Provides Selenium server

Start/Stop/Control supported browsers

Works with any HTTP website

Works with any HTTP website

INSTALLATION

SELENIUM IDE

INSTALL FIREFOX

GO TO “SELENIUMHQ.ORG”
GO TO DOWNLOAD TAB

CLICK HERE TO DOWNLOAD SELENIUM IDE LATEST VERSION

CLICK “ALLOW”
CLICK “INSTALL NOW”

RESTART FIREFOX

GO TO TOOLS MENU
SELENIUM IDE

TABLE VIEW
NB:WHEN NO NEED TO SPECIFY LOCATION, THEN VALUE IS GIVEN IN TARGET

 THE TABLE VIEW


 COMMAND – WHAT YOU DID
 TARGET - WHERE YOU DID
 VALUE-VALUE TO INPUT/TEST
 EDIT ALL THREE THROUGH HERE
 NB:WHEN NO NEED TO SPECIFY LOCATION, THEN VALUE IS GIVEN IN TARGET
SOURCE VIEW

RECORDING A SCRIPT IN SELENIUM IDE


OPEN FIREFOX

GO TO TOOLS TAKE SELENIUM IDE

MINIMIZE IDE

GIVE THE URL OF YOUR SITE IN FIREFOX

DO SOME ACTIONS LIKE CLICK, TYPE,SELECT ETC.

AFTER COMPLETION TAKE SELENIUM AND STOP RECORDING


SELENESE – SELENIUM COMMANDS

Selenium commands come in three flavors :

ACTIONS

ACCESSORS

ASSERTIONS

ACTIONS

Open open url

Openwindow open url in new window

Click Clicking at locator

ClickAt Clicking at locator at a specified co - ord

Type Type at locator

SendKeys Type without overwrite

Check Check radio boxes, checkbox etc.

Uncheck Uncheck boxes

Close Close Page

Goback Goback one step

Highlight Highlight an element

Select Select From a dropdown box

Refresh Refresh the page

Pause Pause for specified milliseconds

Break Pause until user press resume button


ACCESSORS

Store - store values to a variable

StoreTitle, StoreText, StoreElementPresent - store corresponding items to a


variable

Storevalue - on/off state of radio/check boxes

ASSERTIONS

ASSERT
•CHECK CONDITION,ABORT TEST ON FAILING

VERIFY
•CHECK CONDITION

WAITFOR
•WAITFOR A CONDITION TO BECOME TRUE

Asserttext/ verifytext - check the text present in an element

Waitfortext - wait for text to be present in an element

SIMILARLY

Assert/ Verify/ Waitfor Elementpresent

Assert/ Verify/ Waitfor ElementNotpresent

Assert/ Verify/ Waitfor Editable

Assert/ Verify/ Waitfor Title


LOCATORS
TO LOCATE, i.e. POINT OUT A PARTICULAR ELEMENT IN WEB PAGE FOR SELENIUM
COMMANDS IF NECCESSARY

Types of locators

1.Identifier

works with the id and name attributes of your html tags. Let’s consider the following
example:

<html>

<body>

<form id="login">

<input name="username" type="text"/>

<input name="password" type="password"/>

<input name="submit" type="submit" value="Continue!"/> </form> </body> </html>

Eg:

identifier=login

identifier=username
2.Id

works with the id attribute of your html tags.

<html>

<body>

<form id="login">

<input name="username" type="text"/>

<input name="password" type="password"/>

<input name="submit" type="submit" value="Continue!"/> </form> </body> </html>

Eg:

Id=login

3.Name

works with name attribute of your html tags

<html>

<body>

<form id="login">

<input name="username" type="text"/>

<input name="password" type="password"/>

<input name="submit" type="submit" value="Continue!"/> </form> </body> </html>


Eg:

Name=username

Name=submit

If two items has same name then give an additional attribute with name

Applicable to “identifier” also

4.Link

Let’s consider the following example:

<html>

<body>

<form id="login">

<input name="username" type="text"/>

<input name="password" type="password"/>

<input name="submit" type="submit" value="Continue!"/>

<a href="hello.html" >HELLO </a>

</form> </body> </html>

Eg:

Link=HELLO
5.DOM (Document Object Model)

<html>

<body>

<form id="login">

<input name="username" type="text"/>

<input name="password" type="password"/>

<input name="submit" type="submit" value="Continue!"/> </form> </body> </html>

Eg:

Dom=document.getElementById(‘login’)

Dom=document.forms[0]

Dom=document.forms[0].elements[2]

Dom=document.getElementsByName(‘username’)[0]

6.XPATH

<html>

<body>

<form id="login">

<input name="username" type="text"/>

<input name="password" type="password"/>

<input name="submit" type="submit" value="Continue!"/> </form> </body> </html>


Eg:

Xpath=/html/body/form[0]

//input[@name='username']

//form[@id='loginForm']/input[4]

//input[@type=‘submit']

//form[starts-with(@id, 'log')]

//input[contains(@class, 'passfield')]

7.CSS (Cascading Style Sheets)

<html>

<body>

<form id="login">

<input class=“required” name="username" type="text"/>

<input class=“required passfield”name="password" type="password"/>

<input name="submit" type="submit" value="Continue!"/>

</form> </body> </html>

Eg:

Css=input.required

Css=form#login

css=#login input:nth-child(2)

css=#login input[type="button“]

css=input.required[type="text"]

You might also like