Web Automation Using Selenium
  • About The Book
  • Selenium
    • Introduction
      • What is testing and why?
      • What is Selenium and Why?
    • Getting Started
      • Audience
      • Prerequisite
      • Set up
      • Getting Started - Hello World..!!
      • What are drivers
    • Locators
      • CSS Selectors
      • XPath Selector
    • WebDriver
      • WebDriver Methods
      • WebDriver Types
    • WebElement(s)
      • WebElement Methods
      • Looping Through WebElements
    • Waits In Selenium
  • TestNG
    • Introduction
    • TestNG Setup
    • First Test Script
    • Some of the features of TestNG
    • TestNG Annotations
      • @Test
      • @DataProvider
  • Maven
    • Introduction
  • Framework Development
    • Introduction
    • Building Framework
      • Technology Stack
      • Page Object Model (POM)
      • Setup
      • What our framework contain
      • Packages
        • Context
        • Factory
        • Listeners
        • Pages
      • Creating first automation test
  • Common Interview Questions
    • Selenium-Related
Powered by GitBook
On this page
  • 1. Constants.java
  • 2. WebDriverContext.Java

Was this helpful?

  1. Framework Development
  2. Building Framework
  3. Packages

Context

PreviousPackagesNextFactory

Last updated 2 years ago

Was this helpful?

This package will contain classes responsible for contains, holding objects throughout test execution etc.,

1.

We can use this class to store all the constants that are not going to change during the test execution. Like URLs, File paths, credentials for our applications etc.,

2.

Since our framework is capable of running tests in parallel, it's very important to manage our webdriver instance across the threads that are running in parallel. This class makes sure there is one and only one webdriver instance in each thread.

So we set webdriver instance in this context whenever we initialize, and this class maintains that instance in that particular thread.

So in our code whenever we need webdriver instance we should always use WebDriverContext.getDriver()

Constants.java
WebDriverContext.Java