SlideShare a Scribd company logo
SELENIUM 
WEBDRIVER 
Yuriy Bezgachnyuk, SSU/ITA 
October, 2014
Test automation 
What is Selenium WebDriver 
Selenium WD Features 
Document Object Model (DOM) 
 Locators 
Example task 
 PageObject pattern introduction 
2 
Agenda
Test Automation 
 In software testing, 
test automation is 
the use of special 
software (separate 
from the software 
being tested) to 
control the execution 
of tests and the 
comparison of actual 
outcomes to 
predicted outcomes. 
Test automation 3
What is Selenium Web Driver 
Selenium WebDriver – it’s a compact 
Object-Oriented API for Internet Browsers 
control 
WebDriver is the name of the key interface 
against which tests should be written in 
Java, Python, Ruby, … 
What is Selenium Web Driver 4
Selenium WD Features 
Connects to most modern browsers 
 Allows remote control 
 Finds elements by selectors 
 Modifies values of HTML elements 
 Interacts with DOM elements 
 Handles modal, popup windows 
Selenium WD Features 5
Document Object Model (DOM) 
The Document Object Model (DOM) is a 
cross-platform and language-independent 
convention for representing and interacting 
with objects in HTML, XHTML and XML 
documents. 
DOM Introduction 6
DOM [Locators] 
Select any HTML element(s) from DOM by 
using 
 tags name 
 attributes of tags 
• id, name, … 
 CSS selectors 
 XPath 
DOM [Locators] 7
Example Task 
A web-page with a HTML form is given 
[Fig. 1] 
User login functionality should be tested 
 Set value for ‘login’ field 
 Set value for ‘password’ field 
 Click submit button 
 Check results 
Task 8
Explanation of example 
URL for Login form 
http://<HOME_URL>/admin/login 
User inputs correct credentials and is 
redirected to URL: 
http://<HOME_URL>/admin 
otherwise user is redirected back to the 
login form page 
Explanation of practical example 9
Implementation [Template] 
JUnit 4 testing framework will be used 
Template 10 
Initial 
operations 
Finally 
operations 
Our main part of 
code will be here
setUp() method 
setUp() method provides pre-test 
WebDriver configuration. 
setUp() 11 
Object for 
concrete 
browser 
Set time for 
waiting 
Visit to page 
specified in 
URL constant
tearDown() method 
 tearDown() method provides post-test 
actions (WebDriver object disposal, used 
resources freeing). 
Close WebDriver 
and free 
resources 
tearDown() method 12
Task implementation 
Page Object pattern use. 
Selenium WebDriver use for low-level 
browser API functions only!!! 
Definitions of Page Object pattern: 
 Each single web-page is represented through a 
Java class 
 User actions for each web page are 
implemented as class methods 
PageObject pattern [Introduction] 13
PageObject Pattern 
PageObject Pattern 14
Task Implementation 
Let investigate our code for test user logon 
Object for HomePage 
where login form is 
Task’s solution 15 
placed 
Object for ResultPage 
URL from address bar 
of browser 
Comparison existing 
URL address with 
needed address
16 
Class HomePage 
Method for set 
values into HTML 
form and submit 
data to server
Code sample 
Code investigation 17
WebDriver Low level methods 
findElement(By arg) – searches and 
returns an object representation of DOM 
element. Input parameter arg – some of 
possible selectors (using static methods of 
By class) 
sendKeys(CharSequence arg) – sends 
char sequence to a HTML form element 
click() – clicks on a DOM element 
WD Low-level methods 18
Windows handling 
Web applications may have frames or 
multiple windows, that need to be 
specifically handled. WebDriver supports 
moving between named windows with 
switchTo() method: 
Windows switching should be used when 
application has JS modal windows (alerts) 
driver.switchTo().window("windowName"); 
Moving between windows and frames 19
Windows handling 
 When we clicking “Вхід” button without 
supplying credentials an alert modal 
window appears [Fig.1] 
 In order to click ‘OK’ 
