4. @BagmarAnand
• Be on time
• Make this an interactive workshop
• Ask questions
• We will try to address unrelated / long discussions towards the end
Rules for the day
@BagmarAnand
6. @BagmarAnand
Site: https://dev.confengine.com/
Scenario: As a non-logged-in user, I should be asked to login when adding
a session to my schedule
• From UPCOMING section, Select “Selenium Conf 2020”
• “View Schedule”
• Add the 1st session to My Schedule (that is NOT already added)
• Do not login to sync the schedule to other devices
• Verify count has increased in “My Schedule”
Exercise #1
@BagmarAnand
7. @BagmarAnand
• Understand how to get started
• Objective of Automation
Objective / Learning from Exercise #1
@BagmarAnand
18. @BagmarAnand
How do you debug and get to
the root cause of failures?
@BagmarAnand
Rerun test
All info available
to debug
19. @BagmarAnand
• Browser types & versions
• No easy way to identify locators
• Changes in locators / data
• Flaky tests / intermittent test failures
• Test Data availability
• Test Configuration in code?
Typical challenges
@BagmarAnand
23. @BagmarAnand
How does WebDriver work?
@BagmarAnand
Selenium Browser
Drivers
Browsers
Wire Protocol
over HTTP
HTTP
over
HTTP
Server
Test Scripts use
Selenium Client
Libraries
24. @BagmarAnand
• Hardcoded / specific browser driver versions
• Locators specified as part of tests / duplicated
• Duplicate code for setup / teardown
Challenges from Exercise #1
@BagmarAnand
27. @BagmarAnand
• WebDriverManager to manage browser drivers & versions
• Locators – types, how to identify and specify
• Use of TestRunner Annotations for setup & teardown
• Build tool for configuration / setup
• Maven
• Gradle
Objective / Learning from Exercise #2
@BagmarAnand
28. @BagmarAnand
• Test intent not clear
• Duplication of implementation details
• Very granular / imperative implementation
Challenges from Exercise #2
@BagmarAnand
30. @BagmarAnand
• Page-Object
• Business Layer
• Composition
• Factory Method
• Singleton -> DO NOT USE UNLESS YOU ARE VERY SURE
Commonly used Design Patterns
@BagmarAnand
31. @BagmarAnand
• The page object will contain the representation of the page, and the services the
page provides via methods
• Single source for the services or operations offered by the page
• Clean separation between test code and page specific code
• Page objects themselves should never make verifications or assertions
• “Page Component Objects” that represent discrete chunks of the page and can be
included in page objects -> Composite Pattern
• https://www.selenium.dev/documentation/en/guidelines_and_recommendations/page_objec
t_models/
Page-Object Model
@BagmarAnand
32. @BagmarAnand
Site: https://dev.confengine.com/
Scenario: As a non-logged-in user, I shouldn’t be able to add a session to
my schedule for a conference that has completed
• From PAST section, Select “Appium Conf 2019”
• “View Schedule”
• Add the 1st session to My Schedule (that is NOT already added)
• Verify adding session to Schedule does not increase the count in “My
Schedule” for a conference in the PAST
Exercise #3 – Use Page-Object Model
@BagmarAnand
33. @BagmarAnand
• Test intent gets polluted
• Duplication of Test intent & implementation
• Intent becomes Imperative
• Maintenance challenges
• Scaling challenges
Limitations of Page-Object Pattern
@BagmarAnand
34. @BagmarAnand
• Test speaks the “business” language
• Test orchestrates business operations
• Business operations orchestrate other business operations & page objects
• Assertions in business operations
• Declarative style of writing the test
• Clear intent
• Executable business requirements / documentation
• Great resource for onboarding new team members
Business-Layer Page-Object Pattern
@BagmarAnand
35. @BagmarAnand
• Introduction to Patterns
• Implementing Page-Object Pattern & Business-Layer Pattern
• Implement for parallel execution & scaling
• Examples of usage for other patterns in Functional Automation
• Clear Test Intent (Test does not care about the driver, nor
implementation details)
Objective / Learning from Exercise #3
@BagmarAnand
36. @BagmarAnand
• Get information from the page
• Do actions on the page
• Page Objects cannot differentiate between right or wrong!
• No assertions in the Page Object
Page-Object Model
@BagmarAnand
39. @BagmarAnand
• Importance of test data management strategy
• Different ways to specify test data
Objective / Learning from Exercise #4
@BagmarAnand
41. @BagmarAnand
• Data is complex
• Needs to mimic ‘real’ data
• Needs to be unique
• Data can be nested
• Though specified as static, may need to be Dynamic
• Data can be shared and reused
Characteristics of Test Data
@BagmarAnand
42. @BagmarAnand
• In Test implementation
• In Test specification / intent
• In code … separate data structures / classes / etc.
• External files
Different ways to specify Test Data
@BagmarAnand
44. @BagmarAnand
• Usable
• Easy to specify
• Easy to read and consume (by test implementation)
• Ability to override specified data, easily
Criteria for selecting Test Data file format
@BagmarAnand
45. @BagmarAnand
• Consistent way to specify test data
• Read the data as Business Entities
• Override as appropriate
• Create DSL to giving meaning to data
• Implement Test Data Entity Utilities – ex: Build / Equals /
Copy / Find / etc.
Tips for implementing Test Data Strategy
@BagmarAnand
52. @BagmarAnand
• Advantages & disadvantages of Assertions
• Hard asserts Vs Soft asserts
• Use of Assertions
• Where to include them?
• How to use them?
• Clarity in intent of validation
• Assertions Vs throwing exceptions
Objective / Learning from Exercise #5
@BagmarAnand
56. @BagmarAnand
• Using CSS & HTML to resize, hide, shrink, enlarge, or move
the content to make it look good on any screen
• In some cases, Javascript execution in the browser on page-
load also changes / optimises functionality
How does Responsive Web Design work?
@BagmarAnand
57. @BagmarAnand
• Strategy for RWD Automation
• Need for Cross-Browser Testing
• How is RWD implemented in the product-under-test / AUT?
• Select browsers to run your functional tests
• Manage different browser versions
• Viewport sizes for automation implementation / execution
Next Steps for RWD Automation
@BagmarAnand
59. @BagmarAnand
• Intent of executed test is seen clearly
• Includes logs / screenshots / video of test execution
• Showcases the functional coverage from the execution
• Identifies trends of execution results
• Includes functional performance benchmarking
Characteristics of a good report!
@BagmarAnand
62. @BagmarAnand
Unit (xUnit / JavaScript)
Manual / Exploratory
Web Service
UI / e2e
Business-facing
Tests
Technology-facing
Tests
@BagmarAnand
Test Pyramid
Slow
More integration
Expensive
Fast
More isolation
Cheap
63. @BagmarAnand
Unit (xUnit / JavaScript)
Manual / Exploratory
Web
Service
UI / e2e
Business-facing
Tests
Technology-facing
Tests
@BagmarAnand
Slow
More integration
Expensive
Fast
More isolation
Cheap
Workflow
API
Contract
Consumer
Provider
Test Pyramid
64. @BagmarAnand@BagmarAnand
Unit (xUnit / JavaScript)
Manual / Exploratory
Web Service
UI / e2e
Performance
Security
Accessibility
Analytics
Test Pyramid includes NFRs