SlideShare a Scribd company logo
Introduction to Selenium Web Driver
Kokhanjuk Maria Test Lead




2012                        www.ExigenServices.com
Agenda


•What is Selenium 2.0
•Architecture of Selenium 2.0
•Selenium 2.0 API:
  • Finding elements
  • Basic operations on elements
  • Moving between windows and frames
  • Explicit and Implicit Waits
•Creating tests using Selenium 2.0

                                     2   www.ExigenServices.com
What is Selenium?

Selenium is a set of tools for cross-platform automated testing
of web applications.

Selenium supports:

   • IE, Firefox, Safari, Opera and other browsers

   • Windows, OS X, Linux, Solaris and other OS’s

   • C#, Java, Perl, PHP, Python, Ruby and other languages

   • Bromine, JUnit, NUnit, RSpec, TestNG, unittest



                                             3       www.ExigenServices.com
Components of Selenium


• Selenium IDE


• Selenium Remote Control (RC)


• Selenium Grid


• Selenium 2.0 and WebDriver


                        4      www.ExigenServices.com
What is Selenium 2.0 ?


Selenium 1.0                 Webdriver


IDE
Selenium RC
                     merge
Selenium Grid




                 Selenium
                Webdriver 2.0


                                     5   www.ExigenServices.com
Selenium 1.0 Architecture


   Autotests          HTTP
(Java, PHP, Phyton,          Selenium RC
   Ruby, C#, …)




                                Browsers




                             Web-application



                                               6   www.ExigenServices.com
Selenium 2.0 Architecture




Autotests           Driver      Browsers




                             Web-application



   API
   to control the
   browser




                                               7   www.ExigenServices.com
Advantages of Selenium 2.0



• The development and connection of new drivers,
  adapted to the specific test environment
• A more "advanced" API for writing tests
• Events generated are the same as for manual testing
• Work with invisible elements is not available




                                        8    www.ExigenServices.com
Disadvantages of Selenium 2.0


• Need to create own webdriver for each test
  environment
• Only 4 programming languages are supported




                                       9       www.ExigenServices.com
WebDriver’s Drivers

WebDriver

•HtmlUnit Driver
•Firefox Driver
•Internet Explorer Driver
•Chrome Driver
•Opera Driver
•iPhone Driver
•Android Driver




                                    10   www.ExigenServices.com
Selenium API


WebDriver – to control the browser


   WebDriver driver = new FirefoxDriver();

WebElement – to work with the elements on the page


   WebElement element =
   driver.findElement(By.id(“id”));




                                      11     www.ExigenServices.com
WebDriver API

 void get(java.lang.String url) – open page

 void quit() – close browser

 WebDriver.TargetLocator switchTo() – switching
  between the popup-E, alert, windows

 WebElement findElement(By by) -– find element by
  locator

 List<WebElement> findElements(By by) – find
  elements by locator
                                        12     www.ExigenServices.com
Selenium API: Find elements


 By.id("idOfObject")
 By.linkText("TextUsedInTheLink")
 By.partialLinkText("partOfThelink")
 By.tagName("theHTMLNodeType")
 By.className("cssClassOnTheElement")
 By.cssSelector("cssSelectorToTheElement")
 By.xpath("//Xpath/to/the/element")
 By.name("nameOfElement")


                                        13   www.ExigenServices.com
Selenium API: Find elements

Tools for finding elements:

1. Firebug. Download firebug at http://getfirebug.com/




2. Firefinder for Firebug


                                     14    www.ExigenServices.com
Selenium API: Find elements




http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#selectors


                                                     15     www.ExigenServices.com
Selenium API: Basic operations on
                             elements
 void click()

 void submit()

 String getValue()

 void sendKeys(keysToSend)

 void clear()

 String getElementName()

 String getAttribute(java.lang.String name)

 boolean toggle()
                                      16   www.ExigenServices.com
Selenium API: Waits



Implicit Waits

Explicit Waits




                                        17   www.ExigenServices.com
Working with windows
 Working with browser windows
    driver.getWindowHandles()
   driver.switchTo().window(windowName)
 Working with frames
   driver.switchTo().frame( "frameName" );

 Working with alerts
    driver.switchTo().alert();



                                       18    www.ExigenServices.com
Create tests


1. Java
   http://java.com/ru/download


2. IDE

3. Library Selenium WebDriver
  http://seleniumhq.org/download/

4. Firebug



                                    19   www.ExigenServices.com
Create test

Test Case:
  Selenium is in the first line of request for rambler search
Condition:
  Browser is open
Steps:
  1. Enter “selenium webdriver” into search request
  2. Press search button
Expected result:
  The first line of request must be a link to the official
  Selenium website
                                           20   www.ExigenServices.com
Create test

public class Rambler {

  protected WebDriver driver;


  @Before
  public void setUp() throws Exception {
      System.out.println("tmp");
      // driver = new FirefoxDriver();

      driver = new InternetExplorerDriver();
      driver.get("http://www.rambler.ru/");

  }




                                                            21   www.ExigenServices.com
Create test

@Test
 public void RamblerSearch() throws Exception {


     System.out.println(" TC: Selenium is in the first line of request for rambler search");
     waitUntilDisplayed(By.cssSelector(Constants.txtRambler));

     driver.findElement(By.cssSelector(Constants.txtRambler)).sendKeys("selenium webdriver");
     driver.findElement(By.className("pointer")).click();
     //wait first result
     waitUntilDisplayed(By.cssSelector("div[class='b-left-column__wrapper']"));


     assertTrue(driver.findElement(By.cssSelector("div[class='b-podmes_books b-
podmes_top_1']")).getText().contains("Selenium - Web Browser Automation"));


 }

                                                                              22        www.ExigenServices.com
Create test


public class Constants {


    public static final String txtRambler = "input[class='r--hat-form-text-input']";


}




                                                                     23       www.ExigenServices.com
Create test

@Test
 public void RamblerSearch() throws Exception {


     System.out.println(" TC: Selenium is in the first line of request for rambler search");
     waitUntilDisplayed(By.cssSelector(Constants.txtRambler));

     driver.findElement(By.cssSelector(Constants.txtRambler)).sendKeys("selenium webdriver");
     driver.findElement(By.className("pointer")).click();
     //wait first result
     waitUntilDisplayed(By.cssSelector("div[class='b-left-column__wrapper']"));


assertTrue(driver.findElement(By.cssSelector("div[class='b-podmes_books b-
 podmes_top_1']")).getText().contains("Selenium - Web Browser Automation"));
 }



                                                                              24        www.ExigenServices.com
Create test

public void waitUntilDisplayed(final By locator) {

      ( new WebDriverWait(driver, 120)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {
                return d.findElement(locator).isDisplayed();
            }

      });
  }


  @After

  public void tearDown() throws Exception {
      //close browser

      driver.quit();
  }



                                                                     25       www.ExigenServices.com
Create test: result




                      26   www.ExigenServices.com
Create test: result




                      27   www.ExigenServices.com
Structure of the test


1. Use Set UP () and tearDown()

2. All tests should finish with assertion

3. Elements’ locators should be defined in separate
class




                                      28    www.ExigenServices.com
Useful links

• http://seleniumhq.org/docs/

• http://software-testing.ru/library/testing/functional-
  testing/1398-selenium-20

• http://automated-
  testing.info/knowledgebase/avtomatizaciya-
  funkcionalnogo-testirovaniya/selenium

• http://autotestgroup.com/ru/

• http://www.w3.org/TR/2001/CR-css3-selectors-
  20011113/#selectors

• http://junit.org
                                            30     www.ExigenServices.com
Questions




     Questions?




                  31   www.ExigenServices.com

More Related Content

What's hot

SELENIUM PPT.pdf
SELENIUM PPT.pdfSELENIUM PPT.pdf
SELENIUM PPT.pdf
RebelSnowball
 
Web application testing with Selenium
Web application testing with SeleniumWeb application testing with Selenium
Web application testing with Selenium
Kerry Buckley
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriver
Anuraj S.L
 
Selenium
SeleniumSelenium
Selenium
Batch2016
 
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Simplilearn
 
Selenium IDE LOCATORS
Selenium IDE LOCATORSSelenium IDE LOCATORS
Selenium IDE LOCATORS
Mindfire Solutions
 
Automation Testing using Selenium Webdriver
Automation Testing using Selenium WebdriverAutomation Testing using Selenium Webdriver
Automation Testing using Selenium Webdriver
Pankaj Biswas
 
Selenium
SeleniumSelenium
Selenium
Kalyan ch
 
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Simplilearn
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
Pavan Kumar
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
Aneesh Rangarajan
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
Web automation using selenium.ppt
Web automation using selenium.pptWeb automation using selenium.ppt
Web automation using selenium.ppt
Ana Sarbescu
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
vivek_prahlad
 
Selenium- A Software Testing Tool
Selenium- A Software Testing ToolSelenium- A Software Testing Tool
Selenium- A Software Testing Tool
Zeba Tahseen
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
Anirudh Raja
 
Python selenium
Python seleniumPython selenium
Python selenium
Ducat
 
Introduction to selenium
Introduction to seleniumIntroduction to selenium
Introduction to selenium
Archana Krushnan
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
Cynoteck Technology Solutions Private Limited
 
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
Simplilearn
 

What's hot (20)

SELENIUM PPT.pdf
SELENIUM PPT.pdfSELENIUM PPT.pdf
SELENIUM PPT.pdf
 
Web application testing with Selenium
Web application testing with SeleniumWeb application testing with Selenium
Web application testing with Selenium
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriver
 
Selenium
SeleniumSelenium
Selenium
 
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
 
Selenium IDE LOCATORS
Selenium IDE LOCATORSSelenium IDE LOCATORS
Selenium IDE LOCATORS
 
Automation Testing using Selenium Webdriver
Automation Testing using Selenium WebdriverAutomation Testing using Selenium Webdriver
Automation Testing using Selenium Webdriver
 
Selenium
SeleniumSelenium
Selenium
 
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
Selenium WebDriver Tutorial | Selenium WebDriver Tutorial For Beginner | Sele...
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
Web automation using selenium.ppt
Web automation using selenium.pptWeb automation using selenium.ppt
Web automation using selenium.ppt
 
Web Test Automation with Selenium
Web Test Automation with SeleniumWeb Test Automation with Selenium
Web Test Automation with Selenium
 
Selenium- A Software Testing Tool
Selenium- A Software Testing ToolSelenium- A Software Testing Tool
Selenium- A Software Testing Tool
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Python selenium
Python seleniumPython selenium
Python selenium
 
Introduction to selenium
Introduction to seleniumIntroduction to selenium
Introduction to selenium
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
 

Similar to Introduction to Selenium Web Driver

Introduction to selenium web driver
Introduction to selenium web driverIntroduction to selenium web driver
Introduction to selenium web driver
Return on Intelligence
 
Introduction to selenium web driver
Introduction to selenium web driverIntroduction to selenium web driver
Introduction to selenium web driver
Return on Intelligence
 
Selenium WebDriver FAQ's
Selenium WebDriver FAQ'sSelenium WebDriver FAQ's
Selenium WebDriver FAQ's
Praveen Gorantla
 
Getting started with Selenium 2
Getting started with Selenium 2Getting started with Selenium 2
Getting started with Selenium 2
Sebastiano Armeli
 
Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch  Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch
Haitham Refaat
 
Selenium training
Selenium trainingSelenium training
Selenium training
Suresh Arora
 
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptxTop 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
AnanthReddy38
 
selenium-webdriver-interview-questions.pdf
selenium-webdriver-interview-questions.pdfselenium-webdriver-interview-questions.pdf
selenium-webdriver-interview-questions.pdf
AnuragMourya8
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
orbitprojects
 
Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
Quontra Solutions
 
Web driver training
Web driver trainingWeb driver training
Web driver training
Dipesh Bhatewara
 
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfTop 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
AnanthReddy38
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
Ajit Jadhav
 
Best Selenium Online Training
Best Selenium Online TrainingBest Selenium Online Training
Best Selenium Online Training
Samatha Kamuni
 
Selenium
SeleniumSelenium
Selenium
傑倫 鍾
 
前端網頁自動測試
前端網頁自動測試 前端網頁自動測試
前端網頁自動測試
政億 林
 
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Edureka!
 
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Atirek Gupta
 
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudEnterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud
Carlos Sanchez
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in
Sandeep Tol
 

Similar to Introduction to Selenium Web Driver (20)

Introduction to selenium web driver
Introduction to selenium web driverIntroduction to selenium web driver
Introduction to selenium web driver
 
Introduction to selenium web driver
Introduction to selenium web driverIntroduction to selenium web driver
Introduction to selenium web driver
 
Selenium WebDriver FAQ's
Selenium WebDriver FAQ'sSelenium WebDriver FAQ's
Selenium WebDriver FAQ's
 
Getting started with Selenium 2
Getting started with Selenium 2Getting started with Selenium 2
Getting started with Selenium 2
 
Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch  Step by step - Selenium 3 web-driver - From Scratch
Step by step - Selenium 3 web-driver - From Scratch
 
Selenium training
Selenium trainingSelenium training
Selenium training
 
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptxTop 15 Selenium WebDriver Interview Questions and Answers.pptx
Top 15 Selenium WebDriver Interview Questions and Answers.pptx
 
selenium-webdriver-interview-questions.pdf
selenium-webdriver-interview-questions.pdfselenium-webdriver-interview-questions.pdf
selenium-webdriver-interview-questions.pdf
 
Selenium.pptx
Selenium.pptxSelenium.pptx
Selenium.pptx
 
Automation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra SolutionsAutomation with Selenium Presented by Quontra Solutions
Automation with Selenium Presented by Quontra Solutions
 
Web driver training
Web driver trainingWeb driver training
Web driver training
 
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdfTop 15 Selenium WebDriver Interview Questions and Answers.pdf
Top 15 Selenium WebDriver Interview Questions and Answers.pdf
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
 
Best Selenium Online Training
Best Selenium Online TrainingBest Selenium Online Training
Best Selenium Online Training
 
Selenium
SeleniumSelenium
Selenium
 
前端網頁自動測試
前端網頁自動測試 前端網頁自動測試
前端網頁自動測試
 
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
Selenium WebDriver Tutorial For Beginners | What Is Selenium WebDriver | Sele...
 
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
 
Enterprise Build And Test In The Cloud
Enterprise Build And Test In The CloudEnterprise Build And Test In The Cloud
Enterprise Build And Test In The Cloud
 
Selenium Automation in Java Using HttpWatch Plug-in
 Selenium Automation in Java Using HttpWatch Plug-in  Selenium Automation in Java Using HttpWatch Plug-in
Selenium Automation in Java Using HttpWatch Plug-in
 

More from Return on Intelligence

Profsoux2014 presentation by Pavelchuk
Profsoux2014 presentation by PavelchukProfsoux2014 presentation by Pavelchuk
Profsoux2014 presentation by Pavelchuk
Return on Intelligence
 
Agile Project Grows
Agile Project GrowsAgile Project Grows
Agile Project Grows
Return on Intelligence
 
Types of testing and their classification
Types of testing and their classificationTypes of testing and their classification
Types of testing and their classification
Return on Intelligence
 
Time Management
Time ManagementTime Management
Time Management
Return on Intelligence
 
Service design principles and patterns
Service design principles and patternsService design principles and patterns
Service design principles and patterns
Return on Intelligence
 
Differences between Testing in Waterfall and Agile
Differences between Testing in Waterfall and AgileDifferences between Testing in Waterfall and Agile
Differences between Testing in Waterfall and Agile
Return on Intelligence
 
Windows Azure: Quick start
Windows Azure: Quick startWindows Azure: Quick start
Windows Azure: Quick start
Return on Intelligence
 
Windows azurequickstart
Windows azurequickstartWindows azurequickstart
Windows azurequickstart
Return on Intelligence
 
Организация внутренней системы обучения
Организация внутренней системы обученияОрганизация внутренней системы обучения
Организация внутренней системы обучения
Return on Intelligence
 
Shared position in a project: testing and analysis
Shared position in a project: testing and analysisShared position in a project: testing and analysis
Shared position in a project: testing and analysis
Return on Intelligence
 
Introduction to Business Etiquette
Introduction to Business EtiquetteIntroduction to Business Etiquette
Introduction to Business Etiquette
Return on Intelligence
 
Agile Testing Process
Agile Testing ProcessAgile Testing Process
Agile Testing Process
Return on Intelligence
 
Оценка задач выполняемых по итеративной разработке
Оценка задач выполняемых по итеративной разработкеОценка задач выполняемых по итеративной разработке
Оценка задач выполняемых по итеративной разработке
Return on Intelligence
 
Meetings arranging
Meetings arrangingMeetings arranging
Meetings arranging
Return on Intelligence
 
How to develop your creativity
How to develop your creativityHow to develop your creativity
How to develop your creativity
Return on Intelligence
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Return on Intelligence
 
The art of project estimation
The art of project estimationThe art of project estimation
The art of project estimation
Return on Intelligence
 
Successful interview for a young IT specialist
Successful interview for a young IT specialistSuccessful interview for a young IT specialist
Successful interview for a young IT specialist
Return on Intelligence
 
Risk Management
Risk ManagementRisk Management
Risk Management
Return on Intelligence
 
Resolving conflicts
Resolving conflictsResolving conflicts
Resolving conflicts
Return on Intelligence
 

More from Return on Intelligence (20)

Profsoux2014 presentation by Pavelchuk
Profsoux2014 presentation by PavelchukProfsoux2014 presentation by Pavelchuk
Profsoux2014 presentation by Pavelchuk
 
Agile Project Grows
Agile Project GrowsAgile Project Grows
Agile Project Grows
 
Types of testing and their classification
Types of testing and their classificationTypes of testing and their classification
Types of testing and their classification
 
Time Management
Time ManagementTime Management
Time Management
 
Service design principles and patterns
Service design principles and patternsService design principles and patterns
Service design principles and patterns
 
Differences between Testing in Waterfall and Agile
Differences between Testing in Waterfall and AgileDifferences between Testing in Waterfall and Agile
Differences between Testing in Waterfall and Agile
 
Windows Azure: Quick start
Windows Azure: Quick startWindows Azure: Quick start
Windows Azure: Quick start
 
Windows azurequickstart
Windows azurequickstartWindows azurequickstart
Windows azurequickstart
 
Организация внутренней системы обучения
Организация внутренней системы обученияОрганизация внутренней системы обучения
Организация внутренней системы обучения
 
Shared position in a project: testing and analysis
Shared position in a project: testing and analysisShared position in a project: testing and analysis
Shared position in a project: testing and analysis
 
Introduction to Business Etiquette
Introduction to Business EtiquetteIntroduction to Business Etiquette
Introduction to Business Etiquette
 
Agile Testing Process
Agile Testing ProcessAgile Testing Process
Agile Testing Process
 
Оценка задач выполняемых по итеративной разработке
Оценка задач выполняемых по итеративной разработкеОценка задач выполняемых по итеративной разработке
Оценка задач выполняемых по итеративной разработке
 
Meetings arranging
Meetings arrangingMeetings arranging
Meetings arranging
 
How to develop your creativity
How to develop your creativityHow to develop your creativity
How to develop your creativity
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
The art of project estimation
The art of project estimationThe art of project estimation
The art of project estimation
 
Successful interview for a young IT specialist
Successful interview for a young IT specialistSuccessful interview for a young IT specialist
Successful interview for a young IT specialist
 
Risk Management
Risk ManagementRisk Management
Risk Management
 
Resolving conflicts
Resolving conflictsResolving conflicts
Resolving conflicts
 

Introduction to Selenium Web Driver

  • 1. Introduction to Selenium Web Driver Kokhanjuk Maria Test Lead 2012 www.ExigenServices.com
  • 2. Agenda •What is Selenium 2.0 •Architecture of Selenium 2.0 •Selenium 2.0 API: • Finding elements • Basic operations on elements • Moving between windows and frames • Explicit and Implicit Waits •Creating tests using Selenium 2.0 2 www.ExigenServices.com
  • 3. What is Selenium? Selenium is a set of tools for cross-platform automated testing of web applications. Selenium supports: • IE, Firefox, Safari, Opera and other browsers • Windows, OS X, Linux, Solaris and other OS’s • C#, Java, Perl, PHP, Python, Ruby and other languages • Bromine, JUnit, NUnit, RSpec, TestNG, unittest 3 www.ExigenServices.com
  • 4. Components of Selenium • Selenium IDE • Selenium Remote Control (RC) • Selenium Grid • Selenium 2.0 and WebDriver 4 www.ExigenServices.com
  • 5. What is Selenium 2.0 ? Selenium 1.0 Webdriver IDE Selenium RC merge Selenium Grid Selenium Webdriver 2.0 5 www.ExigenServices.com
  • 6. Selenium 1.0 Architecture Autotests HTTP (Java, PHP, Phyton, Selenium RC Ruby, C#, …) Browsers Web-application 6 www.ExigenServices.com
  • 7. Selenium 2.0 Architecture Autotests Driver Browsers Web-application API to control the browser 7 www.ExigenServices.com
  • 8. Advantages of Selenium 2.0 • The development and connection of new drivers, adapted to the specific test environment • A more "advanced" API for writing tests • Events generated are the same as for manual testing • Work with invisible elements is not available 8 www.ExigenServices.com
  • 9. Disadvantages of Selenium 2.0 • Need to create own webdriver for each test environment • Only 4 programming languages are supported 9 www.ExigenServices.com
  • 10. WebDriver’s Drivers WebDriver •HtmlUnit Driver •Firefox Driver •Internet Explorer Driver •Chrome Driver •Opera Driver •iPhone Driver •Android Driver 10 www.ExigenServices.com
  • 11. Selenium API WebDriver – to control the browser WebDriver driver = new FirefoxDriver(); WebElement – to work with the elements on the page WebElement element = driver.findElement(By.id(“id”)); 11 www.ExigenServices.com
  • 12. WebDriver API  void get(java.lang.String url) – open page  void quit() – close browser  WebDriver.TargetLocator switchTo() – switching between the popup-E, alert, windows  WebElement findElement(By by) -– find element by locator  List<WebElement> findElements(By by) – find elements by locator 12 www.ExigenServices.com
  • 13. Selenium API: Find elements  By.id("idOfObject")  By.linkText("TextUsedInTheLink")  By.partialLinkText("partOfThelink")  By.tagName("theHTMLNodeType")  By.className("cssClassOnTheElement")  By.cssSelector("cssSelectorToTheElement")  By.xpath("//Xpath/to/the/element")  By.name("nameOfElement") 13 www.ExigenServices.com
  • 14. Selenium API: Find elements Tools for finding elements: 1. Firebug. Download firebug at http://getfirebug.com/ 2. Firefinder for Firebug 14 www.ExigenServices.com
  • 15. Selenium API: Find elements http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#selectors 15 www.ExigenServices.com
  • 16. Selenium API: Basic operations on elements  void click()  void submit()  String getValue()  void sendKeys(keysToSend)  void clear()  String getElementName()  String getAttribute(java.lang.String name)  boolean toggle() 16 www.ExigenServices.com
  • 17. Selenium API: Waits Implicit Waits Explicit Waits 17 www.ExigenServices.com
  • 18. Working with windows  Working with browser windows driver.getWindowHandles() driver.switchTo().window(windowName)  Working with frames driver.switchTo().frame( "frameName" );  Working with alerts driver.switchTo().alert(); 18 www.ExigenServices.com
  • 19. Create tests 1. Java http://java.com/ru/download 2. IDE 3. Library Selenium WebDriver http://seleniumhq.org/download/ 4. Firebug 19 www.ExigenServices.com
  • 20. Create test Test Case: Selenium is in the first line of request for rambler search Condition: Browser is open Steps: 1. Enter “selenium webdriver” into search request 2. Press search button Expected result: The first line of request must be a link to the official Selenium website 20 www.ExigenServices.com
  • 21. Create test public class Rambler { protected WebDriver driver; @Before public void setUp() throws Exception { System.out.println("tmp"); // driver = new FirefoxDriver(); driver = new InternetExplorerDriver(); driver.get("http://www.rambler.ru/"); } 21 www.ExigenServices.com
  • 22. Create test @Test public void RamblerSearch() throws Exception { System.out.println(" TC: Selenium is in the first line of request for rambler search"); waitUntilDisplayed(By.cssSelector(Constants.txtRambler)); driver.findElement(By.cssSelector(Constants.txtRambler)).sendKeys("selenium webdriver"); driver.findElement(By.className("pointer")).click(); //wait first result waitUntilDisplayed(By.cssSelector("div[class='b-left-column__wrapper']")); assertTrue(driver.findElement(By.cssSelector("div[class='b-podmes_books b- podmes_top_1']")).getText().contains("Selenium - Web Browser Automation")); } 22 www.ExigenServices.com
  • 23. Create test public class Constants { public static final String txtRambler = "input[class='r--hat-form-text-input']"; } 23 www.ExigenServices.com
  • 24. Create test @Test public void RamblerSearch() throws Exception { System.out.println(" TC: Selenium is in the first line of request for rambler search"); waitUntilDisplayed(By.cssSelector(Constants.txtRambler)); driver.findElement(By.cssSelector(Constants.txtRambler)).sendKeys("selenium webdriver"); driver.findElement(By.className("pointer")).click(); //wait first result waitUntilDisplayed(By.cssSelector("div[class='b-left-column__wrapper']")); assertTrue(driver.findElement(By.cssSelector("div[class='b-podmes_books b- podmes_top_1']")).getText().contains("Selenium - Web Browser Automation")); } 24 www.ExigenServices.com
  • 25. Create test public void waitUntilDisplayed(final By locator) { ( new WebDriverWait(driver, 120)).until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { return d.findElement(locator).isDisplayed(); } }); } @After public void tearDown() throws Exception { //close browser driver.quit(); } 25 www.ExigenServices.com
  • 26. Create test: result 26 www.ExigenServices.com
  • 27. Create test: result 27 www.ExigenServices.com
  • 28. Structure of the test 1. Use Set UP () and tearDown() 2. All tests should finish with assertion 3. Elements’ locators should be defined in separate class 28 www.ExigenServices.com
  • 29. Useful links • http://seleniumhq.org/docs/ • http://software-testing.ru/library/testing/functional- testing/1398-selenium-20 • http://automated- testing.info/knowledgebase/avtomatizaciya- funkcionalnogo-testirovaniya/selenium • http://autotestgroup.com/ru/ • http://www.w3.org/TR/2001/CR-css3-selectors- 20011113/#selectors • http://junit.org 30 www.ExigenServices.com
  • 30. Questions Questions? 31 www.ExigenServices.com