Overview of C# Selenium WebDriver Namespace

While I was trying to understand the selenium namespace, found it confusing since it has too much inside and some obsolete namespace as well. Using Selenium webdriver 3.7.0 to explain the library. [Note: This is not an implementation article and assuming reader knows basic implementation of webdriver]

The C# selenium library is can be grabbed from Nuget: webdriver & supportIgnore WebDriverBackedSeleniumRC since they are transitional packages for old RC API. C# Selenium API documentation can be found here: link

Overview

Before we begin, lets see a high level diagram of selenium test automation.

All the components above are present and configurable in API. The two libraries are — (i) WebDriver (ii) WebDriver.Support. They contain the following namespaces

Namespace

Below is a simple cheatsheet on the namespaces. Added few classes which i felt worth mentioning under each namespace.

OpenQA.Selenium : The biggest namespace in the package. Contains the fundamental components of the webdriver. They are group into :-

  1. WebDriver Service/Options : These classes are responsible for initiating service, proxy, capabilities, extension, arguments, platform.

2.Cookie/Screenshots : Browser cookie management. Taking screenshot of the browser.

3. Inputs/Logging : responsible for input interaction such as keyboard, mouse, navigation, touchscreen. Defines the log entry and type.

  • Keys : keys able to be pressed

4. Elements/Exceptions : Classes contains the web element selector such as ClassName, id, XPath etc. While there are Exception defined in the package related to above classes.

  • By : find elements within a document

OpenQA.Selenium.Remote : This namespace contains Web driver base class along with WebElement, sessionid , response. It has commands & capabilities.It also deals with storage such as Application Cache, Local Storage, LocationContext, WebStorage and SessionStorage.

OpenQA.Selenium.Chrome/Edge/Firefox/IE/Opera/PhantomJS/Safari : This namespace contains implementation of Remote & Selenium namespace. They are usually required for actual selenium testing. All browser classes inherits — RemoteDriver, DriverService, DriverOptions and RemoteWebElement.

OpenQA.Selenium.Html5 : This package contains HTML5 definitions and represents browser’s physical locations.

  • Location : Represents the physical location of the browser.

OpenQA.Selenium.Interactions : This class responsible for advance interactions with the browser such as Action & Touch Action.

  • Actions : mechanism for building advanced interactions

OpenQA.Selenium.Support.UI : This namespace exist in both DLLs. It helps testing with explicit waits, advanced expected conditions and WebElement Load status.

OpenQA.Selenium.Support.Events : The namespace helps during execution of test by logging the details using events.

  • EventFiringWebDriver : A wrapper around an arbitrary WebDriver instance which supports registering for events

OpenQA.Selenium.Support.PageObjects : A useful namespace to smartly identify WebElements and can produce PageObject modeling for a page.

  • ByAll : locate elements within a document using a series of lookups
  • ByChained : locate elements within a document using a series of other lookups.
  • PageFactory : ability to produce Page Objects modeling

Leave a Reply

Your email address will not be published.