Skip to content

Commit 8d69c49

Browse files
committed
Fix test config override; add Edge presonality
1 parent 28fc2d6 commit 8d69c49

16 files changed

+81
-71
lines changed

build.gradle

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,15 @@ if (project.hasProperty('browsers')) {
3131
}
3232
}
3333

34+
// if "personality" is specified
3435
if (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

3845
def 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+
126150
task 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

139156
test {
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

152162
scmVersion {
@@ -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-
}

chromeDeps.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
2-
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.ChromePlugin' + File.pathSeparator)
3-
System.setProperty('selenium.browser.name', 'chrome')
4-
System.setProperty('selenium.context.platform', 'web-app')
2+
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.ChromePlugin' + File.pathSeparator)
3+
System.setProperty('injected.selenium.browser.name', 'chrome')
4+
System.setProperty('injected.selenium.context.platform', 'web-app')
55
dependencies {
66
testImplementation('org.seleniumhq.selenium:selenium-chrome-driver') {
77
exclude module: 'selenium-remote-driver'

edgeDeps.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
2-
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.EdgePlugin' + File.pathSeparator)
3-
System.setProperty('selenium.browser.name', 'MicrosoftEdge')
4-
System.setProperty('selenium.context.platform', 'web-app')
2+
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.EdgePlugin' + File.pathSeparator)
3+
System.setProperty('injected.selenium.browser.name', 'MicrosoftEdge')
4+
System.setProperty('injected.selenium.context.platform', 'web-app')
55
dependencies {
66
testImplementation('org.seleniumhq.selenium:selenium-edge-driver') {
77
exclude module: 'selenium-remote-driver'

espressoDeps.gradle

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
2-
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.EspressoPlugin' + File.pathSeparator)
3-
System.setProperty('selenium.browser.caps', '{"platformName":"Android","appium:automationName":"Espresso","appium:forceEspressoRebuild":true,"appium:showGradleLog":true,"appium:app":"https://github.com/appium/appium/raw/master/packages/appium/sample-code/apps/ApiDemos-debug.apk"}')
4-
System.setProperty('selenium.context.platform', 'android')
5-
System.setProperty('selenium.grid.examples', 'false')
6-
System.setProperty('appium.with.pm2', 'true')
2+
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.EspressoPlugin' + File.pathSeparator)
3+
System.setProperty('injected.selenium.browser.caps', '{"platformName":"Android","appium:automationName":"Espresso","appium:forceEspressoRebuild":true,"appium:showGradleLog":true,"appium:app":"https://github.com/appium/appium/raw/master/packages/appium/sample-code/apps/ApiDemos-debug.apk"}')
4+
System.setProperty('injected.selenium.context.platform', 'android')
5+
System.setProperty('injected.selenium.grid.examples', 'false')
76
dependencies {
87
api('io.appium:java-client') {
98
exclude group: 'org.seleniumhq.selenium', module: 'selenium-java'

firefoxDeps.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
2-
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.FirefoxPlugin' + File.pathSeparator)
3-
System.setProperty('selenium.browser.name', 'firefox')
4-
System.setProperty('selenium.context.platform', 'web-app')
2+
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.FirefoxPlugin' + File.pathSeparator)
3+
System.setProperty('injected.selenium.browser.name', 'firefox')
4+
System.setProperty('injected.selenium.context.platform', 'web-app')
55
dependencies {
66
testImplementation('org.seleniumhq.selenium:selenium-firefox-driver') {
77
exclude module: 'selenium-remote-driver'

htmlunitDeps.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
2-
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.HtmlUnitPlugin' + File.pathSeparator)
3-
System.setProperty('selenium.browser.name', 'htmlunit')
4-
System.setProperty('selenium.context.platform', 'web-app')
2+
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.HtmlUnitPlugin' + File.pathSeparator)
3+
System.setProperty('injected.selenium.browser.name', 'htmlunit')
4+
System.setProperty('injected.selenium.context.platform', 'web-app')
55
dependencies {
66
if ("${profile}" == "selenium4") {
77
testImplementation 'com.nordstrom.ui-tools:htmlunit-remote'

mac2Deps.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
2-
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.Mac2Plugin' + File.pathSeparator)
3-
System.setProperty('selenium.browser.caps', '{"platformName":"Mac","appium:automationName":"Mac2","appium:bundleId":"com.apple.TextEdit"}')
4-
System.setProperty('selenium.context.platform', 'mac-app')
5-
System.setProperty('selenium.grid.examples', 'false')
6-
System.setProperty('appium.with.pm2', 'true')
2+
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.Mac2Plugin' + File.pathSeparator)
3+
System.setProperty('injected.selenium.browser.caps', '{"platformName":"Mac","appium:automationName":"Mac2","appium:bundleId":"com.apple.TextEdit"}')
4+
System.setProperty('injected.selenium.context.platform', 'mac-app')
5+
System.setProperty('injected.selenium.grid.examples', 'false')
6+
System.setProperty('injected.appium.with.pm2', 'true')
77
dependencies {
88
api('io.appium:java-client') {
99
exclude group: 'org.seleniumhq.selenium', module: 'selenium-java'

operaDeps.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
2-
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.OperaPlugin' + File.pathSeparator)
3-
System.setProperty('selenium.browser.name', 'opera')
4-
System.setProperty('selenium.context.platform', 'web-app')
2+
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.OperaPlugin' + File.pathSeparator)
3+
System.setProperty('injected.selenium.browser.name', 'opera')
4+
System.setProperty('injected.selenium.context.platform', 'web-app')
55
dependencies {
66
testImplementation('org.seleniumhq.selenium:selenium-opera-driver') {
77
exclude module: 'selenium-remote-driver'

phantomjsDeps.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
2-
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.PhantomJsPlugin' + File.pathSeparator)
3-
System.setProperty('selenium.browser.name', 'phantomjs')
4-
System.setProperty('selenium.context.platform', 'web-app')
2+
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.PhantomJsPlugin' + File.pathSeparator)
3+
System.setProperty('injected.selenium.browser.name', 'phantomjs')
4+
System.setProperty('injected.selenium.context.platform', 'web-app')
55
dependencies {
66
testImplementation('com.codeborne:phantomjsdriver') {
77
exclude group: 'org.seleniumhq.selenium', module: 'selenium-remote-driver'

safariDeps.gradle

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
2-
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.SafariPlugin' + File.pathSeparator)
3-
System.setProperty('selenium.browser.name', 'safari')
4-
System.setProperty('selenium.context.platform', 'web-app')
2+
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.SafariPlugin' + File.pathSeparator)
3+
System.setProperty('injected.selenium.browser.name', 'safari')
4+
System.setProperty('injected.selenium.context.platform', 'web-app')
55
dependencies {
66
testImplementation('org.seleniumhq.selenium:selenium-safari-driver') {
77
exclude module: 'selenium-remote-driver'

0 commit comments

Comments
 (0)