This document provides an overview of automated testing with Selenium. It discusses the Selenium architecture including the Selenium IDE, WebDriver, and Grid. It then covers different locator techniques in Selenium like XPath, ID, name and more. The document demonstrates how to set up the testing environment in Eclipse and launch browsers. It also introduces TestNG as the testing framework and shows how to install and use it. Finally, it demonstrates locating elements on a real website using different locator techniques.
2. 2
Agenda
1. Architecture of Selenium
2. Introduction to IDE, WebDriver and
Selenium Grid
3. Different Locator Technique
4. Invoke Different Browsers and logic behind
browsers
5. TestNG
6. Automate a LoginPage
7. QnA
2
3. Architecture of Selenium
3
JSON Wire Protocol
over HTTP
JSON Wire Protocol
over HTTP BrowserBrowser
Driver APIDriver API
C#C#
RubyRubyRubyRuby
JavaJava
PythonPython
Language Binding
OR
Selenium Client Library Real BrowsersReal Browsers
http request over
HTTP Server
http response to
HTTP Server
Selenium Server
4. IDE, WebDriver and Grid
Selenium IDE
• Selenium IDE is an integrated development environment for Selenium scripts. It is implemented
as a Chrome and Firefox extension, and allows you to record, edit, and debug tests.
• This is basically record and play
• Recorded script can be exported in different languages.
• This extension is available for Chrome and Mozilla
4
5. SeleniumWebDriver
• WebDriver is one of the most powerful and popular tools of Selenium Family.
• WebDriver extends its support to many latest browsers and platforms
• WebDriver makes direct calls to the Web browser and the entire test script is executed in this
fashion. WebDriver uses the browsers support and capabilities to automation.
• It drives the browser much more effectively
Selenium Grid
• Selenium Grid is a part of the Selenium Suite that enable in running multiple tests across different
browsers, in different OS and in different Machines.
• This will assures us that the application is fully compatible to different browsers running on
different OS
• It reduces the time to test application on diversified environment.
5
IDE, WebDriver and Grid cont..
6. Setup the Environment in Eclipse
• Download Selenium server from selenium official portal seleniumhq.org
• Download selenium language binding (Java we will be using here)
• Download Chrome Browser executable file (https://chromedriver.storage.googleapis.com/index.html?path=2.41/)
• Start Eclipse and Create a Java Project.
• Add the downloaded JAR to this project (Selenium Server Jar and Java language jar)
6
Launch the browser
public class LaunchBrowsers {
public WebDriver driver;
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", “C:chromedriver.exe");
ChromeDriver driver = new ChromeDriver();
driver.get("https://google.com");
7. 7
Program and logics behind it
public class LaunchBrowsers {
public WebDriver driver;
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", “C:chromedriver.exe");
ChromeDriver driver = new ChromeDriver();
driver.get("https://google.com");
Let’s understand the Browser behavior and the logic behind it.
8. TestNG
• TestNG is a testing framework
• This is an open source testing framework, TestNG has NG, which means Next Generation
• TestNG is derived after JUnit and it is much more powerful than JUnit
• TestNG enables us to write Business logic, Step by Step test, write information about Test,
Prioirtize the Testing Methods and Testing functionalities.
• There are many annotations used on TestNG like - @BeforeTest, @AfterTest, @BeforeClass,
@Test
Install TestNG in Eclipse
• Eclipse >> Help >> install New Software >> Name: TestNG” and type “http://beust.com/eclipse/”
as location.
8
TestNG : How it works
9. • Selenium works on Web automation through action performed on Web Component –
which is called as “Locators”
• We use these locators in our test script and while execution selenium server performs
action on these locators – which is called as “Web Elements”
• In Selenium there are 8 ways to locate these element
1.By xpath
2.By ID
3.By Name
4.By Link Text
5.By Partial Link Text
6.By Class Name
7.By CSS
8.By Tag Name
9
Locator Technique in Selenium
10. Demo and Practical on Locators on Real Website
Let’s launch the demo portal and locate the elements:
10
Who we are
Testing JS code and front-end
Listing the types of tests
Looking at some test tools
Writing and running tests
Testing without the browser
What is a headless browser
Scripting with a headless browser
Testing with a headless browser
Continuous Integration
Deploying code
Integrating testing with builds
Review build results