@@ -31,8 +31,15 @@ if (project.hasProperty('browsers')) {
3131 }
3232}
3333
34+ // if "personality" is specified
3435if (project. hasProperty(' personality' )) {
35- System . setProperty(' selenium.browser.name' , ext. personality)
36+ // store "injected" browser name setting
37+ System . setProperty(' injected.selenium.browser.name' , ext. personality)
38+ // if target is a mobile browser
39+ if ([" .chrome" , " .safari" ]. any { ext. personality. endsWith(it) }) {
40+ // specify "web-app" as the injected default context platform
41+ System . setProperty(' injected.selenium.context.platform' , ' web-app' )
42+ }
3643}
3744
3845def archiveVer = null
@@ -123,30 +130,33 @@ javadocJar {
123130 destinationDirectory = libsDir
124131}
125132
133+ tasks. withType(Test ). configureEach {
134+ // iterate over system properties
135+ System . getProperties(). each { key , val ->
136+ // if this is a property that should be propagated to the test task
137+ if (key. endsWith(' .binary.path' ) || [' injected.' , ' selenium.' , ' appium.' , ' testng.' , ' junit.' ]. any { key. startsWith(it) }) {
138+ // if running on Windows and this property defines JSON browser capabilities
139+ if (OperatingSystem . current(). isWindows() && key. endsWith(' selenium.browser.caps' )) {
140+ // escape double quotes
141+ val = val. replace(' "' , ' \\\\ "' )
142+ }
143+ // propagate property
144+ systemProperty key, val
145+ }
146+ }
147+ }
148+
149+
126150task testNG (type : Test ) {
127151 useTestNG()
128152 reports. html. destination = file(" ${ buildDir} /reports/testng" )
129153 testLogging. showStandardStreams = true
130-
131- systemProperty ' selenium.grid.plugins' , System . getProperty(' selenium.grid.plugins' )
132- systemProperty ' selenium.browser.name' , System . getProperty(' selenium.browser.name' )
133- systemProperty ' selenium.browser.caps' , getBrowserCaps()
134- systemProperty ' selenium.context.platform' , System . getProperty(' selenium.context.platform' , ' support' )
135- systemProperty ' selenium.grid.examples' , System . getProperty(' selenium.grid.examples' , ' true' )
136- systemProperty ' appium.with.pm2' , System . getProperty(' appium.with.pm2' , ' false' )
137154}
138155
139156test {
140157 dependsOn testNG
141158 reports. html. destination = file(" ${ buildDir} /reports/junit" )
142159 testLogging. showStandardStreams = true
143-
144- systemProperty ' selenium.grid.plugins' , System . getProperty(' selenium.grid.plugins' )
145- systemProperty ' selenium.browser.name' , System . getProperty(' selenium.browser.name' )
146- systemProperty ' selenium.browser.caps' , getBrowserCaps()
147- systemProperty ' selenium.context.platform' , System . getProperty(' selenium.context.platform' , ' support' )
148- systemProperty ' selenium.grid.examples' , System . getProperty(' selenium.grid.examples' , ' true' )
149- systemProperty ' appium.with.pm2' , System . getProperty(' appium.with.pm2' , ' false' )
150160}
151161
152162scmVersion {
@@ -259,11 +269,3 @@ test {
259269 " -javaagent:${ classpath.find { it.name.contains('junit-foundation') }.absolutePath} "
260270 ]
261271}
262-
263- def getBrowserCaps () {
264- def browserCaps = System . getProperty(' selenium.browser.caps' )
265- if (browserCaps && OperatingSystem . current(). isWindows()) {
266- return browserCaps. replaceAll(' "' , ' \\\\ "' )
267- }
268- return browserCaps
269- }
0 commit comments