In the previous post of this WebDriver series, I shared a gist about what WebDriver does and how. In this blog post as Part 2 of this series, I'm sharing a bit more details on WebDriver and RemoteWebDriver.
From there, we will see how AppiumDriver is related to WebDriver -- which extends the interface SearchContext.
This blog post is written as part of 21Days21Tips from The Test Chat. The tip shared in this post is to know more about WebDriver internals and how it associates with RemoteWebDriver and AppiumDriver.
This should help in understanding the Selenium APIs better and from where it comes. This helps in having a better mental model of the Selenium WebDriver and how we want to structure the instructions in the tests and utilities we write
SearchContext and WebDriver
- The SearchContext is the parent interface in the WebDriver hierarchy
- The subinterfaces of SearchContext are
- WebDriver
- WebElement
- This SearchContext defines two methods
- findElement(By by)
- Modifier and Type is: WebElement
- It finds the first WebElement using the given method
- findElements(By by)
- Modifier and Type is: java.util.List<WebElement>
- It finds all elements within the current context using the given mechanism
- Note: I'm referring to Java APIs of Selenium in this blog post
- More details of this can be found here.
- close()
- findElement(By by)
- findElements(By by)
- get(java.lang.String url)
- getCurrentUrl()
- getPageSource()
- getTitle()
- getWindowHandle()
- getWindowHandles()
- manage()
- navigate()
- quit()
- switchTo()
RemoteWebDriver and AppiumDriver
- Why do we initiate the WebDriver for first
- And, then we instantiate the browser's driver
- Later how we use WebDriver's instantiation to drive action (mimic the user action) on the browser using the respective browser's driver
The class AppiumDriver extends the WebElement and RemoteWebDriver from the project Selenium. And further, it has its own methods to interact with the mobile elements. More details about the Java Client of AppiumDriver can be found here.
The subclasses of AppiumDrivers are:
- AndroidDriver
- iOSDriver
- WindowsDriver
21 Days 21 Tips -- #day17
Here are my pointers to fellow test engineers
- Interface SearchContext is top in the hierarchy of the WebDriver interface
- Interface SearchContext defines
- Should I want to search for the element in the whole page
- using WebDriver object
- Or, should I search within a containing element
- using WebElement object
- We can notice methods returning the type WebElement
- RemoteWebDriver implements the interface WebDriver
- The modern browsers drivers extends the class RemoteWebDriver
- AppiumDriver extends the class RemoteWebDriver and interface WebElement
- AndroidDriver extends AppiumDriver
- iOSDriver extends AppiumDriver
- WindowsDriver extends WindowsDriver
- SeleniumHQ Repository -- https://github.com/SeleniumHQ/selenium
- Selenium Java Client
- SearchContext
- WebDriver
- RemoteWebDriver
- ChromiumDriver
- WebDriver and browser's driver instantiation
- The order in which it is instantiated and used in programming to automate actions on the browser
No comments:
Post a Comment
Please, do write your comment on the read information. Thank you.