
Explore how Selenium WebDriver and design patterns create reusable, maintainable test code. Learn to prioritize good code design over tool chatter, with hands-on Java and Maven, Cucumber, and Rundeck.
Explore Gang of Four design patterns to craft clean, reusable test automation beyond page objects; learn prerequisites in Selenium WebDriver and Java, and how patterns boost productivity and communication.
Learn how poorly designed page objects and if-else driven salary logic with webdriver coupling create maintenance, regression, and testing burdens across roles like manager and director.
Compare good code and bad code, identifying how bad code may work but burdens maintenance and regression testing, and learn design patterns to write maintainable, adaptable code.
Apply the single responsibility principle by giving a class a purpose to minimize testing and maintenance; leverage polymorphism and interfaces to keep components cohesive, loosely coupled, and avoid monolithic designs.
Compare tight coupling and loosely coupled designs, illustrate how single responsibility drives high cohesion, and analyze examples like login page object and employee class to clarify dependencies.
Practice scripting a Google search automation workflow with parameterized keywords and click-on-suggestion steps, then verify results by printing search statistics across pages like news, images, or videos.
Design page components by composing separate classes for the search textbox, suggestions, navigation bar, and result stats, connecting them to form the page and avoiding inheritance and base pages.
Set up a Maven project in your editor for Selenium design patterns with Java, enable Java 8, add Selenium and test dependencies, and organize source main java and test packages.
Learn a Selenium design pattern workflow: interact with search box, suggestions, and navigation to results page, while applying the single responsibility principle with abstract component that provides an isDisplayed check.
Build a search widget component for a Google page by using a webdriver, page factory, and explicit waits, then enter keywords into the 'Q' text box.
Design a Selenium Java page object by extending the abstract component, locating suggestions with a CSS selector using the bcd class, and clicking by index.
Implement explicit wait with a lambda to wait for at least five suggestions, using a Java 8 function that returns a boolean for flexible waiting beyond expected conditions.
refactor the test framework by moving common webdriver wait and driver initialization into an abstract component, use protected members, and let child classes implement their own elements.
Implement the navigation bar component by extending the abstract component, wiring a private bar element, and adding go to methods for images and news links with display waits.
Implement the result state component by extending the abstract component, locating the stat by its ID, waiting for display, and exposing get stat to return the element's text.
Create the Google main page as a page object in Selenium, initializing the search widget and search suggestions with a page factory and providing a go to url method.
Implement a Google result page using a page object model with search widget, search suggestion, and navigation bar; initialize via page factory and create main and result pages.
Create a base test in Java that initializes a WebDriver, sets up before and after test hooks, and shares a protected driver across page object tests for Firefox or Chrome.
Implement Google workflow with a base test and single responsibility principle, create Google main page and Google result page objects, and verify the search widget is displayed after launching site.
Learn how to parameterize a Google search test with Selenium WebDriver, simulate selecting search suggestions by index, navigate result pages, switch to news, and print result stats.
Implement corrections to the Selenium workflow by refining the navigation bar options and enabling video or image alternatives, and optimize the search widget with character-by-character typing, Ajax calls, and SendKeys.
Run the implemented workflow with the added steps and observe that the test runs successfully on the very first run.
Parameterize the Google search test with a data provider returning an object array named getData, supplying a string keyword and an index, and verify both test cases pass.
Refactor your selenium design by organizing page objects into main, result, and common packages, centralizing shared components like the search widget, microphone, and navigation bar in a common package.
Explore cohesion and coupling in page object design, showing how navigation bar and search widget stay closely related within a single page and its package.
Organize page objects into multiple component classes, with the page object merely holding component references. This follows the single responsibility principle and keeps tests readable.
Apply the single responsibility principle by keeping classes simple and small, splitting when they grow, and using design patterns as concrete SRP implementations in Java for robust Selenium tests.
Explore how design patterns offer repeatable, reusable solutions to common software design problems, and learn to recognize issues and apply pattern-based solutions with examples like if conditions and for loops.
Explore the difference between the single responsibility principle and design patterns, explaining how SRP focuses on small, single-purpose classes, while design patterns define interaction protocols between classes.
discover the factory design pattern by creating webdriver instances through a common interface, hiding the creation logic and enabling tests to run with browsers such as Chrome, Firefox, or Safari.
Explore the factory pattern by building a language-agnostic automation exercise that creates search tests via a common interface, parameterized for English, French, and Arabic Google searches, reporting result counts.
Implement a factory design pattern by creating an abstract Google page with common steps (launch site, search for keyword, get results count) and extending it with language-specific implementations under com.udemy.selenium.design.factory.
Implement the google english page by extending the abstract google page, using the factory pattern with page factory and selenium java, and waiting for search results.
Extend the google english page to implement the google french page using a robust css selector and id, switch language, and share the webdriver via a common google page base.
Extend the google english page to google arabic, override launch site to sa, switch language, click the keyboard, wait for elements, and perform the search using the same pattern.
Explains the factory pattern for creating language-specific google pages and enforces the single responsibility principle by mapping languages to lambda-based page instances via a google factory.
Build a factory-based Google search test in Selenium, using a data provider to run language-specific searches and verify result counts via the shared Google page interface.
Demonstrates a factory-driven Google search test in Selenium, addressing click timing by entering the query character by character and adding short sleeps to sync with onchange events, and validating results.
Learn to use the factory pattern in Selenium tests to accommodate new language requirements, extending a base Google test to Spanish by overriding launch site and reusing common steps.
Discover how the factory pattern streamlines test automation for multilingual apps by organizing language-specific behaviors into dedicated classes with a shared base, and returning WebDriver for multiple browsers.
Learn how the strategy design pattern defines a family of interchangeable behaviors and enables easy substitution, illustrated by a car engine upgrade and a Blu ray player handling disc types.
Explore a simple HTML example that demonstrates the strategy design pattern for a checkout page with multiple payment options—credit card, net banking, PayPal, and future options.
Introduce the strategy pattern to replace complex if-else in a payment flow, moving to component-based page objects for credit card, net banking, and PayPal.
Implement the strategy pattern for the payment screen by building a page object and modular components for user information and the order, following the single responsibility principle.
Create a payment option interface and concrete classes for credit card and net banking to enter payment information from a details map, mirroring radio button selections.
Connects payment screen components to the page object via a common payment option interface, initializes user information and order components, and sets the payment option at runtime using credit cards.
Create a payment screen test class extending the base test, initialize the page objects with the driver, and drive the flow from user data to payment option to order.
Create and pass diverse payment test data using data providers or feature files, building hash maps with credit card and net banking details to drive the payment screen tests.
Run a selenium-based payment screen test by passing the payment option as an object parameter, validating credit card and net banking flows, and confirming an order number is generated.
The strategy pattern, a behavioral pattern, changes a component's behavior at runtime by substituting different payment options on the payment screen, as in swapping engines.
Explore how factory creates objects (creational) and how strategy changes behavior (behavioral), using car engines and multiple payment options as examples.
Combine factory and strategy patterns to create payment options using a Java 8 supplier map, enabling flexible addition of credit card, net banking, or other options without conditional logic.
Learn the command design pattern, its decoupling of sender and receiver in test automation, and how an invoker triggers wrapped behavior inside objects—the page object and test classes.
Explore automating a dynamic web screen with elements that behave differently, including info messages that appear for seven seconds, notifications, modals, and form submissions, and validate these interactions end-to-end.
learn how the command design pattern streamlines page object and test logic by encapsulating actions like click on info, warning, success, and danger, reducing size and improving timing validation.
Develop a command pattern based notification validator in Selenium Java that uses an abstract element validator to verify button clicks display alerts and disappear after four seconds.
Learn to implement a dismissal alert validator in Selenium with Java, validating initial appearance, clicking the close button, and confirming the alert disappears.
Develop a home page object with the command design pattern, initialize a webdriver, navigate to the URL, and locate notification and alert elements using CSS selectors.
Demonstrates a single method returning a list of element validators, including notification and dismissal validators, to validate UI elements in Selenium with Java while reinforcing the single responsibility principle.
Extend the base test to create a home page test, initialize the page object with the driver, and use Java 8 streams to validate all element validators and assert true.
Identify and reliably target dismissal alerts on the home page by using precise selectors (card body -> row -> second child) and verify with document.querySelector for correct element scope.
Demonstrating the command design pattern, the lecture validates multiple elements on a slow HTML5 template and shows how Java 8 parallel streams run validations concurrently to improve test performance.
Embrace the command design pattern to wrap element validation logic in dedicated validation objects. Keep test classes and page objects neat by delegating validation to a centralized element validator.
Explore the template method design pattern, a special case of the factory pattern, and see how shared steps—from launching a site to entering payment details—apply across tasks using page objects and tests.
See how the template method pattern standardizes a purchase workflow by outlining the same steps—launch, search, select, land on the product description, extract price—and automate with a template.
Apply the template method to build an Amazon shopping flow by extending the shopping template, implementing search, select, and price extraction with Selenium WebDriver, waits, and page factory.
Apply the template method to implement an eBay shopping flow in Selenium, mirroring the Amazon example, including launching the site, searching a product, selecting it, and extracting the price.
Extend the base test to implement the template method for a shopping test, using a data provider that returns an object (driver and Samsung) to test Amazon and eBay shopping.
Run and validate a shopping test using the template method pattern, reporting eBay test passed and Amazon test fixed by correcting the input, then confirming both tests pass.
Apply the template method pattern to manage a reservation workflow, defining steps such as launch, select destination, search, and select book while delegating specifics to flight, car, or hotel.
Apply the template method to refactor Amazon’s multi-page checkout into three page objects and a coordinating template, driving go to, search, select, and buy with WebDriver.
Explore how the template method pattern manages a large, multi-page shopping workflow by delegating page object creation to a shopping template, with Amazon and eBay implementations.
Learn the proxy design pattern as a placeholder that provides controlled access to a page object across environments, enabling test automation to run in development while restricting prod steps.
Implement the proxy pattern for the order component in selenium tests, with a real and proxy class implementing the order component interface and returning an order number when placing orders.
Implement a proxy for the order component that uses the current environment. It creates a real object only in lower environments and skips in higher ones.
Integrate the order component proxy into the page object by replacing the real order with a proxy, using an interface and the driver, to test it.
Leverage the proxy object and a proxy package to run the same tests, highlighting page object design, and compare behavior across QA and production via system properties.
discover how a proxy object centralizes access on the payment screen, delegating to the real object in lower environments and bypassing it in higher ones, enabling controlled access and logging.
Apply the execute around method design pattern to run pre and post actions around a method call, ensuring resources like database connections and files are closed in test automation.
Apply the execute method pattern to a three-frame form, with behind-the-scenes switching, enabling data entry in any frame and in any order via page objects.
Implement the execute around method by building a main page object with three frame components (frame A, frame B, frame C), initialized via page factory and ready for frame switching.
Learn how to switch to frames in Selenium and master Java 8's consumer lambda for strings, including the consumer of string, the accept method, and no-return behavior with practical examples.
Explore the frame switching problem on a main page using the execute around method pattern, highlighting frame A and B challenges and default content pitfalls.
Apply the execute around method pattern in Selenium to manage frame switching for frames A, B, and C. Use lambdas to define frame actions and automatically return to default content.
Explore the decorator design pattern and learn how to add behavior to objects at runtime, illustrated with pizza and coffee examples and its use in Selenium test automation.
Explore a sample app that uses the decorator pattern to reveal role-based UI components and design page object tests for this screen.
Create a decorator-based dashboard page object using webdriver, locating components by CSS classes and roles, and exposing a single object with all components instead of per-role objects.
Implement the decorator design pattern in Java 8 with lambdas to compose role-based dashboard tests from ingredient decorators, including admin, guest, and super user components.
Apply the decorator pattern to selenium tests by composing a dashboard page with role-based decorators. Use a data provider and a dashboard page consumer to validate per-role components.
Apply the decorator pattern to a payment page scenario with coupon, partial promo code, and credit card options, and design page objects and tests.
Demonstrate how the decorator pattern extends a simple page object to build payment flows, apply promo codes, enter card details, and verify pass or fail across test cases.
Explore the dependency injection pattern to build a framework for page objects, multi-window handling, localization, automatic screenshots, and cross-environment testing with Spring Boot.
Mastering Design Patterns for Test Automation: Reusability and Maintainability
Design Patterns offer repeatable and reusable solutions to address software design challenges. In this comprehensive course, you will be introduced to frequently used Design Patterns, empowering you to leverage their potential in Test Automation. By applying these patterns to your Automation Frameworks, Page Objects, and Test classes, you will achieve enhanced reusability and maintainability, paving the way for efficient and scalable test automation solutions.
Key Learning Points:
Single Responsibility Principle: Gain insights into the fundamental principle of assigning specific responsibilities to modules, classes, and methods within an application. Learn how to refactor complex Page Objects into modular Page Components or Fragments, resulting in more organized and neater test steps.
Factory Pattern: Uncover the power of creating objects without exposing the creation logic to the test class. Explore localization testing scenarios, where multiple languages and their specific behaviors come into play. Implement an abstract class with common functionalities and language-specific subclasses, leveraging the Factory Pattern to dynamically create Page Objects based on the language being tested.
Strategy Pattern: Understand how to pass behavior to an object at runtime without resorting to cumbersome if-else blocks. For instance, examine a Google search page with different search strategies, such as text-based or voice-based search. By utilizing the Strategy Pattern, you can dynamically switch between these strategies, promoting flexibility in your automation code.
Command Pattern: Explore how to encapsulate an object with all the necessary information for later execution. This pattern is highly valuable for Pages with multiple UI components and numerous UI validations.
Template Method Pattern: Discover how to design high-level steps or a skeleton in a superclass while allowing subclasses to override specific steps. This pattern is particularly useful in scenarios where similar applications, such as room booking and car booking, share common workflows with varying options.
Proxy Pattern: Learn how to create a placeholder object for another object, facilitating seamless execution of specific steps based on the testing environment. For instance, executing certain steps in the QA environment while skipping them in the production environment is made more efficient using the Proxy Pattern.
Execute Around Method Pattern: This pattern addresses the need to perform specific steps consistently, regardless of the main task. For example, opening and closing files before and after reading or writing content is a common occurrence. The Execute Around Method Pattern provides a systematic approach for handling such scenarios.
Decorator Pattern: Delve into the world of dynamic UI components based on user roles within an application. By employing the Decorator Pattern, you can create flexible Page Objects that adapt to different user roles, such as admin or user, granting them varying levels of access.
By completing this course, you will acquire a strong foundation in essential Design Principles and Patterns for Test Automation. Empowered with this knowledge, you will significantly enhance the reusability and maintainability of your Automation Framework, Page Objects, and Test classes. Unleash the full potential of Design Patterns and elevate your test automation solutions to new heights of efficiency and scalability.