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 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 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 also also implements few other interfaces like HasCapabilities, HasInputDevices, Interactive, PrintsPage and HasVirtualAuthenticator.
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:
- Safari Driver
Classes which extends ChromiumDriver are: