SlideShare a Scribd company logo
1 of 49
WEB APPLICATIONS TEST AUTOMATION
                USING SELENIUM




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   1
AGENDA
      Selenium IDE
      Test Cases and Test Suites
      Selenium Commands
      Regular Expression
      Ajax Applications
      User Extensions and Flow Controls
      Cross Browser Testing
      Location Strategies
      Alerts, Popups and Multiple Windows


JANESH KODIKARA- PRAGMATIC TEST LABS         11 November 2012   2
SELENIUM IDE

  Installation

  Selenium IDE Features

  Understand Timeout

  Limitations of Selenium IDE



JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   3
JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   ‹#›
HELLO SELENIUM




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   5
FREQUENTLY USED COMMANDS

  open
  click / clickAndWait
  verifyTitle / assertTitle
  verifyTextPresent
  verifyElementPresent
  verifyText
  verifyTable
  waitForPageToLoad
  waitForElementPresent

JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   6
SELENIUM IDE : LOG PANE

  Useful for Debugging

  Automatically Selected When Tests are Executed




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   7
SELENIUM IDE : REFERENCE PANE

  Display Reference of Current Command

  Default Pane




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   8
SELENIUM IDE : MENU BAR



  Speed Control
  Run All Tests
  Run Currently Selected Test
  Pause/Resume
  Step
  Apply Roll-up Rules
  Recording

JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   9
SELENIUM IDE : TEST CASE PANE

  Use for Editing Commands

  Read Reference Documentation Before Giving
     Parameters (e.g. Store Command)




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   10
SELENIUM IDE : TEST CASE PANE
  Context Menu
  Stop in the Middle
  Start from the Middle
  Run Single Command




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   11
TEST CASES AND TEST SUITES

      Create Test Cases
      Create Test Suites
      Naming Conventions
      Test Project Packaging and Best Practices
      Modifying Test Cases and Test Suites
      User of Variables in Test Cases
      Creating and Using Random Variables



JANESH KODIKARA- PRAGMATIC TEST LABS       11 November 2012   12
EDITING

      Adding New Commands
      Inset Comments
      Editing Test Cases
      Editing Test Suites
      Table View, Source View




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   13
VARIABLES




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   14
VERIFY PAGE ELEMENTS

  Element Present Somewhere in the Page


  Specific Text Present in Somewhere in the Page


  Specific Text Present at Specific Location



JANESH KODIKARA- PRAGMATIC TEST LABS     11 November 2012   15
ASSERT OR VERIFY?

  When to use assert commands


  When to use verify commands




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   16
FEW USEFUL STORE COMMANDS

      store
      storeElementPresent
      storeHtmlSource
      storeEditable
      storeTitle
      storeSelectedLabel
      storeTable



JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   17
STORE COMMAND : EXAMPLE




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   18
USE OF VARIABLES IN JAVASCRIPTS

 storeEval command

 storedVars['counter']=parseInt(storedVars['counter'])+1

 Javascript{ ${variableName} + ‘Some Text’ }

 Case Sensitivity



JANESH KODIKARA- PRAGMATIC TEST LABS       11 November 2012   19
MATCHING TEXT PATTERNS

 Globbing Patterns


 Regular Expression Patterns



 Exact Pattern


JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   20
REGULAR EXPRESSIONS




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   21
REGULAR EXPRESSION
 <tr>
              <td>verifyTitle</td>
              <td>regexp:.*Simplicity into Software Testing</td>
              <td></td>
 </tr>
 <tr>
              <td>verifyTitle</td>
              <td>regexpi:.*simplicity into software testing</td>
              <td></td>
 </tr>

JANESH KODIKARA- PRAGMATIC TEST LABS             11 November 2012   22
LOGS

  Setting Log Levels




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   23
SELENIUM COMMANDS

  Selense

  Actions

  Assessors

  Assertions



JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   24
ACTIONS

  Commands that Manipulate the State

  Click this link, Select that Option

  Test Stops if Actions Fail or has an Error

  Commands with ‘AndWait’ Suffix

  Hands-on

JANESH KODIKARA- PRAGMATIC TEST LABS      11 November 2012   25
ACCESSORS

  Examine State and Store the Value in Variable

  Store Commands

  Test Stops if an Accessor has an Error

  Hands-on



JANESH KODIKARA- PRAGMATIC TEST LABS    11 November 2012   26
ASSERTIONS

  Like Accessors

  Verify and Confirm the State

  Asserts, Verify and WaitFor

  When Assert Fails Test is Aborted

  When Verify Fails Test Continue, Failure is Logged

JANESH KODIKARA- PRAGMATIC TEST LABS    11 November 2012   27
TESTING AJAX

  Understanding Ajax

  WaitFor Commands

  Hands-on




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   28
LOCATION STRATEGIES

  Locating Elements in a Web Application

  Format LocatorType=Location

  Supported Strategies

  We Can Define Our Own Strategies



JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   29
LOCATION STRATEGIES : IDENTIFIER

  Default Strategy
  identifier=id

  Select the element with the specified @id attribute

  If no match is found,
   select the first element whose @name attribute is
   id


JANESH KODIKARA- PRAGMATIC TEST LABS     11 November 2012   30
LOCATION STRATEGIES : ID

  id=id

  Select the element with the specified @id attribute

  Hands-on




JANESH KODIKARA- PRAGMATIC TEST LABS     11 November 2012   31
LOCATION STRATEGIES : NAME

  name=name

  Select the first element with the specified @name attribute

  Optionally be Followed by One or More Element-filters

  Default Filter is Value

  name=company value=Allion

JANESH KODIKARA- PRAGMATIC TEST LABS     11 November 2012   32
LOCATION STRATEGIES : DOM

  dom=javascriptExpression

  Find an element by evaluating the specified string

  Traverse HTML Document Object Model using JavaScript

  dom=document.forms['myForm'].myDropdown

  dom=document.images[56]

JANESH KODIKARA- PRAGMATIC TEST LABS      11 November 2012   33
LOCATION STRATEGIES : XPATH

  xpath=xpathExpression

  Locate an element using an XPath expression.

  xpath=//img[@alt='The image alt text']

  xpath=//a[contains(@href,'#id1')]

  xpath=//input[@name='name2' and @value='yes']

JANESH KODIKARA- PRAGMATIC TEST LABS        11 November 2012   34
LOCATION STRATEGIES : LINK

  link=textPattern

  Select the link (anchor) element which contains text
       matching the specified pattern




JANESH KODIKARA- PRAGMATIC TEST LABS      11 November 2012   35
LOCATION STRATEGIES : CSS

  css=cssSelectorSyntax

  Select the element using css selectors

  css=input[name="username"]

  css=input.required[type="text"]

  css=#loginForm input:nth-child(2)

JANESH KODIKARA- PRAGMATIC TEST LABS    11 November 2012   36
USER EXTENSIONS

  Helps to Add Additional Functionality

  Install a User Extension

  Flow Controls

  Selenium and PageBot Object Prototype



JANESH KODIKARA- PRAGMATIC TEST LABS       11 November 2012   37
USER EXTENSIONS

  Writing Your Own Action

  Wiring Your Own Assertion

  Writing Your Own Location Strategy




JANESH KODIKARA- PRAGMATIC TEST LABS    11 November 2012   38
CROSS BROWSER TESTING

  Installing RC

  Starting RC Server

  Running Tests




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   39
CROSS BROWSER TESTING : RC

 Java -jar selenium-server.jar

 -userExtensions user-extensions.js

 -htmlSuite "*firefox“ "http://www.google.com"
 "c:absolutepathtomyHTMLSuite.html“
 "c:absolutepathtomyresults.html"



