This library helps with managing browser instantiation and clean-up automatically for :
- Cucumber based tests.
- TestNG based tests.
- Cucumber ( Compatibility testing has only been done for
group: 'info.cukes', name: 'cucumber-java', version: '1.2.5'
) - JDK-8 ( This implementation uses a reflection based mechanism to alter annotations values at runtime. This has been tested only on JDK8)
- Cucumber TestNG integration (This implementation does not work with the JUnit based Cucumber runner)
Add the below maven dependency to get started
<dependency>
<groupId>com.rationaleemotions</groupId>
<artifactId>autospawn</artifactId>
<version>1.2.2</version>
</dependency>
- Create an implementation of
com.rationaleemotions.web.IBrowserCreator
. - Wire in this implementation via the JVM argument
-Dcreator=
- Annotate all cucumber scenarios that automatically need a browser instance to be created using the tag
@Browser
- Now within your scenario you can query the browser instance using
DriverFactory.getDriver()
- Create an implementation of
com.rationaleemotions.web.IBrowserCreator
. - Wire in this implementation via the JVM argument
-Dcreator=
- Annotate all
@Test
methods that automatically need a browser instance to be created using the annotation@Browser
- Now within your
@Test
method you can query the browser instance usingDriverFactory.getDriver()
Note:
Here DriverFactory
belongs to the package com.rationaleemotions.web.DriverFactory