button WebDriver 
should be switched to 
modal window 
Moving between windows and frames 20
Example #2 [Code] 
 Let’s take a look at the code 
Switch to JS alert 
window and click ‘OK’ 
button 
Example #2 [Code] 21
22 
“Main” class source
http://www.w3schools.com/ 
https://developer.mozilla.org/ 
http://docs.seleniumhq.org/ 
23 
References and Sources
QUESTIONS?

More Related Content

What's hot

Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...Edureka!
 
Test Automation Using Python | Edureka
Test Automation Using Python | EdurekaTest Automation Using Python | Edureka
Test Automation Using Python | EdurekaEdureka!
 
Python selenium
Python seleniumPython selenium
Python seleniumDucat
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with seleniumTzirla Rozental
 
Selenium Presentation at Engineering Colleges
Selenium Presentation at Engineering CollegesSelenium Presentation at Engineering Colleges
Selenium Presentation at Engineering CollegesVijay Rangaiah
 
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
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriverAnuraj S.L
 
Test Automation and Selenium
Test Automation and SeleniumTest Automation and Selenium
Test Automation and SeleniumKarapet Sarkisyan
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriverRajathi-QA
 

What's hot (20)

Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
 
Selenium WebDriver training
Selenium WebDriver trainingSelenium WebDriver training
Selenium WebDriver training
 
Test Automation Using Python | Edureka
Test Automation Using Python | EdurekaTest Automation Using Python | Edureka
Test Automation Using Python | Edureka
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Selenium WebDriver FAQ's
Selenium WebDriver FAQ'sSelenium WebDriver FAQ's
Selenium WebDriver FAQ's
 
Selenium web driver
Selenium web driverSelenium web driver
Selenium web driver
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
Selenium
SeleniumSelenium
Selenium
 
Python selenium
Python seleniumPython selenium
Python selenium
 
Selenium Automation Framework
Selenium Automation  FrameworkSelenium Automation  Framework
Selenium Automation Framework
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
Selenium Presentation at Engineering Colleges
Selenium Presentation at Engineering CollegesSelenium Presentation at Engineering Colleges
Selenium Presentation at Engineering Colleges
 
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 ...
 
An overview of selenium webdriver
An overview of selenium webdriverAn overview of selenium webdriver
An overview of selenium webdriver
 
Test Automation and Selenium
Test Automation and SeleniumTest Automation and Selenium
Test Automation and Selenium
 
Selenium WebDriver
Selenium WebDriverSelenium WebDriver
Selenium WebDriver
 
Selenium-Locators
Selenium-LocatorsSelenium-Locators
Selenium-Locators
 
TestNG Framework
TestNG Framework TestNG Framework
TestNG Framework
 

Viewers also liked

Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using SeleniumNaresh Chintalcheru
 
Webinar: Selenium WebDriver - Automation Uncomplicated
Webinar: Selenium WebDriver - Automation UncomplicatedWebinar: Selenium WebDriver - Automation Uncomplicated
Webinar: Selenium WebDriver - Automation UncomplicatedEdureka!
 
Introduction to Selenium Webdriver - SpringPeople
Introduction to Selenium Webdriver - SpringPeopleIntroduction to Selenium Webdriver - SpringPeople
Introduction to Selenium Webdriver - SpringPeopleSpringPeople
 
Design patterns in web testing automation with WebDriver
Design patterns in web testing automation with WebDriverDesign patterns in web testing automation with WebDriver
Design patterns in web testing automation with WebDriverMikalai Alimenkou
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object patternMichael Palotas
 
Perils of Page-Object Pattern
Perils of Page-Object PatternPerils of Page-Object Pattern
Perils of Page-Object PatternAnand Bagmar
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object PatternDante Briones
 
Selenium Architecture
Selenium ArchitectureSelenium Architecture
Selenium Architecturerohitnayak
 

Viewers also liked (16)

Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Selenium ile Web testi.
Selenium ile Web testi.Selenium ile Web testi.
Selenium ile Web testi.
 
Webinar: Selenium WebDriver - Automation Uncomplicated
Webinar: Selenium WebDriver - Automation UncomplicatedWebinar: Selenium WebDriver - Automation Uncomplicated
Webinar: Selenium WebDriver - Automation Uncomplicated
 
Introduction to Selenium Webdriver - SpringPeople
Introduction to Selenium Webdriver - SpringPeopleIntroduction to Selenium Webdriver - SpringPeople
Introduction to Selenium Webdriver - SpringPeople
 
Selenium topic 3 -Web Driver Basics
Selenium topic 3 -Web Driver BasicsSelenium topic 3 -Web Driver Basics
Selenium topic 3 -Web Driver Basics
 
Selenium Automation
Selenium AutomationSelenium Automation
Selenium Automation
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
Design patterns in web testing automation with WebDriver
Design patterns in web testing automation with WebDriverDesign patterns in web testing automation with WebDriver
Design patterns in web testing automation with WebDriver
 
Selenium - The page object pattern
Selenium - The page object patternSelenium - The page object pattern
Selenium - The page object pattern
 
Perils of Page-Object Pattern
Perils of Page-Object PatternPerils of Page-Object Pattern
Perils of Page-Object Pattern
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Basic Selenium Training
Basic Selenium TrainingBasic Selenium Training
Basic Selenium Training
 
Using The Page Object Pattern
Using The Page Object PatternUsing The Page Object Pattern
Using The Page Object Pattern
 
Selenium Architecture
Selenium ArchitectureSelenium Architecture
Selenium Architecture
 

Similar to Selenium WebDriver

AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014Ran Wahle
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power pointjustmeanscsr
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs WorkshopRan Wahle
 
Testing with test_complete
Testing with test_completeTesting with test_complete
Testing with test_completebinuiweb
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentRob Windsor
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentationBhavin Shah
 
Web UI Tests: Introduce UI tests using Selenium
Web UI Tests: Introduce UI tests using Selenium Web UI Tests: Introduce UI tests using Selenium
Web UI Tests: Introduce UI tests using Selenium Peyman Fakharian
 
Test Automation Framework Development Introduction
Test Automation Framework Development IntroductionTest Automation Framework Development Introduction
Test Automation Framework Development IntroductionGanuka Yashantha
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Roy de Kleijn
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVCSunpawet Somsin
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testingdrewz lin
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullySpringPeople
 
Automated Acceptance Testing Example
Automated Acceptance Testing ExampleAutomated Acceptance Testing Example
Automated Acceptance Testing ExampleHani Massoud
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Jonas Follesø
 
Surviving UI Automation Armageddon with BELLATRIX.pptx
Surviving UI Automation Armageddon with BELLATRIX.pptxSurviving UI Automation Armageddon with BELLATRIX.pptx
Surviving UI Automation Armageddon with BELLATRIX.pptxNikolayAvramov4
 

Similar to Selenium WebDriver (20)

AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014AngularJs Workshop SDP December 28th 2014
AngularJs Workshop SDP December 28th 2014
 
D17251 gc20 47_us
D17251 gc20 47_usD17251 gc20 47_us
D17251 gc20 47_us
 
Selenium
SeleniumSelenium
Selenium
 
Justmeans power point
Justmeans power pointJustmeans power point
Justmeans power point
 
angularJs Workshop
angularJs WorkshopangularJs Workshop
angularJs Workshop
 
Testing with test_complete
Testing with test_completeTesting with test_complete
Testing with test_complete
 
Advanced SharePoint Web Part Development
Advanced SharePoint Web Part DevelopmentAdvanced SharePoint Web Part Development
Advanced SharePoint Web Part Development
 
MVC ppt presentation
MVC ppt presentationMVC ppt presentation
MVC ppt presentation
 
