Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Selenium Java for Beginners by Sujit Pathak


Published on

In this slides, Sujit Pathak explains how to get started with Selenium Java.

See recorded video at

Published in: Education
  • Be the first to comment

  • Be the first to like this

Selenium Java for Beginners by Sujit Pathak

  1. 1. 1 Automated Testing With Selenium 1
  2. 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. 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. 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. 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. 6. Setup the Environment in Eclipse • Download Selenium server from selenium official portal • Download selenium language binding (Java we will be using here) • Download Chrome Browser executable file ( • 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("", “C:chromedriver.exe"); ChromeDriver driver = new ChromeDriver(); driver.get("");
  7. 7. 7 Program and logics behind it public class LaunchBrowsers { public WebDriver driver; public static void main(String[] args) { System.setProperty("", “C:chromedriver.exe"); ChromeDriver driver = new ChromeDriver(); driver.get(""); Let’s understand the Browser behavior and the logic behind it.
  8. 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 “” as location. 8 TestNG : How it works
  9. 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. 10. Demo and Practical on Locators on Real Website Let’s launch the demo portal and locate the elements: 10
  11. 11. 11
  12. 12. 12