SlideShare a Scribd company logo
Selenium Automation
■ Part 1
– Why Automated testing?
– Why Selenium?
– History of Selenium
– Selenium IDE
■ Part 2
– Selenium WebDriver
– Setup Development Environment (.net)
– Design Patterns
Selenium Automation
What is Automated testing ?
■ Test automation is the use of special software to control the execution of tests and
the comparison of actual outcomes with predicted outcomes.
Why Automated testing ?
Manual Testing Automated Testing
Manual testing is not accurate at all times due to human error. Automated testing is more reliable, as it is performed by tools.
Manual testing is time-consuming, taking up human resources.
Automated testing is executed by software tools, so it is
significantly faster.
Investment is required for human resources. Investment is required for testing tools.
Manual testing is only practical when frequent repetition is not
required.
Automated testing is a practical option when the test cases are
run repeatedly over a long time period.
Why Selenium ?
■ Selenium,
– is free and open source
– has a large user base and helping communities
– has cross Browser compatibility (Firefox, chrome, Internet Explorer, Safari etc.)
– has great platform compatibility (Windows, Mac OS, Linux etc.)
– supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.)
– supports distributed testing
■ In 2004, at ThoughtWorks, Jason Huggins built the “Selenium Core”
model.
– It is limited by the JavaScript sandbox in browsers.
■ Paul Hammant joined the team and steered the second phase of
selenium development.
– Code with your favorite computer language
■ In 2005, at ThoughtWorks released Selenium RC.
■ In 2007, Huggins joined Google and keep improving the Selenium RC.
■ In 2007, at ThoughtWorks, Simon Stewart developed a superior browser
automation tool called WebDriver.
■ In 2009, they decided to merge two projects and call the new project
Selenium WebDriver.
The name Selenium comes from a joke made by Huggins in an email, mocking
a competitor named Mercury, saying that,
“You can cure mercury poisoning by taking selenium supplements”.
Selenium IDE
Selenium WebDriver
Selenium Grid
Selenium RC
■ Selenium RC comes in two parts.
– Client libraries for your favorite computer
language
■ Java / C# / Python / Ruby / Perl / PHP
– Selenium Server which Interprets and runs
the Selenese commands
■ Automatically launches and kills browsers
■ Acts as a HTTP proxy for web requests
■ Selenium IDE is a Firefox Add-on originally
developed by Shinya Kasatani
■ Selenium IDE was developed to help testers to
record and play back their actions
■ 140 long API commands
■ Install Firefox
■ Go to http://www.seleniumhq.org/download/
■ Install Selenium Add-ons
■ Restart Browser
■ Firebug
■ Firefinder
■ IE Developer Tool
■ Google Chrome Developer Tool
Selenium Automation
■ Selenium 2 Testing Tools Beginner's Guide
– David Burns
Selenium Automation
■ My first record and playback
■ Locators
– Locate elements by ID
– Locate elements by Name
– Locate elements by Link
– Locate elements by Xpath
■ XPath uses path expressions to select nodes or node-sets in an XML document.
– Locate elements by CSS
■ In CSS, selectors are patterns used to select the element(s) you want to style.
– Locate elements by DOM
■ When a web page is loaded, the browser creates a Document Object Model of the page.
■ The HTML DOM model is constructed as a tree of Objects:
■ Add assertion
– Assert vs Verify
■ Add comments
http://book.theautomatedtester.co.uk/
(cont..)
■ Handle Multiple Browser Windows
■ Handle Alerts
■ Working with AJAX
■ Store Variable
■ Debug Testing
■ Create Test Suit
■ Create Test Case
http://book.theautomatedtester.co.uk/
■ Silverlight and Flex/Flash applications
■ HTML5 is not fully supported with Selenium IDE.
– contentEditable=true
■ Create quick bug reproduction scripts
■ Create scripts to aid in automation-aided exploratory testing
■ Selenium RC written purely in JavaScript
■ This JavaScript would automate the browser from within the browser.
■ Selenium RC API has grown over the life of the project to support the changes that
have been happening to web applications (140 API calls)
■ Mobile devices and HTML5 not supported
Selenium Automation
Selenium Automation
Selenium Automation
■ Source tab of Selenium IDE shows selenese commands of recording
– Selenese is a HTML
– http://release.seleniumhq.org/selenium-core/1.0.1/reference.html
■ Selenium RC Proxy is for internal usage
■ Selenium WebDriver control the browser from outside the browser.
■ It controls the browser from the OS level
■ It uses browser’s accessibility API to drive the browser.
– This approach means we can control browsers in the best possible way
– Firefox use JavaScript to access API.
– While Internet Explorer uses C++.
■ But…, new browsers entering the market will not be supported straight away.
■ Visual Studio
■ Install browser specific drivers
– No need for Firefox
– Add driver location to Path variable and
■ IE11 related registry key changes
– https://code.google.com/p/selenium/wiki/InternetExplorerDriver#Required_C
onfiguration
■ Restart the PC
Selenium Automation
Selenium Automation
Selenium Automation
■ Page Object simply models UI areas as objects within the test code.
■ This reduces the amount of duplicated codes.
■ Try and think about the services that they're interacting with rather than the
implementation
■ Methods on the PageObject should return other PageObjects.
■ Test should be responsible for making assertions (not the PageObjects)
public class LoginPage {
public HomePage loginAs(String username, String password) {
// ... clever magic happens here
}
}
public void testMessagesAreReadOrUnread() {
Inbox inbox = new Inbox(driver);
assertTrue(inbox.isMessageWithSubjectIsUnread("I like cheese"));
assertFalse(inbox.isMessageWithSubjectIsUnread("I'm not fond of tofu"));
}
■ In order to support the PageObject pattern, WebDriver's support library contains a
factory class.
public class GoogleSearchPage {
// The element is now looked up using the name attribute
@FindBy(how = How.NAME, using = "q")
private WebElement searchBox;
public void searchFor(String text) {
// We continue using the element just as before
searchBox.sendKeys(text);
searchBox.submit();
}
}
public static void main(String[] args) {
// Create a new instance of a driver
WebDriver driver = new HtmlUnitDriver();
// Navigate to the right place
driver.get("http://www.google.com/");
// Create a new instance of the search page class
// and initialise any WebElement fields in it.
GoogleSearchPage page = PageFactory.initElements(driver, GoogleSearchPage.class);
// And now do the search.
page.searchFor("Cheese");
}
Selenium Automation
Selenium Automation
Selenium Automation

