Since we already have a working Maven implementation, let's enhance it so that it can connect to a Selenium Grid. These enhancements will enable you to connect to any Selenium Grid, but we are going to speci cally look at connecting to a third-party service provided by Sauce Labs since it offers a free tier. Let's have
a look at the modi cations we need to make to our TestNG code.
We will start off with the modi cations to our POM; rst of all we are going to add some properties that we can con gure on the command line:
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.
outputEncoding> <!-- Dependency versions --> <selenium.version>2.45.0</selenium.version> <!-- Configurable variables --> <threads>1</threads> <browser>firefox</browser> <overwrite.binaries>false</overwrite.binaries> <remote>false</remote> <seleniumGridURL/> <platform/> <browserVersion/>
</properties>
I've left the seleniumGridURL element blank because I don't know your Selenium Grid URL, but you can give this a value if you want. The same applies to platform and browserVersion. Next we need to make sure these properties are read in as system properties so we need to modify our maven-failsafe-plugin con guration:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-failsafe-plugin</artifactId> <version>2.17</version> <configuration>
<parallel>methods</parallel> <threadCount>${threads}</threadCount> <systemProperties>
<browser>${browser}</browser> <remoteDriver>${remote}</remoteDriver> <gridURL>${seleniumGridURL}</gridURL> <desiredPlatform>${platform}</desiredPlatform>
Comments
0 comments
Please sign in to leave a comment.