JANESH KODIKARA- PRAGMATIC TEST LABS     11 November 2012   40
ALERTS

assertAlert(Pattern) : Throws error if pattern does not match

assertAlertPresent : Useful when we don’t know the message

assertAlertNotPresent : Throws error if alert is present

storeAlert(variable) : Stores the message to a variable



 JANESH KODIKARA- PRAGMATIC TEST LABS        11 November 2012   41
CONFIRMATIONS

assertConfirmation(Pattern) : Simulates clicking OK

chooseCancelOnNextConfirmation

chooseOkOnNextConfirmation




 JANESH KODIKARA- PRAGMATIC TEST LABS     11 November 2012   42
JAVASCRIPTS AND SELENSE PARAMETERS

Script Parameters




  JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   43
JAVASCRIPTS AND SELENSE PARAMETERS

Non-Script Parameters




  JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   44
DEBUGGING




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   45
ECHO – PRINT COMMAND




JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   46
JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   47
SELENIUM PLUGINS
File Logging
Highlight Elements
Log Search Bar
Page Coverage
Power Debugger
Screenshot on Fail
Selenium Expert
Stored Variables Viewer
Test Results
Test Suite Batch Converter

 JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   48
JANESH KODIKARA- PRAGMATIC TEST LABS   11 November 2012   49

More Related Content

What's hot

Final Automation Testing
Final Automation TestingFinal Automation Testing
Final Automation Testing
priya_trivedi
 
Automated integration tests for ajax applications (с. карпушин, auriga)
Automated integration tests for ajax applications (с. карпушин, auriga)Automated integration tests for ajax applications (с. карпушин, auriga)
Automated integration tests for ajax applications (с. карпушин, auriga)
Mobile Developer Day
 
Expert Quick Tour
Expert Quick TourExpert Quick Tour
Expert Quick Tour
Active Base
 

What's hot (11)

TDD
TDDTDD
TDD
 
Unit testing - A&BP CC
Unit testing - A&BP CCUnit testing - A&BP CC
Unit testing - A&BP CC
 
Final Automation Testing
Final Automation TestingFinal Automation Testing
Final Automation Testing
 
Model-based Testing: Taking BDD/ATDD to the Next Level
Model-based Testing: Taking BDD/ATDD to the Next LevelModel-based Testing: Taking BDD/ATDD to the Next Level
Model-based Testing: Taking BDD/ATDD to the Next Level
 
Automated integration tests for ajax applications (с. карпушин, auriga)
Automated integration tests for ajax applications (с. карпушин, auriga)Automated integration tests for ajax applications (с. карпушин, auriga)
Automated integration tests for ajax applications (с. карпушин, auriga)
 
SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011SoftTest Ireland: Model Based Testing - January 27th 2011
SoftTest Ireland: Model Based Testing - January 27th 2011
 
How Spotify Does Test Automation - Kristian Karl
How Spotify Does Test Automation - Kristian KarlHow Spotify Does Test Automation - Kristian Karl
How Spotify Does Test Automation - Kristian Karl
 
Expert Quick Tour
Expert Quick TourExpert Quick Tour
Expert Quick Tour
 
Improving The Quality of Existing Software
Improving The Quality of Existing SoftwareImproving The Quality of Existing Software
Improving The Quality of Existing Software
 
Integration testing - A&BP CC
Integration testing - A&BP CCIntegration testing - A&BP CC
Integration testing - A&BP CC
 
dbadapters
dbadaptersdbadapters
dbadapters
 

Viewers also liked (13)

Selenium
SeleniumSelenium
Selenium
 
Sakai10 Selenium Workshop
Sakai10 Selenium WorkshopSakai10 Selenium Workshop
Sakai10 Selenium Workshop
 
Selenium IDE and Extensions
Selenium IDE and ExtensionsSelenium IDE and Extensions
Selenium IDE and Extensions
 
