Selenium Notes - Part 1
Selenium Notes - Part 1
1. What is Selenium ?
Limitation of Selenium :
● It doesn’t support windows based applica on directly. However, third party tool (eg: AutoIt) can be
integrated with selenium to automate windows based applica ons.
Note :
1. Selenium community developed specific tool called WINIUM to automate windows based applica ons.
2. Selenium community also developed tools to test mobile applica ons,
● Selendroid - it supports only Android pla orm
● Appium - it supports Android pla orm, MAC, Windows etc.
Note :
All the selenium related resources and documents can be found on the below website.
h p://www.seleniumhq.org
-------------------------------------------------------------------------------------------------------
hence, cross browser tes ng/compa bility tes ng can be performed using selenium.
7. It supports almost all the Opera ng System (MAC, Windows, LINUX etc) and hence,
--------------------------------------------------------------------------------------------------------
● Selenium Core (Developed by a company called Thought Works way back in 2004)
● Selenium IDE (supports only Mozilla Firefox - supports record and playback feature)
● Selenium RC (Remote Control - Version is 1.x) (Used for parallel execu on of automa on scripts on
mul ple remote systems)
● Selenium WebDriver (Version is 2.x and 3.x)
Note :
Selenium WebDriver version 3.x is no longer capable of running Selenium RC directly, rather it does through
emula on and via an interface called WebDriverBackedSelenium.
Selenium Grid :
1. It is one of the component of selenium that is used to run automa on scripts on mul ple system
simultaneously.
2. It is used to carry out compa bility tes ng on mul ple browsers and pla orms.
--------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------
4. Driver Executables
5. Browsers:
Note : To stop auto update of firefox browser version, Make sure to disconnect the internet connec on
and then install 54.0 version, now go to Se ng/Op on in firefox browser and check the below checkbox -
Never check for updates.
https://www.actitime.com/download.php
--------------------------------------------------------------------------------------------------------
OR
1. Since selenium supports multiple languages such as Java, Python, C# etc, we can develop automation
scripts in all the supported languages. This is know as language binding or Client binding.
2. When we execute the selenium code, request goes to the Selenium Standalone Server (also known as
Selenium WebDriver Server), which further process the request based on the input received from the
client binding and perform specific actions on the respective browsers using the browser specific driver
executables,
3. Driver executables uses a protocol called JSON Wire protocol to communicate with related
--------------------------------------------------------------------------------------------------------
NOTE :
All the above men oned interfaces and classes are present in a package called “org.openqa.selenium”.
To view any information about Selenium interfaces, classes and methods, navigate to the below page.
https://github.com/SeleniumHQ/selenium/tree/master/java/client/src/org/openqa/selenium
8. List down all the methods present in below interfaces of Selenium WebDriver.
1. findElement()
2. findElements()
1. close()
2. get()
3. getTitle()
4. getPageSource()
5. getCurrentUrl()
6. getWindowHandle()
7. getWindowHandles()
8. manage()
9. navigate()
10. quit()
11. switchTo()
1. executeScript()
2. executeAsyncScript() - we don’t use this for automation
1. clear()
2. click()
3. getAttribute()
4. getCssValue()
5. getLocation()
6. getRect()
7. getSize()
8. getTagName()
9. getText()
10. isDisplayed()
11. isEnabled()
12. isSelected()
13. sendKeys()
14. submit()
9. Why we upcast the browser related child class to WebDriver, and not RemoteWebDriver class
(RemoteWebDriver being the super most class in selenium) ?
Upcasting Example :
Url - h p://www.seleniumhq.org/projects/webdriver/
-------------------------------------------------------------------------------------------
1. WebDriver is an interface in Selenium that extends the supermost interface called SearchContext.
2. driver is the upcasted object or WebDriver interface reference variable.
3. “ = ” is an assignment operator.
4. new is a keyword using which object of the FirefoxDriver class is created.
5. FirefoxDriver() is the constructor of FirefoxDriver class which ini alises the object and it will also launch
the firefox browser.
-------------------------------------------------------------------------------------------
1. Launch eclipse and go to package explorer [naviga on path :- Window menu → Show View → Package
Explorer]
2. Create a java project [File → New→ Java Project]
3. Right click on Java Project and add a new folder with name “driver” [File → New→ Folder]
4. copy geckodriver.exe file from your system and paste it into this driver folder
5. Similarly, create another folder with name “jar”and copy Selenium Standalone Server.jar file into this jar
folder.
6. Expand the jar folder and right click on Selenium Standalone Server.jar file → select Build Path → select
Add to Build Path
7. As soon as you add any .jar files to build path, a new folder will be available called “Reference Libraries”
under the package explorer sec on and you can see the .jar file is added to this “Reference Libraries”
8. To remove the .jar file from the java build path, go to the Reference Libraries → select the .jar file → right
click → select build path → Remove from build path.
9. Other way of adding .jar file to java build path is : right click on the project → build path → configure build
path → Libraries tab → Add External jars → select the .jar file → Apply → ok
12. This program demonstrates Upcasting concept (FirefoxDriver class object to WebDriver interface) and
accessing various methods of WebDriver interface
package qspiders;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
System.setProperty("webdriver.gecko.driver", ".\\driver\\geckodriver.exe");
driver.get("http://www.google.com");
//Get the title of the google page and print it on the console
//Get the URL of the google page and print it on the console
//Get the source code of the google page and print it on the console
Thread.sleep(2000);
driver.close();