Selenium
Selenium
Selenium
Automation tool
Selenium syllabus
SELENIUM COURSE CONTENTS:
Automation Testing
Test Scripts
Selenium IDE
Web Elements
Locators
HTML
Xpath
Handling Listbox
Find element & Find Elements
Popup’s
Java script Popup
File Upload Popup
File Download Popup
New Browser Popup
Tabbed Browser Popup
Calendar Popup
Hidden Division Popup
Handling Frame
Mouse Over Operations
Drag & Drop Operations
Working with different browser
Taking Screenshot
Auto Suggestion
POI Apache
Data Driven Framework
TestNG Framework
Hybrid Framework
History of selenium
Jason released the first version of automation
tool called selenium core but it is not read
properly, than he launched 2nd version of tool
that selenium IDE(SIDE) which are also failed.
Than the developed 3rd version with java code
◦ Selenium core
◦ Selenium IDE
◦ Selenium RC(remote control)
◦ Selenium web driver
◦ Selenium Grid
Selenium supporting languages
Selenium supports the following languages
◦ C#
◦ PHP
◦ Pearl
◦ Python
◦ Ruby
◦ Java
◦ Java script
What is selenium web driver
Selenium is a combination of selenium RC
and Web driver
It is used to automate the web based
◦ Selenium 2
◦ Selenium 3
◦ Selenium 4
How to Setup the
Selenium Web Driver
Java development tools
Eclipse
Netbeens
Jcreater
Intelli.j (IDBA)
Dr.java
Mgeclipse
J developer
Eclipse versions
Auslin
Bravo
Callisto
Europa
Ganymede
Galileo
Helios
Indigo
Juno
Keplar
Luna
Mars
We can use any one of those five versions
Neon for selenium
Oxygen
Selenium Web driver architecture
Web Driver(I)
Remote Web
Driver(c)
Internet
Firefox Chrome
explorer
Driver(c) Driver(C)
driver(C)
• When ever we use predefined interfaces and classes every word first
letter should be in upper case
• Import statement should be written when ever we use predefined
classes and interfaces
• To write import statement write the class name or interface name
mouse move on the class click on import statement or we can press
ctrl +shift+O
1. How to start browser and how to open the
Google.com
Get Title method
In order to get the title of the app we use get
Title method and it returns the title of the
application in string format
Ex:
Wait statement
Thread. Sleep statement is used to wait for
specified milliseconds
EX 1000 msec =1 sec
Sleep method is a static method of thread
Opening tag
Syntax
◦ Html Tagname[propertyname=‘property value’]
◦ When we need to use the id attribute in css
Html tagname#id attribute value
◦ When we need to use the class attribute in css
Html tagname.class attribute value
Ex:
◦ Input[type=‘submit’]
Xpath
Xpath in selenium is a xml path used for
navigation through the HTML structure of the
page.
it is a syntax or language for finding any
◦ //tagname[text()=‘text of an element’]
◦ Xpath with contains and text().
Different types of browser command
Get command
Get title Command
Get current URL command
Close command
Quit command
Navigation command
Ex:System.out.println(driver.getTitle());
Get current URL command
It is used to get the URL of the current Web
page
EX:
Close and quit command
Close
◦ It is used to close the current window
◦ driver.close();
Quit
◦ It is also used to close the browser
◦ driver.quit();
Navigation command
Navigate to previous web page
◦ driver.navigate().back();
Navigate To Command
◦ It is used to open the application
◦ Driver.navigate().to(“url”);
Refresh command
◦ It is used to reload the web page
◦ driver.navigate().refresh();
WebElement Methods
◦ 1.SendKeys() Method
It is used to enter the value to the text box, password
text box and multiline text box
◦ 2. Clear method
It is used to clear the existing value in the text box
Click method: click()
◦ This method is used to click on the element such as
button, link, check box radio button
isSelected() method
◦ isSelected() is used to verify whether the specified
radio button or check box is selected or unselected,
if it is selected it returns true value else returns
false value
Escape sequence
A character preceded by a back slash(\) is an
escape sequence and has special meaning to the
compiler.
\t insert a tab in the text at this point
\b inset a backspace in the text at this point
\n inset newline in the text at this point
\’ insert a single quote character in the text at
this point
\” insert double quote character in the text at
this point
\\ insert a back slash
Web Element type
Web element type is used to store the
element, it is a return type of find element
type method
We use web element type to perform multiple
quotes.
Scroll down operation
It is done using keys enumeration operation
Keys.ARROW-DOWN
Keys.END
Key.HOME
Handling list box
Steps to perform operations on list box
◦ Find the dropdown list using findElement() method
◦ Create instance of select class by specifying the above
dropdown list elements as a argument for select class
constructor
◦ Select the required options present in dropdown list by calling
any on of the following methods
SelectByIndex(index)
This method is use to select the required option based on index which
is sequential number, which starts from 0
Select ByValue(value)
This method is used to select the required option based on attribute
value
SelectByVisibleText(String)
This method is used to select the required option based on the actual
name of the option which is displayed in the application
Write a selenium code to count total number
of options present in the list box
◦ List<webElement>l1=s1.getOptions();
◦ Get options method used to get all the options
from the list box and all list box elements are
stored in List<WebElement>l1
◦ L1.size() method used to find total no.of options
present in the list box
◦ List<WebElement> used to store group of elements
Write a selenium code to print the number of
option present in the list box
Write the selenium code to print last options in
the list box
Write a selenium code to print current value in
the list box
◦ getFirstSelectedOption();
This method used to get the current option from the list
box and current option is stored in the web element
reference variable to get name of the option from web
element we use get text() method
Makemytrip
◦ Get the current value from the list box
Justrechargeit.com
◦ Print all the options in the list box
http://www.mymarriage.com/
◦ Find total no.of options present in education list
box
Face book
◦ Print the last year in the list box
Handling the multi select list box
In order to select the required option in the
multi select list box we use methods of select
class it will keep already selected option as it
is and it will select the newly specified option
also
◦ In order to un select the option we use following
methods
deselectByIndex(index)
deselectBYvalue(value)
deselectByVisibleText(text)
Actions class
Handling special keyboard and mouse events are
done using advanced user interactions api. It
contains the actions class that is needed which
executing these events. The following are the
most commonly used key boards and mouse
events provided by the actions class
Using actions class we can perform following the
operations
◦ Mouse move operations
◦ Drag and drop operations
◦ Right click operation
◦ Double click operation
Drag and drop operation
Actions class.DragANDDrop(from element, to
element ).build().perform();
DragAndDrop() method used to drag source
opt.setProfile(p1);
WebDriver driver = new FirefoxDriver(opt);
driver.get("https://www.seleniumhq.org/download/");
driver.manage().window().maximize();
driver.findElement(By.linkText("3.141.59")).click();