Class hierarchy is basically, how classes are inter-related to each other in certain order. An interface in the Java programming language is an abstract type that is used to specify a behavior that classes must implement.
In Selenium we have different interfaces and classes which are inter-related, if you will see below flowchart:
Here we are using parallelogram symbol for an interface, rectangle for classes, yellow arrow for extends and black directional connecter for implements.
SearchContext Interface
SearchContext is a super or top most interface in WebDriver hierarchy. This interface consists of only two methods findElement() and findElements(). This interface is extended by both WebDriver and WebElement interfaces.
WebDriver Interface
WebDriver is a remote control interface that enables introspection and control of user agents (browsers). It extends SearchContext. The methods in this interface fall into three categories:
- Control of the browser itself
- Selection of WebElements
- Debugging aids
Key methods are get(String), which is used to load a new web page, and the various methods similar to findElement(By), which is used to find WebElements.
Currently, you will need to instantiate implementations of this interface directly. You write your tests against this interface so that you may "swap in" a more fully featured browser when there is a requirement for one. Most implementations of this interface follow W3C WebDriver specification.
WebDriver interface has multiple inner interfaces like ImeHandler, Navigation, Options, TargetLocator, Timeouts and Window which contains methods related to specific events.
RemoteWebDriver Class
RemoteWebDriver, which is a fully implemented class where all abstract methods of WebDriver and SearchContext interface implemented. Also, two other comment interfaces JavascriptExecutor and TakesScreenshot abstract methods are implemented in RemoteWebDriver class.
RemoteWebDriver also also implements few other interfaces like HasCapabilities, HasInputDevices, Interactive, PrintsPage and HasVirtualAuthenticator.
JavascriptExecutor Interface
JavaScriptExecutor is an Interface that helps to execute JavaScript through Selenium Webdriver. JavaScriptExecutor provides two methods "executescript" & "executeAsyncScript" to run javascript on the selected window or current page.
TakesScreenshot Interface
TakesSchreenshot capture a screenshot and store it in different ways.
Browser Specific Classes
Browser specific classes provides control on a browser and provides different methods to test browser. Browser specific driver classes which extend RemoteWebDriver:
- InternetExplorerDriver
- FirefoxDriver
- ChromiumDriver
- OperaDriver
- Safari Driver
Classes which extends ChromiumDriver are:
- ChromeDriver
- EdgeDriver
- Log in to post comments