More Related Content

PPTX
Introduction to selenium
PDF
Web automation using selenium.ppt
PPT
Automation With A Tool Demo
PPTX
PPTX
Test Automation and Selenium
PPTX
Automation - web testing with selenium
PPT
Selenium Presentation at Engineering Colleges
PPT
Selenium ppt
Introduction to selenium
Web automation using selenium.ppt
Automation With A Tool Demo
Test Automation and Selenium
Automation - web testing with selenium
Selenium Presentation at Engineering Colleges
Selenium ppt

What's hot (20)

PPTX
Introduction to Selenium Web Driver
PPT
QSpiders - Automation using Selenium
PDF
Automation Testing using Selenium
PPTX
Test automation using selenium
PPTX
Selenium with java
PPT
Selenium ppt
PPT
Selenium Concepts
PPTX
Data driven Automation Framework with Selenium
PPT
Selenium
PPTX
Automation Testing by Selenium Web Driver
PPTX
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
KEY
Selenium Grid
PPTX
Jenkins CI
PPTX
Selenium introduction
PDF
Selenium Maven With Eclipse | Edureka
PPTX
Selenium ppt
PPTX
Selenium WebDriver
PDF
Selenium IDE LOCATORS
PPTX
Automated Test Framework with Cucumber
PPSX
Selenium WebDriver
Introduction to Selenium Web Driver
QSpiders - Automation using Selenium
Automation Testing using Selenium
Test automation using selenium
Selenium with java
Selenium ppt
Selenium Concepts
Data driven Automation Framework with Selenium
Selenium
Automation Testing by Selenium Web Driver
Selenium Tutorial For Beginners | Selenium Automation Testing Tutorial | Sele...
Selenium Grid
Jenkins CI
Selenium introduction
Selenium Maven With Eclipse | Edureka
Selenium ppt
Selenium WebDriver
Selenium IDE LOCATORS
Automated Test Framework with Cucumber
Selenium WebDriver
Ad

Viewers also liked (16)

PPTX
JAVA User Group Bern - Selenium
PDF
Automated Testing with Selenium
PDF
Meet the Selenium Grid
ODP
Mastering selenium for automated acceptance tests
PPTX
Design patterns in web testing automation with WebDriver
PDF
Selenium - The page object pattern
PDF
Perils of Page-Object Pattern
PPTX
Basic Selenium Training
PDF
Using The Page Object Pattern
PPT
Selenium Architecture
PPT
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
PPTX
How to Design a Successful Test Automation Strategy
PDF
Test Automation Framework Design | www.idexcel.com
PDF
Selenium Basics Tutorial
PDF
Agile Testing Framework - The Art of Automated Testing
PDF
Test Automation - Principles and Practices
JAVA User Group Bern - Selenium
Automated Testing with Selenium
Meet the Selenium Grid
Mastering selenium for automated acceptance tests
Design patterns in web testing automation with WebDriver
Selenium - The page object pattern
Perils of Page-Object Pattern
Basic Selenium Training
Using The Page Object Pattern
Selenium Architecture
Understanding Selenium/RC, Webdriver Architecture and developing the page obj...
How to Design a Successful Test Automation Strategy
Test Automation Framework Design | www.idexcel.com
Selenium Basics Tutorial
Agile Testing Framework - The Art of Automated Testing
Test Automation - Principles and Practices
Ad

