Selenium Training
-
Upload
pragmatic-test-labs -
Category
Technology
-
view
466 -
download
0
description
Transcript of Selenium Training
WEB APPLICATIONS TEST AUTOMATION USING SELENIUM
April 12, 2023 1JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
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
2JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
SELENIUM IDE
Installation
Selenium IDE Features
Understand Timeout
Limitations of Selenium IDE
3JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
INSTALLATION
JANESH KODIKARA- PRAGMATIC TEST LABS 4
April 12, 2023
HELLO SELENIUM
JANESH KODIKARA- PRAGMATIC TEST LABS 5
April 12, 2023
FREQUENTLY USED COMMANDS
JANESH KODIKARA- PRAGMATIC TEST LABS 6
open click / clickAndWait verifyTitle / assertTitle verifyTextPresent verifyElementPresent verifyText verifyTable waitForPageToLoad waitForElementPresent
April 12, 2023
SELENIUM IDE : LOG PANE
Useful for Debugging
Automatically Selected When Tests are Executed
7JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
SELENIUM IDE : REFERENCE PANE
Display Reference of Current Command
Default Pane
8JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
SELENIUM IDE : MENU BAR
Speed Control Run All Tests Run Currently Selected Test Pause/Resume Step Apply Roll-up Rules Recording
9JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
SELENIUM IDE : TEST CASE PANE
Use for Editing Commands
Read Reference Documentation Before Giving Parameters (e.g. Store Command)
10JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
SELENIUM IDE : TEST CASE PANE
Context Menu Stop in the Middle Start from the Middle Run Single Command
11JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
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
12JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
EDITING
Adding New Commands Inset Comments Editing Test Cases Editing Test Suites Table View, Source View
13JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
VARIABLES
14JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
VERIFY PAGE ELEMENTS
Element Present Somewhere in the Page
Specific Text Present in Somewhere in the Page
Specific Text Present at Specific Location
15JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
ASSERT OR VERIFY?
When to use assert commands
When to use verify commands
16JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
FEW USEFUL STORE COMMANDS
store storeElementPresent storeHtmlSource storeEditable storeTitle storeSelectedLabel storeTable
17JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
STORE COMMAND : EXAMPLE
18JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
USE OF VARIABLES IN JAVASCRIPTS
storeEval command
storedVars['counter']=parseInt(storedVars['counter'])+1
Javascript{ ${variableName} + ‘Some Text’ }
Case Sensitivity
19JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
MATCHING TEXT PATTERNS
Globbing Patterns
Regular Expression Patterns
Exact Pattern
20JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
REGULAR EXPRESSIONS
21JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
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>
22JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
LOGS
Setting Log Levels
23JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
SELENIUM COMMANDS
Selense
Actions
Assessors
Assertions
24JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
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
25JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
ACCESSORS
Examine State and Store the Value in Variable
Store Commands
Test Stops if an Accessor has an Error
Hands-on
26JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
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
27JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
TESTING AJAX
Understanding Ajax
WaitFor Commands
Hands-on
28JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
LOCATION STRATEGIES
Locating Elements in a Web Application
Format LocatorType=Location
Supported Strategies
We Can Define Our Own Strategies
29JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
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
30JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
LOCATION STRATEGIES : ID
id=id
Select the element with the specified @id attribute
Hands-on
31JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
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
32JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
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]
33JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
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']
34JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
LOCATION STRATEGIES : LINK
link=textPattern
Select the link (anchor) element which contains text matching the specified pattern
35JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
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)
36JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
USER EXTENSIONS
Helps to Add Additional Functionality
Install a User Extension
Flow Controls
Selenium and PageBot Object Prototype
37JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
USER EXTENSIONS
Writing Your Own Action
Wiring Your Own Assertion
Writing Your Own Location Strategy
38JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
CROSS BROWSER TESTING
Installing RC
Starting RC Server
Running Tests
39JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
CROSS BROWSER TESTING : RC
Java -jar selenium-server.jar
-userExtensions user-extensions.js
-htmlSuite "*firefox“ "http://www.google.com" "c:\absolute\path\to\my\HTMLSuite.html“"c:\absolute\path\to\my\results.html"
40JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
ALERTS
41JANESH KODIKARA- PRAGMATIC TEST LABS
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
April 12, 2023
CONFIRMATIONS
42JANESH KODIKARA- PRAGMATIC TEST LABS
assertConfirmation(Pattern) : Simulates clicking OK
chooseCancelOnNextConfirmation
chooseOkOnNextConfirmation
April 12, 2023
JAVASCRIPTS AND SELENSE PARAMETERS
43JANESH KODIKARA- PRAGMATIC TEST LABS
Script Parameters
April 12, 2023
JAVASCRIPTS AND SELENSE PARAMETERS
44JANESH KODIKARA- PRAGMATIC TEST LABS
Non-Script Parameters
April 12, 2023
DEBUGGING
45JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
ECHO – PRINT COMMAND
46JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
Practice Session
47JANESH KODIKARA- PRAGMATIC TEST LABS
April 12, 2023
SELENIUM PLUGINS
48JANESH KODIKARA- PRAGMATIC TEST LABS
File LoggingHighlight ElementsLog Search BarPage CoveragePower DebuggerScreenshot on FailSelenium ExpertStored Variables ViewerTest ResultsTest Suite Batch Converter
April 12, 2023
Thank You
49JANESH KODIKARA- PRAGMATIC TEST LABS