seleniumtestingprotractornightwatch

What is a Selenium wrapper?


Does it wrap around Selenium and provide a simpler or different method of invoking the functionality of Selenium?

I looked it up on Google and the best information I could find was this one https://www.ontestautomation.com/using-wrapper-methods-for-better-error-handling-in-selenium/.

This doesn't explicitly explain what a Selenium wrapper is but gives enough information to help understand what it is.


Solution

  • One of the definitions of a "wrapper" is:

    In the context of software engineering, a wrapper is defined as an entity that encapsulates and hides the underlying complexity of another entity by means of well-defined interfaces.

    So, any custom code you might use that implements Selenium code could be understood as a wrapper.

    For example, Katalon Studio is a testing tool that uses Selenium under the hood i.e. Katalon's WebUI class methods are a wrapper around Selenium methods. The following two pieces of code are equivalent - they do the same thing:

    1. Selenium (and Java)
    WebElement element = driver.findElement(By.cssSelector("css-selector-of-the-element"));
    element.click();
    
    1. Katalon
    WebUI.click(testObject) //testObject defined elsewhere
    

    This is just a simple example, but it shows how can you hide complexity behind simpler commands.