Similar to Selenium Automation (20)

PPT
Selenium for everyone
PDF
Automation Testing using Selenium Webdriver
PDF
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
PPT
Selenium testing - Handle Elements in WebDriver
PPTX
Automated ui-testing
PPT
Selenium
PDF
orcreatehappyusers
PDF
orcreatehappyusers
PPTX
Automated Web Testing With Selenium
PPTX
Selenium Automation
PPTX
Selenium.pptx
PPTX
Presentation on Introduction to Selenium
PPTX
Basics of selenium containing features of selenium
PDF
Microsoft power point automation-opensourcetestingtools_matrix-1
PDF
Microsoft power point automation-opensourcetestingtools_matrix-1
PPTX
Selenium training
PDF
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
PPTX
Selenium- A Software Testing Tool
PPTX
Selenium Basics and Overview topics.pptx
PPTX
Selenium Basics and Overview1233444.pptx
Selenium for everyone
Automation Testing using Selenium Webdriver
Mastering Selenium WebDriver: A Comprehensive Tutorial with Real-World Examples
Selenium testing - Handle Elements in WebDriver
Automated ui-testing
Selenium
orcreatehappyusers
orcreatehappyusers
Automated Web Testing With Selenium
Selenium Automation
Selenium.pptx
Presentation on Introduction to Selenium
Basics of selenium containing features of selenium
Microsoft power point automation-opensourcetestingtools_matrix-1
Microsoft power point automation-opensourcetestingtools_matrix-1
Selenium training
Selenium & PHPUnit made easy with Steward (Berlin, April 2017)
Selenium- A Software Testing Tool
Selenium Basics and Overview topics.pptx
Selenium Basics and Overview1233444.pptx

Recently uploaded (20)

PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPTX
Cloud computing and distributed systems.
PPTX
Big Data Technologies - Introduction.pptx
PPTX
Spectroscopy.pptx food analysis technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Machine learning based COVID-19 study performance prediction
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Encapsulation theory and applications.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
cuic standard and advanced reporting.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Cloud computing and distributed systems.
Big Data Technologies - Introduction.pptx
Spectroscopy.pptx food analysis technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
Review of recent advances in non-invasive hemoglobin estimation
Encapsulation_ Review paper, used for researhc scholars
Digital-Transformation-Roadmap-for-Companies.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Machine learning based COVID-19 study performance prediction
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Spectral efficient network and resource selection model in 5G networks
Encapsulation theory and applications.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Dropbox Q2 2025 Financial Results & Investor Presentation
Chapter 3 Spatial Domain Image Processing.pdf
cuic standard and advanced reporting.pdf