Web UI Tests: Introduce UI tests using Selenium
Web UI Tests: Introduce UI tests using Selenium Web UI Tests: Introduce UI tests using Selenium
Web UI Tests: Introduce UI tests using Selenium
 
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
Deep Dive Modern Apps Lifecycle with Visual Studio 2012: How to create cross ...
 
Test Automation Framework Development Introduction
Test Automation Framework Development IntroductionTest Automation Framework Development Introduction
Test Automation Framework Development Introduction
 
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016Improving Your Selenium WebDriver Tests - Belgium testing days_2016
Improving Your Selenium WebDriver Tests - Belgium testing days_2016
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVCIntroduction to ASP.NET MVC
Introduction to ASP.NET MVC
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Automated Acceptance Testing Example
Automated Acceptance Testing ExampleAutomated Acceptance Testing Example
Automated Acceptance Testing Example
 
Web driver training
Web driver trainingWeb driver training
Web driver training
 
Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008Silverlight 2 for Developers - TechEd New Zealand 2008
Silverlight 2 for Developers - TechEd New Zealand 2008
 
Surviving UI Automation Armageddon with BELLATRIX.pptx
Surviving UI Automation Armageddon with BELLATRIX.pptxSurviving UI Automation Armageddon with BELLATRIX.pptx
Surviving UI Automation Armageddon with BELLATRIX.pptx
 
Mvc summary
Mvc summaryMvc summary
Mvc summary
 

Recently uploaded

Pvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdfPvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdfPvtaan
 
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkkaudience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkklolsDocherty
 
Case study on merger of Vodafone and Idea (VI).pptx
Case study on merger of Vodafone and Idea (VI).pptxCase study on merger of Vodafone and Idea (VI).pptx
Case study on merger of Vodafone and Idea (VI).pptxAnkitscribd
 
How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?Linksys Velop Login
 
Article writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxArticle writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxabhinandnam9997
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEHimani415946
 
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理aagad
 
The Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyThe Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyDamar Juniarto
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesSanjeev Rampal
 
Bug Bounty Blueprint : A Beginner's Guide
Bug Bounty Blueprint : A Beginner's GuideBug Bounty Blueprint : A Beginner's Guide
Bug Bounty Blueprint : A Beginner's GuideVarun Mithran
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxlaozhuseo02
 
The AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfThe AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfSiskaFitrianingrum
 

Recently uploaded (13)

Pvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdfPvtaan Social media marketing proposal.pdf
Pvtaan Social media marketing proposal.pdf
 
The Best AI Powered Software - Intellivid AI Studio
The Best AI Powered Software - Intellivid AI StudioThe Best AI Powered Software - Intellivid AI Studio
The Best AI Powered Software - Intellivid AI Studio
 
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkkaudience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
audience research (emma) 1.pptxkkkkkkkkkkkkkkkkk
 
Case study on merger of Vodafone and Idea (VI).pptx
Case study on merger of Vodafone and Idea (VI).pptxCase study on merger of Vodafone and Idea (VI).pptx
Case study on merger of Vodafone and Idea (VI).pptx
 
How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?How Do I Begin the Linksys Velop Setup Process?
How Do I Begin the Linksys Velop Setup Process?
 
Article writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptxArticle writing on excessive use of internet.pptx
Article writing on excessive use of internet.pptx
 
ER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAEER(Entity Relationship) Diagram for online shopping - TAE
ER(Entity Relationship) Diagram for online shopping - TAE
 
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
一比一原版UTS毕业证悉尼科技大学毕业证成绩单如何办理
 
The Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case StudyThe Use of AI in Indonesia Election 2024: A Case Study
The Use of AI in Indonesia Election 2024: A Case Study
 
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and GuidelinesMulti-cluster Kubernetes Networking- Patterns, Projects and Guidelines
Multi-cluster Kubernetes Networking- Patterns, Projects and Guidelines
 
Bug Bounty Blueprint : A Beginner's Guide
Bug Bounty Blueprint : A Beginner's GuideBug Bounty Blueprint : A Beginner's Guide
Bug Bounty Blueprint : A Beginner's Guide
 
The+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptxThe+Prospects+of+E-Commerce+in+China.pptx
The+Prospects+of+E-Commerce+in+China.pptx
 
The AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdfThe AI Powered Organization-Intro to AI-LAN.pdf
The AI Powered Organization-Intro to AI-LAN.pdf
 

Selenium WebDriver

  • 1. SELENIUM WEBDRIVER Yuriy Bezgachnyuk, SSU/ITA October, 2014
  • 2. Test automation What is Selenium WebDriver Selenium WD Features Document Object Model (DOM)  Locators Example task  PageObject pattern introduction 2 Agenda
  • 3. Test Automation  In software testing, test automation is the use of special software (separate from the software being tested) to control the execution of tests and the comparison of actual outcomes to predicted outcomes. Test automation 3
  • 4. What is Selenium Web Driver Selenium WebDriver – it’s a compact Object-Oriented API for Internet Browsers control WebDriver is the name of the key interface against which tests should be written in Java, Python, Ruby, … What is Selenium Web Driver 4
  • 5. Selenium WD Features Connects to most modern browsers  Allows remote control  Finds elements by selectors  Modifies values of HTML elements  Interacts with DOM elements  Handles modal, popup windows Selenium WD Features 5
  • 6. Document Object Model (DOM) The Document Object Model (DOM) is a cross-platform and language-independent convention for representing and interacting with objects in HTML, XHTML and XML documents. DOM Introduction 6
  • 7. DOM [Locators] Select any HTML element(s) from DOM by using  tags name  attributes of tags • id, name, …  CSS selectors  XPath DOM [Locators] 7
  • 8. Example Task A web-page with a HTML form is given [Fig. 1] User login functionality should be tested  Set value for ‘login’ field  Set value for ‘password’ field  Click submit button  Check results Task 8
  • 9. Explanation of example URL for Login form http://<HOME_URL>/admin/login User inputs correct credentials and is redirected to URL: http://<HOME_URL>/admin otherwise user is redirected back to the login form page Explanation of practical example 9
  • 10. Implementation [Template] JUnit 4 testing framework will be used Template 10 Initial operations Finally operations Our main part of code will be here
  • 11. setUp() method setUp() method provides pre-test WebDriver configuration. setUp() 11 Object for concrete browser Set time for waiting Visit to page specified in URL constant
  • 12. tearDown() method  tearDown() method provides post-test actions (WebDriver object disposal, used resources freeing). Close WebDriver and free resources tearDown() method 12
  • 13. Task implementation Page Object pattern use. Selenium WebDriver use for low-level browser API functions only!!! Definitions of Page Object pattern:  Each single web-page is represented through a Java class  User actions for each web page are implemented as class methods PageObject pattern [Introduction] 13
  • 15. Task Implementation Let investigate our code for test user logon Object for HomePage where login form is Task’s solution 15 placed Object for ResultPage URL from address bar of browser Comparison existing URL address with needed address
  • 16. 16 Class HomePage Method for set values into HTML form and submit data to server
  • 17. Code sample Code investigation 17
  • 18. WebDriver Low level methods findElement(By arg) – searches and returns an object representation of DOM element. Input parameter arg – some of possible selectors (using static methods of By class) sendKeys(CharSequence arg) – sends char sequence to a HTML form element click() – clicks on a DOM element WD Low-level methods 18
  • 19. Windows handling Web applications may have frames or multiple windows, that need to be specifically handled. WebDriver supports moving between named windows with switchTo() method: Windows switching should be used when application has JS modal windows (alerts) driver.switchTo().window("windowName"); Moving between windows and frames 19
  • 20. Windows handling  When we clicking “Вхід” button without supplying credentials an alert modal window appears [Fig.1]  In order to click ‘OK’ button WebDriver should be switched to modal window Moving between windows and frames 20
  • 21. Example #2 [Code]  Let’s take a look at the code Switch to JS alert window and click ‘OK’ button Example #2 [Code] 21