selenium training

49
WEB APPLICATIONS TEST AUTOMATION USING SELENIUM Thursday, Novemb er 3, 2022 1 JANESH KODIKARA- PRAGMATIC TEST LABS

Upload: pragmatic-test-labs

Post on 20-May-2015

468 views

Category:

Technology


0 download

DESCRIPTION

Pragmatic Test Labs provide online training for software testers who wants to learn

TRANSCRIPT

Page 1: Selenium Training

WEB APPLICATIONS TEST AUTOMATION USING SELENIUM

April 12, 2023 1JANESH KODIKARA- PRAGMATIC TEST LABS

Page 2: Selenium Training

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

Page 3: Selenium Training

April 12, 2023

SELENIUM IDE

Installation

Selenium IDE Features

Understand Timeout

Limitations of Selenium IDE

3JANESH KODIKARA- PRAGMATIC TEST LABS

Page 4: Selenium Training

April 12, 2023

INSTALLATION

JANESH KODIKARA- PRAGMATIC TEST LABS 4

Page 5: Selenium Training

April 12, 2023

HELLO SELENIUM

JANESH KODIKARA- PRAGMATIC TEST LABS 5

Page 6: Selenium Training

April 12, 2023

FREQUENTLY USED COMMANDS

JANESH KODIKARA- PRAGMATIC TEST LABS 6

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

Page 7: Selenium Training

April 12, 2023

SELENIUM IDE : LOG PANE

Useful for Debugging

Automatically Selected When Tests are Executed

7JANESH KODIKARA- PRAGMATIC TEST LABS

Page 8: Selenium Training

April 12, 2023

SELENIUM IDE : REFERENCE PANE

Display Reference of Current Command

Default Pane

8JANESH KODIKARA- PRAGMATIC TEST LABS

Page 9: Selenium Training

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

Page 10: Selenium Training

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

Page 11: Selenium Training

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

Page 12: Selenium Training

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

Page 13: Selenium Training

April 12, 2023

EDITING

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

13JANESH KODIKARA- PRAGMATIC TEST LABS

Page 14: Selenium Training

April 12, 2023

VARIABLES

14JANESH KODIKARA- PRAGMATIC TEST LABS

Page 15: Selenium Training

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

Page 16: Selenium Training

April 12, 2023

ASSERT OR VERIFY?

When to use assert commands

When to use verify commands

16JANESH KODIKARA- PRAGMATIC TEST LABS

Page 17: Selenium Training

April 12, 2023

FEW USEFUL STORE COMMANDS

store storeElementPresent storeHtmlSource storeEditable storeTitle storeSelectedLabel storeTable

17JANESH KODIKARA- PRAGMATIC TEST LABS

Page 18: Selenium Training

April 12, 2023

STORE COMMAND : EXAMPLE

18JANESH KODIKARA- PRAGMATIC TEST LABS

Page 19: Selenium Training

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

Page 20: Selenium Training

April 12, 2023

MATCHING TEXT PATTERNS

Globbing Patterns

Regular Expression Patterns

Exact Pattern

20JANESH KODIKARA- PRAGMATIC TEST LABS

Page 21: Selenium Training

April 12, 2023

REGULAR EXPRESSIONS

21JANESH KODIKARA- PRAGMATIC TEST LABS

Page 22: Selenium Training

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

Page 23: Selenium Training

April 12, 2023

LOGS

Setting Log Levels

23JANESH KODIKARA- PRAGMATIC TEST LABS

Page 24: Selenium Training

April 12, 2023

SELENIUM COMMANDS

Selense

Actions

Assessors

Assertions

24JANESH KODIKARA- PRAGMATIC TEST LABS

Page 25: Selenium Training

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

Page 26: Selenium Training

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

Page 27: Selenium Training

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

Page 28: Selenium Training

April 12, 2023

TESTING AJAX

Understanding Ajax

WaitFor Commands

Hands-on

28JANESH KODIKARA- PRAGMATIC TEST LABS

Page 29: Selenium Training

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

Page 30: Selenium Training

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

Page 31: Selenium Training

April 12, 2023

LOCATION STRATEGIES : ID

id=id

Select the element with the specified @id attribute

Hands-on

31JANESH KODIKARA- PRAGMATIC TEST LABS

Page 32: Selenium Training

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

Page 33: Selenium Training

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

Page 34: Selenium Training

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

Page 35: Selenium Training

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

Page 36: Selenium Training

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

Page 37: Selenium Training

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

Page 38: Selenium Training

April 12, 2023

USER EXTENSIONS

Writing Your Own Action

Wiring Your Own Assertion

Writing Your Own Location Strategy

38JANESH KODIKARA- PRAGMATIC TEST LABS

Page 39: Selenium Training

April 12, 2023

CROSS BROWSER TESTING

Installing RC

Starting RC Server

Running Tests

39JANESH KODIKARA- PRAGMATIC TEST LABS

Page 40: Selenium Training

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

Page 41: Selenium Training

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

Page 42: Selenium Training

April 12, 2023

CONFIRMATIONS

42JANESH KODIKARA- PRAGMATIC TEST LABS

assertConfirmation(Pattern) : Simulates clicking OK

chooseCancelOnNextConfirmation

chooseOkOnNextConfirmation

Page 43: Selenium Training

April 12, 2023

JAVASCRIPTS AND SELENSE PARAMETERS

43JANESH KODIKARA- PRAGMATIC TEST LABS

Script Parameters

Page 44: Selenium Training

April 12, 2023

JAVASCRIPTS AND SELENSE PARAMETERS

44JANESH KODIKARA- PRAGMATIC TEST LABS

Non-Script Parameters

Page 45: Selenium Training

April 12, 2023

DEBUGGING

45JANESH KODIKARA- PRAGMATIC TEST LABS

Page 46: Selenium Training

April 12, 2023

ECHO – PRINT COMMAND

46JANESH KODIKARA- PRAGMATIC TEST LABS

Page 47: Selenium Training

April 12, 2023

Practice Session

47JANESH KODIKARA- PRAGMATIC TEST LABS

Page 48: Selenium Training

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

Page 49: Selenium Training

April 12, 2023

Thank You

49JANESH KODIKARA- PRAGMATIC TEST LABS