Selenium Automation

  • 2. ■ Part 1 – Why Automated testing? – Why Selenium? – History of Selenium – Selenium IDE ■ Part 2 – Selenium WebDriver – Setup Development Environment (.net) – Design Patterns
  • 4. What is Automated testing ? ■ Test automation is the use of special software to control the execution of tests and the comparison of actual outcomes with predicted outcomes.
  • 5. Why Automated testing ? Manual Testing Automated Testing Manual testing is not accurate at all times due to human error. Automated testing is more reliable, as it is performed by tools. Manual testing is time-consuming, taking up human resources. Automated testing is executed by software tools, so it is significantly faster. Investment is required for human resources. Investment is required for testing tools. Manual testing is only practical when frequent repetition is not required. Automated testing is a practical option when the test cases are run repeatedly over a long time period.
  • 6. Why Selenium ? ■ Selenium, – is free and open source – has a large user base and helping communities – has cross Browser compatibility (Firefox, chrome, Internet Explorer, Safari etc.) – has great platform compatibility (Windows, Mac OS, Linux etc.) – supports multiple programming languages (Java, C#, Ruby, Python, Pearl etc.) – supports distributed testing
  • 7. ■ In 2004, at ThoughtWorks, Jason Huggins built the “Selenium Core” model. – It is limited by the JavaScript sandbox in browsers. ■ Paul Hammant joined the team and steered the second phase of selenium development. – Code with your favorite computer language ■ In 2005, at ThoughtWorks released Selenium RC. ■ In 2007, Huggins joined Google and keep improving the Selenium RC. ■ In 2007, at ThoughtWorks, Simon Stewart developed a superior browser automation tool called WebDriver. ■ In 2009, they decided to merge two projects and call the new project Selenium WebDriver.
  • 8. The name Selenium comes from a joke made by Huggins in an email, mocking a competitor named Mercury, saying that, “You can cure mercury poisoning by taking selenium supplements”.
  • 10. ■ Selenium RC comes in two parts. – Client libraries for your favorite computer language ■ Java / C# / Python / Ruby / Perl / PHP – Selenium Server which Interprets and runs the Selenese commands ■ Automatically launches and kills browsers ■ Acts as a HTTP proxy for web requests
  • 11. ■ Selenium IDE is a Firefox Add-on originally developed by Shinya Kasatani ■ Selenium IDE was developed to help testers to record and play back their actions ■ 140 long API commands
  • 12. ■ Install Firefox ■ Go to http://www.seleniumhq.org/download/ ■ Install Selenium Add-ons ■ Restart Browser
  • 13. ■ Firebug ■ Firefinder ■ IE Developer Tool ■ Google Chrome Developer Tool
  • 15. ■ Selenium 2 Testing Tools Beginner's Guide – David Burns
  • 17. ■ My first record and playback ■ Locators – Locate elements by ID – Locate elements by Name – Locate elements by Link – Locate elements by Xpath ■ XPath uses path expressions to select nodes or node-sets in an XML document. – Locate elements by CSS ■ In CSS, selectors are patterns used to select the element(s) you want to style. – Locate elements by DOM ■ When a web page is loaded, the browser creates a Document Object Model of the page. ■ The HTML DOM model is constructed as a tree of Objects: ■ Add assertion – Assert vs Verify ■ Add comments http://book.theautomatedtester.co.uk/
  • 18. (cont..) ■ Handle Multiple Browser Windows ■ Handle Alerts ■ Working with AJAX ■ Store Variable ■ Debug Testing ■ Create Test Suit ■ Create Test Case http://book.theautomatedtester.co.uk/
  • 19. ■ Silverlight and Flex/Flash applications ■ HTML5 is not fully supported with Selenium IDE. – contentEditable=true
  • 20. ■ Create quick bug reproduction scripts ■ Create scripts to aid in automation-aided exploratory testing
  • 21. ■ Selenium RC written purely in JavaScript ■ This JavaScript would automate the browser from within the browser. ■ Selenium RC API has grown over the life of the project to support the changes that have been happening to web applications (140 API calls) ■ Mobile devices and HTML5 not supported
  • 25. ■ Source tab of Selenium IDE shows selenese commands of recording – Selenese is a HTML – http://release.seleniumhq.org/selenium-core/1.0.1/reference.html ■ Selenium RC Proxy is for internal usage
  • 26. ■ Selenium WebDriver control the browser from outside the browser. ■ It controls the browser from the OS level ■ It uses browser’s accessibility API to drive the browser. – This approach means we can control browsers in the best possible way – Firefox use JavaScript to access API. – While Internet Explorer uses C++. ■ But…, new browsers entering the market will not be supported straight away.
  • 27. ■ Visual Studio ■ Install browser specific drivers – No need for Firefox – Add driver location to Path variable and ■ IE11 related registry key changes – https://code.google.com/p/selenium/wiki/InternetExplorerDriver#Required_C onfiguration ■ Restart the PC
  • 31. ■ Page Object simply models UI areas as objects within the test code. ■ This reduces the amount of duplicated codes. ■ Try and think about the services that they're interacting with rather than the implementation ■ Methods on the PageObject should return other PageObjects. ■ Test should be responsible for making assertions (not the PageObjects) public class LoginPage { public HomePage loginAs(String username, String password) { // ... clever magic happens here } } public void testMessagesAreReadOrUnread() { Inbox inbox = new Inbox(driver); assertTrue(inbox.isMessageWithSubjectIsUnread("I like cheese")); assertFalse(inbox.isMessageWithSubjectIsUnread("I'm not fond of tofu")); }
  • 32. ■ In order to support the PageObject pattern, WebDriver's support library contains a factory class. public class GoogleSearchPage { // The element is now looked up using the name attribute @FindBy(how = How.NAME, using = "q") private WebElement searchBox; public void searchFor(String text) { // We continue using the element just as before searchBox.sendKeys(text); searchBox.submit(); } } public static void main(String[] args) { // Create a new instance of a driver WebDriver driver = new HtmlUnitDriver(); // Navigate to the right place driver.get("http://www.google.com/"); // Create a new instance of the search page class // and initialise any WebElement fields in it. GoogleSearchPage page = PageFactory.initElements(driver, GoogleSearchPage.class); // And now do the search. page.searchFor("Cheese"); }