Skip to content

Multi browser support

Marcus Kaufmann edited this page May 9, 2018 · 38 revisions

Multi browser support

Multi browser support enables you to execute your test with different browser configurations. Notice the @Browser annotation in the example below. Every listed string of that ordered list references a specific browser configuration (see Browser configuration)

@RunWith(NeodymiumRunner.class)
@Browser({"Firefox_large", "Chrome_large", "InternetExplorer_small"})
public class MyTests
{
    @Test
    public void testMethod()
    {
        // implementation
    }
}

On execution each @Test method will be automatically executed with each annotated browser configuration. Neodymium creates the browser instance according to the configuration, injects the resulting web driver in Selenide framework and clear them up afterwards.

BTW: The @Browser annotation can be inherited from a parent class and if needed you can overwrite it in the test class.

Browser configuration

Browser configurations are stored in the file config/browser.properties Since it is a property file a special format is needed to define a configuration.

Format: browserprofile.<configuration tag>.<property>

  • browserprofile is a static prefix that must be used for every configuration.
  • <configuration tag> is a user defined string that is later on used to be referred with @Browser annotation

NOTE: This <configuration tag> must not contain any white space characters. Also it's treated case sensitive.

  • <property> is one of the listed below
Property Mandatory Description
name YES is a more detailed name of this browser/device test. This name will be used for reporting
browser YES determines what browser will be used for this test. Valid values are iphone, ipad, android, firefox, chrome, internetexplorer, safari
version YES if used for device emulation determines which version of the browser should be used OR determines the version of the OS of an emulated device by default version references the browser version, but in case of saucelabs device emulation usage it may be used for the OS version instead
browserResolution NO determines width and height of the browser window. If not specified the default will be used instead not applicable for mobile device emulation can be defined as e.g. 1200x900 or 1200X900 or 1200,900
screenResolution NO determines width and height of the emulated operating system only applicable for Windows, Linux and MacOS devices can be defined as e.g. 1280x1024 or 1280X1024 or 1280,1024
platform NO defines on which (emulated) platform the test should run. See SauceLabs Platform-Configurator for further more information
deviceOrientation NO defines the screen orientation. only for mobile/tablet device emulation valid values: portrait or landscape
testEnvironment NO determines where the testcase will be executed. possible values are local and saucelabs. NOTE: you only need to set this property if you want to use saucelabs as test environment. by default the value local is assumed.
chromeEmulationProfile NO A special property that contains a device name that should be emulated. This property is for chrome only. See chrome device emulation features for valid strings. NOTE: Currently are only from chrome predefined devices supported.
pageLoadStrategy NO This property defines when the web driver will return from a page load. Value can be normal, eager or non
  • normal: (default) call returns when load event was fired
  • eager: returns when DOMContentLoaded event was fired
  • none: returns immediately
headless NO Boolean propertey that determines if the browser should run in headless mode. Default value is false. NOTE: Currently only supported for Firefox and Chrome

Example

# latest Google Chrome local in 1600x1200
browserprofile.Chrome_1600x1200.name = Chrome 1600x1200
browserprofile.Chrome_1600x1200.browser = chrome
browserprofile.Chrome_1600x1200.browserResolution = 1600x1200

# latest Firefox local in 1500x1000
browserprofile.Firefox_1500x1000.name = Firefox 1500x1000
browserprofile.Firefox_1500x1000.browser = firefox
browserprofile.Firefox_1500x1000.browserResolution = 1500x1000
Clone this wiki locally