Steps to write Selenium
Steps to write Selenium  Steps to write Selenium
Steps to write Selenium
 
Automated User Tests with Apache Flex
Automated User Tests with Apache FlexAutomated User Tests with Apache Flex
Automated User Tests with Apache Flex
 
Selenium IDE and Beyond
Selenium IDE and BeyondSelenium IDE and Beyond
Selenium IDE and Beyond
 
Efficient Automated Test Creation With Selenium IDE Plugins
Efficient Automated Test Creation With Selenium IDE PluginsEfficient Automated Test Creation With Selenium IDE Plugins
Efficient Automated Test Creation With Selenium IDE Plugins
 
Selenium Ide Tutorials
Selenium Ide TutorialsSelenium Ide Tutorials
Selenium Ide Tutorials
 
Selenium
SeleniumSelenium
Selenium
 
Selenium WebDriver FAQ's
Selenium WebDriver FAQ'sSelenium WebDriver FAQ's
Selenium WebDriver FAQ's
 
Jmeter Performance Testing
Jmeter Performance TestingJmeter Performance Testing
Jmeter Performance Testing
 
Java Basics for selenium
Java Basics for seleniumJava Basics for selenium
Java Basics for selenium
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 

Similar to Selenium Training

TripCase Unit Testing with Jasmine
TripCase Unit Testing with JasmineTripCase Unit Testing with Jasmine
TripCase Unit Testing with Jasmine
Stephen Pond
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
Troy Miles
 
Creating master and work repository
Creating master and work repositoryCreating master and work repository
Creating master and work repository
Ravi Kumar Lanke
 
Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)
Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)
Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)
enpit GmbH & Co. KG
 
Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)
Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)
Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)
Andreas Koop
 

Similar to Selenium Training (20)

TripCase Unit Testing with Jasmine
TripCase Unit Testing with JasmineTripCase Unit Testing with Jasmine
TripCase Unit Testing with Jasmine
 
AD208 - End to End Quality Processes for Top Notch XPages Apps
AD208 - End to End Quality Processes for Top Notch XPages AppsAD208 - End to End Quality Processes for Top Notch XPages Apps
AD208 - End to End Quality Processes for Top Notch XPages Apps
 
Beginning AngularJS
Beginning AngularJSBeginning AngularJS
Beginning AngularJS
 
AngularJS Beginner Day One
AngularJS Beginner Day OneAngularJS Beginner Day One
AngularJS Beginner Day One
 
TDD in Javascript
TDD in JavascriptTDD in Javascript
TDD in Javascript
 
Creating master and work repository
Creating master and work repositoryCreating master and work repository
Creating master and work repository
 
Test Automation for NoSQL Databases
Test Automation for NoSQL DatabasesTest Automation for NoSQL Databases
Test Automation for NoSQL Databases
 
Codeception
CodeceptionCodeception
Codeception
 
Load Testing: See a Bigger Picture
Load Testing: See a Bigger PictureLoad Testing: See a Bigger Picture
Load Testing: See a Bigger Picture
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)
Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)
Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)
 
Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)
Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)
Deployment Best Practices on WebLogic Server (DOAG IMC Summit 2013)
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
 
Unit testing hippo
Unit testing hippoUnit testing hippo
Unit testing hippo
 
Building a Cerberus App Without Losing Our Heads: The Passage to a Cross-Plat...
Building a Cerberus App Without Losing Our Heads: The Passage to a Cross-Plat...Building a Cerberus App Without Losing Our Heads: The Passage to a Cross-Plat...
Building a Cerberus App Without Losing Our Heads: The Passage to a Cross-Plat...
 
Sightly_techInsight
Sightly_techInsightSightly_techInsight
Sightly_techInsight
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
 
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power ToolsJavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
JavaOne 2017 CON2902 - Java Code Inspection and Testing Power Tools
 
jp06_bossola
jp06_bossolajp06_bossola
jp06_bossola
 
