Skip to content

Support Selenium 4 new features

ixytiris edited this page Dec 10, 2021 · 5 revisions

Stevia v1 new release supports Selenium 4 new features such as :

Selenium Load Strategy

Stevia by default set it to NORMAL , Selenium supports the following strategies :

  • normal

    This will make Selenium WebDriver to wait for the entire page is loaded. When set to normal, Selenium WebDriver waits until the load event
    fire is returned.

  • eager

    This will make Selenium WebDriver to wait until the initial HTML document has been completely loaded and parsed, and discards loading of stylesheets, images and subframes.

  • none

    When set to none Selenium WebDriver only waits until the initial page is downloaded.


To override the default value, add to your testNG xml

 <parameter name="loadStrategy" value="none"/>

Selenium Relative Locators

  • above()
  • below()
  • toLeftOf()
  • toRightOf()
  • near()


Stevia implements Relative Locators such as :


* Finds an element that is at most 50px away from the specified element.

public WebElement findTagNearElement(String tag,String nearOfElement)


* Finds WebElement with specific tag which is left to specific locator

public WebElement findTagToTheLeftOfElement(String tag,String leftOfElement)


* Finds WebElement with specific tag which is right to specific locator

public WebElement findTagToTheRightOfElement(String tag,String right OfElement)


* Finds WebElement with specific tag which is above specific locator

public WebElement findTagAboveElement(String tag,String aboveOfElement)


* Finds WebElement with specific tag which is above specific locator and to the left of other locator

public WebElement findTagAboveElementToTheLeftOfElement(String tag,String aboveOfElement,String leftOfLocator)


more combinations exist under the WebDriverWebController class.

Example of Stevia finding relative locator

For example if you like to find and click an "a" tag (link) which is below SIGN_IN Button and to the right of FORGOT LINK

controller().findTagBelowElementToTheRightOfElement("a",BUTTON_SIGN_IN.get(),LINK_FORGOT.get()).click();

Mocking Geolocation - Supported on Local Chrome Driver

Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.

  • latitude: number

  • longitude: number

  • accuracy: number

To set geolocation numbers add to your testNG xml for example:

<parameter name="location.latitude" value="35.8235"/>
<parameter name="location.longitude" value="-78.8256"/>
<parameter name="location.accuracy" value="100"/>

Simulate Device Dimensions - Supported on Local Chrome Driver

Overrides the values of device screen dimensions - pass 0 to disable override

  • width: integer

  • height: integer

  • deviceScaleFactor: integer

  • mobile: boolean

To set device dimension add to your testNG xml for example:

 <parameter name="device.width" value="600"/>
 <parameter name="device.height" value="800"/>
 <parameter name="device.scale.factor" value="50”/>
 <parameter name="device.mobile" value="true"/>