B13 Investigating oracle by Julian Dyke
B13 Investigating oracle by Julian DykeB13 Investigating oracle by Julian Dyke
B13 Investigating oracle by Julian Dyke
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 

Selenium Training

  • 1. WEB APPLICATIONS TEST AUTOMATION USING SELENIUM JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 1
  • 2. AGENDA  Selenium IDE  Test Cases and Test Suites  Selenium Commands  Regular Expression  Ajax Applications  User Extensions and Flow Controls  Cross Browser Testing  Location Strategies  Alerts, Popups and Multiple Windows JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 2
  • 3. SELENIUM IDE  Installation  Selenium IDE Features  Understand Timeout  Limitations of Selenium IDE JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 3
  • 4. JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 ‹#›
  • 5. HELLO SELENIUM JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 5
  • 6. FREQUENTLY USED COMMANDS  open  click / clickAndWait  verifyTitle / assertTitle  verifyTextPresent  verifyElementPresent  verifyText  verifyTable  waitForPageToLoad  waitForElementPresent JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 6
  • 7. SELENIUM IDE : LOG PANE  Useful for Debugging  Automatically Selected When Tests are Executed JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 7
  • 8. SELENIUM IDE : REFERENCE PANE  Display Reference of Current Command  Default Pane JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 8
  • 9. SELENIUM IDE : MENU BAR  Speed Control  Run All Tests  Run Currently Selected Test  Pause/Resume  Step  Apply Roll-up Rules  Recording JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 9
  • 10. SELENIUM IDE : TEST CASE PANE  Use for Editing Commands  Read Reference Documentation Before Giving Parameters (e.g. Store Command) JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 10
  • 11. SELENIUM IDE : TEST CASE PANE  Context Menu  Stop in the Middle  Start from the Middle  Run Single Command JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 11
  • 12. TEST CASES AND TEST SUITES  Create Test Cases  Create Test Suites  Naming Conventions  Test Project Packaging and Best Practices  Modifying Test Cases and Test Suites  User of Variables in Test Cases  Creating and Using Random Variables JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 12
  • 13. EDITING  Adding New Commands  Inset Comments  Editing Test Cases  Editing Test Suites  Table View, Source View JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 13
  • 14. VARIABLES JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 14
  • 15. VERIFY PAGE ELEMENTS  Element Present Somewhere in the Page  Specific Text Present in Somewhere in the Page  Specific Text Present at Specific Location JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 15
  • 16. ASSERT OR VERIFY?  When to use assert commands  When to use verify commands JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 16
  • 17. FEW USEFUL STORE COMMANDS  store  storeElementPresent  storeHtmlSource  storeEditable  storeTitle  storeSelectedLabel  storeTable JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 17
  • 18. STORE COMMAND : EXAMPLE JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 18
  • 19. USE OF VARIABLES IN JAVASCRIPTS storeEval command storedVars['counter']=parseInt(storedVars['counter'])+1 Javascript{ ${variableName} + ‘Some Text’ } Case Sensitivity JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 19
  • 20. MATCHING TEXT PATTERNS Globbing Patterns Regular Expression Patterns Exact Pattern JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 20
  • 21. REGULAR EXPRESSIONS JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 21
  • 22. REGULAR EXPRESSION <tr> <td>verifyTitle</td> <td>regexp:.*Simplicity into Software Testing</td> <td></td> </tr> <tr> <td>verifyTitle</td> <td>regexpi:.*simplicity into software testing</td> <td></td> </tr> JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 22
  • 23. LOGS  Setting Log Levels JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 23
  • 24. SELENIUM COMMANDS  Selense  Actions  Assessors  Assertions JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 24
  • 25. ACTIONS  Commands that Manipulate the State  Click this link, Select that Option  Test Stops if Actions Fail or has an Error  Commands with ‘AndWait’ Suffix  Hands-on JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 25
  • 26. ACCESSORS  Examine State and Store the Value in Variable  Store Commands  Test Stops if an Accessor has an Error  Hands-on JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 26
  • 27. ASSERTIONS  Like Accessors  Verify and Confirm the State  Asserts, Verify and WaitFor  When Assert Fails Test is Aborted  When Verify Fails Test Continue, Failure is Logged JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 27
  • 28. TESTING AJAX  Understanding Ajax  WaitFor Commands  Hands-on JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 28
  • 29. LOCATION STRATEGIES  Locating Elements in a Web Application  Format LocatorType=Location  Supported Strategies  We Can Define Our Own Strategies JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 29
  • 30. LOCATION STRATEGIES : IDENTIFIER  Default Strategy  identifier=id  Select the element with the specified @id attribute  If no match is found, select the first element whose @name attribute is id JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 30
  • 31. LOCATION STRATEGIES : ID  id=id  Select the element with the specified @id attribute  Hands-on JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 31
  • 32. LOCATION STRATEGIES : NAME  name=name  Select the first element with the specified @name attribute  Optionally be Followed by One or More Element-filters  Default Filter is Value  name=company value=Allion JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 32
  • 33. LOCATION STRATEGIES : DOM  dom=javascriptExpression  Find an element by evaluating the specified string  Traverse HTML Document Object Model using JavaScript  dom=document.forms['myForm'].myDropdown  dom=document.images[56] JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 33
  • 34. LOCATION STRATEGIES : XPATH  xpath=xpathExpression  Locate an element using an XPath expression.  xpath=//img[@alt='The image alt text']  xpath=//a[contains(@href,'#id1')]  xpath=//input[@name='name2' and @value='yes'] JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 34
  • 35. LOCATION STRATEGIES : LINK  link=textPattern  Select the link (anchor) element which contains text matching the specified pattern JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 35
  • 36. LOCATION STRATEGIES : CSS  css=cssSelectorSyntax  Select the element using css selectors  css=input[name="username"]  css=input.required[type="text"]  css=#loginForm input:nth-child(2) JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 36
  • 37. USER EXTENSIONS  Helps to Add Additional Functionality  Install a User Extension  Flow Controls  Selenium and PageBot Object Prototype JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 37
  • 38. USER EXTENSIONS  Writing Your Own Action  Wiring Your Own Assertion  Writing Your Own Location Strategy JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 38
  • 39. CROSS BROWSER TESTING  Installing RC  Starting RC Server  Running Tests JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 39
  • 40. CROSS BROWSER TESTING : RC Java -jar selenium-server.jar -userExtensions user-extensions.js -htmlSuite "*firefox“ "http://www.google.com" "c:absolutepathtomyHTMLSuite.html“ "c:absolutepathtomyresults.html" JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 40
  • 41. ALERTS assertAlert(Pattern) : Throws error if pattern does not match assertAlertPresent : Useful when we don’t know the message assertAlertNotPresent : Throws error if alert is present storeAlert(variable) : Stores the message to a variable JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 41
  • 42. CONFIRMATIONS assertConfirmation(Pattern) : Simulates clicking OK chooseCancelOnNextConfirmation chooseOkOnNextConfirmation JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 42
  • 43. JAVASCRIPTS AND SELENSE PARAMETERS Script Parameters JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 43
  • 44. JAVASCRIPTS AND SELENSE PARAMETERS Non-Script Parameters JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 44
  • 45. DEBUGGING JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 45
  • 46. ECHO – PRINT COMMAND JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 46
  • 47. JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 47
  • 48. SELENIUM PLUGINS File Logging Highlight Elements Log Search Bar Page Coverage Power Debugger Screenshot on Fail Selenium Expert Stored Variables Viewer Test Results Test Suite Batch Converter JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 48
  • 49. JANESH KODIKARA- PRAGMATIC TEST LABS 11 November 2012 49