Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 25 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@ if (project.hasProperty('browsers')) {
}
}

// if "personality" is specified
if (project.hasProperty('personality')) {
System.setProperty('selenium.browser.name', ext.personality)
// store "injected" browser name setting
System.setProperty('injected.selenium.browser.name', ext.personality)
// if target is a mobile browser
if ([".chrome", ".safari"].any { ext.personality.endsWith(it) }) {
// specify "web-app" as the injected default context platform
System.setProperty('injected.selenium.context.platform', 'web-app')
}
}

def archiveVer = null
Expand Down Expand Up @@ -123,30 +130,33 @@ javadocJar {
destinationDirectory = libsDir
}

tasks.withType(Test).configureEach {
// iterate over system properties
System.getProperties().each { key, val ->
// if this is a property that should be propagated to the test task
if (key.endsWith('.binary.path') || ['injected.', 'selenium.', 'appium.', 'testng.', 'junit.'].any { key.startsWith(it) }) {
// if running on Windows and this property defines JSON browser capabilities
if (OperatingSystem.current().isWindows() && key.endsWith('selenium.browser.caps')) {
// escape double quotes
val = val.replace('"', '\\\\"')
}
// propagate property
systemProperty key, val
}
}
}


task testNG(type: Test) {
useTestNG()
reports.html.destination = file("${buildDir}/reports/testng")
testLogging.showStandardStreams = true

systemProperty 'selenium.grid.plugins', System.getProperty('selenium.grid.plugins')
systemProperty 'selenium.browser.name', System.getProperty('selenium.browser.name')
systemProperty 'selenium.browser.caps', getBrowserCaps()
systemProperty 'selenium.context.platform', System.getProperty('selenium.context.platform', 'support')
systemProperty 'selenium.grid.examples', System.getProperty('selenium.grid.examples', 'true')
systemProperty 'appium.with.pm2', System.getProperty('appium.with.pm2', 'false')
}

test {
dependsOn testNG
reports.html.destination = file("${buildDir}/reports/junit")
testLogging.showStandardStreams = true

systemProperty 'selenium.grid.plugins', System.getProperty('selenium.grid.plugins')
systemProperty 'selenium.browser.name', System.getProperty('selenium.browser.name')
systemProperty 'selenium.browser.caps', getBrowserCaps()
systemProperty 'selenium.context.platform', System.getProperty('selenium.context.platform', 'support')
systemProperty 'selenium.grid.examples', System.getProperty('selenium.grid.examples', 'true')
systemProperty 'appium.with.pm2', System.getProperty('appium.with.pm2', 'false')
}

scmVersion {
Expand Down Expand Up @@ -259,11 +269,3 @@ test {
"-javaagent:${classpath.find { it.name.contains('junit-foundation') }.absolutePath}"
]
}

def getBrowserCaps() {
def browserCaps = System.getProperty('selenium.browser.caps')
if (browserCaps && OperatingSystem.current().isWindows()) {
return browserCaps.replaceAll('"', '\\\\"')
}
return browserCaps
}
6 changes: 3 additions & 3 deletions chromeDeps.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.ChromePlugin' + File.pathSeparator)
System.setProperty('selenium.browser.name', 'chrome')
System.setProperty('selenium.context.platform', 'web-app')
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.ChromePlugin' + File.pathSeparator)
System.setProperty('injected.selenium.browser.name', 'chrome')
System.setProperty('injected.selenium.context.platform', 'web-app')
dependencies {
testImplementation('org.seleniumhq.selenium:selenium-chrome-driver') {
exclude module: 'selenium-remote-driver'
Expand Down
6 changes: 3 additions & 3 deletions edgeDeps.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.EdgePlugin' + File.pathSeparator)
System.setProperty('selenium.browser.name', 'MicrosoftEdge')
System.setProperty('selenium.context.platform', 'web-app')
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.EdgePlugin' + File.pathSeparator)
System.setProperty('injected.selenium.browser.name', 'MicrosoftEdge')
System.setProperty('injected.selenium.context.platform', 'web-app')
dependencies {
testImplementation('org.seleniumhq.selenium:selenium-edge-driver') {
exclude module: 'selenium-remote-driver'
Expand Down
9 changes: 4 additions & 5 deletions espressoDeps.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.EspressoPlugin' + File.pathSeparator)
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"}')
System.setProperty('selenium.context.platform', 'android')
System.setProperty('selenium.grid.examples', 'false')
System.setProperty('appium.with.pm2', 'true')
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.EspressoPlugin' + File.pathSeparator)
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"}')
System.setProperty('injected.selenium.context.platform', 'android')
System.setProperty('injected.selenium.grid.examples', 'false')
dependencies {
api('io.appium:java-client') {
exclude group: 'org.seleniumhq.selenium', module: 'selenium-java'
Expand Down
6 changes: 3 additions & 3 deletions firefoxDeps.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.FirefoxPlugin' + File.pathSeparator)
System.setProperty('selenium.browser.name', 'firefox')
System.setProperty('selenium.context.platform', 'web-app')
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.FirefoxPlugin' + File.pathSeparator)
System.setProperty('injected.selenium.browser.name', 'firefox')
System.setProperty('injected.selenium.context.platform', 'web-app')
dependencies {
testImplementation('org.seleniumhq.selenium:selenium-firefox-driver') {
exclude module: 'selenium-remote-driver'
Expand Down
6 changes: 3 additions & 3 deletions htmlunitDeps.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.HtmlUnitPlugin' + File.pathSeparator)
System.setProperty('selenium.browser.name', 'htmlunit')
System.setProperty('selenium.context.platform', 'web-app')
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.HtmlUnitPlugin' + File.pathSeparator)
System.setProperty('injected.selenium.browser.name', 'htmlunit')
System.setProperty('injected.selenium.context.platform', 'web-app')
dependencies {
if ("${profile}" == "selenium4") {
testImplementation 'com.nordstrom.ui-tools:htmlunit-remote'
Expand Down
10 changes: 5 additions & 5 deletions mac2Deps.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.Mac2Plugin' + File.pathSeparator)
System.setProperty('selenium.browser.caps', '{"platformName":"Mac","appium:automationName":"Mac2","appium:bundleId":"com.apple.TextEdit"}')
System.setProperty('selenium.context.platform', 'mac-app')
System.setProperty('selenium.grid.examples', 'false')
System.setProperty('appium.with.pm2', 'true')
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.Mac2Plugin' + File.pathSeparator)
System.setProperty('injected.selenium.browser.caps', '{"platformName":"Mac","appium:automationName":"Mac2","appium:bundleId":"com.apple.TextEdit"}')
System.setProperty('injected.selenium.context.platform', 'mac-app')
System.setProperty('injected.selenium.grid.examples', 'false')
System.setProperty('injected.appium.with.pm2', 'true')
dependencies {
api('io.appium:java-client') {
exclude group: 'org.seleniumhq.selenium', module: 'selenium-java'
Expand Down
6 changes: 3 additions & 3 deletions operaDeps.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.OperaPlugin' + File.pathSeparator)
System.setProperty('selenium.browser.name', 'opera')
System.setProperty('selenium.context.platform', 'web-app')
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.OperaPlugin' + File.pathSeparator)
System.setProperty('injected.selenium.browser.name', 'opera')
System.setProperty('injected.selenium.context.platform', 'web-app')
dependencies {
testImplementation('org.seleniumhq.selenium:selenium-opera-driver') {
exclude module: 'selenium-remote-driver'
Expand Down
6 changes: 3 additions & 3 deletions phantomjsDeps.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.PhantomJsPlugin' + File.pathSeparator)
System.setProperty('selenium.browser.name', 'phantomjs')
System.setProperty('selenium.context.platform', 'web-app')
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.PhantomJsPlugin' + File.pathSeparator)
System.setProperty('injected.selenium.browser.name', 'phantomjs')
System.setProperty('injected.selenium.context.platform', 'web-app')
dependencies {
testImplementation('com.codeborne:phantomjsdriver') {
exclude group: 'org.seleniumhq.selenium', module: 'selenium-remote-driver'
Expand Down
6 changes: 3 additions & 3 deletions safariDeps.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.SafariPlugin' + File.pathSeparator)
System.setProperty('selenium.browser.name', 'safari')
System.setProperty('selenium.context.platform', 'web-app')
System.setProperty('injected.selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.SafariPlugin' + File.pathSeparator)
System.setProperty('injected.selenium.browser.name', 'safari')
System.setProperty('injected.selenium.context.platform', 'web-app')
dependencies {
testImplementation('org.seleniumhq.selenium:selenium-safari-driver') {
exclude module: 'selenium-remote-driver'
Expand Down
4 changes: 2 additions & 2 deletions selenium4Deps.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ dependencies {
api 'org.seleniumhq.selenium:selenium-firefox-driver:4.38.0'
api 'org.seleniumhq.selenium:selenium-opera-driver:4.4.0'
api 'org.seleniumhq.selenium:selenium-safari-driver:4.38.0'
api 'com.nordstrom.ui-tools:htmlunit-remote:4.38.0'
api 'org.seleniumhq.selenium:htmlunit3-driver:4.38.0'
api 'com.nordstrom.ui-tools:htmlunit-remote:4.39.0-SNAPSHOT'
api 'org.seleniumhq.selenium:htmlunit3-driver:4.39.0-SNAPSHOT'
api 'org.htmlunit:htmlunit:4.18.0'
api 'com.codeborne:phantomjsdriver:1.5.0'
api 'org.apache.httpcomponents:httpclient:4.5.14'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,11 @@ protected Map<String, String> getDefaults() {
defaults.put(SeleniumSettings.NODE_BINARY_PATH.key(), nodePath);
}

// propagate "injected" settings, which take precedence over default values
System.getProperties().entrySet().stream()
.filter(e -> e.getKey().toString().startsWith("injected."))
.collect(Collectors.toMap(e -> e.getKey().toString().substring(9), e -> e.getValue()));

return defaults;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,22 @@ private HtmlUnitCaps() {
"\"pluginClass\":\"com.nordstrom.automation.selenium.plugins.HtmlUnitPlugin\"}}";

private static final String CHROME =
"{\"browserName\":\"htmlunit\",\"browserVersion\":\"chrome\"," +
"{\"browserName\":\"htmlunit\",\"garg:browserVersion\":\"chrome\"," +
"\"nord:options\":{\"personality\":\"htmlunit.chrome\"," +
"\"pluginClass\":\"com.nordstrom.automation.selenium.plugins.HtmlUnitPlugin\"}}";

private static final String EDGE =
"{\"browserName\":\"htmlunit\",\"garg:browserVersion\":\"edge\"," +
"\"nord:options\":{\"personality\":\"htmlunit.edge\"," +
"\"pluginClass\":\"com.nordstrom.automation.selenium.plugins.HtmlUnitPlugin\"}}";

private static final String FIREFOX =
"{\"browserName\":\"htmlunit\",\"browserVersion\":\"firefox\"," +
"{\"browserName\":\"htmlunit\",\"garg:browserVersion\":\"firefox\"," +
"\"nord:options\":{\"personality\":\"htmlunit.firefox\"," +
"\"pluginClass\":\"com.nordstrom.automation.selenium.plugins.HtmlUnitPlugin\"}}";

private static final String INT_EXP =
"{\"browserName\":\"htmlunit\",\"browserVersion\":\"ie\"," +
"{\"browserName\":\"htmlunit\",\"garg:browserVersion\":\"ie\"," +
"\"nord:options\":{\"personality\":\"htmlunit.ie\"," +
"\"pluginClass\":\"com.nordstrom.automation.selenium.plugins.HtmlUnitPlugin\"}}";

Expand All @@ -55,6 +60,7 @@ private HtmlUnitCaps() {
Map<String, String> personalities = new HashMap<>();
personalities.put(DRIVER_NAME, BASELINE);
personalities.put(DRIVER_NAME + ".chrome", CHROME);
personalities.put(DRIVER_NAME + ".edge", EDGE);
personalities.put(DRIVER_NAME + ".firefox", FIREFOX);
personalities.put(DRIVER_NAME + ".ie", INT_EXP);
personalities.put(DRIVER_NAME + ".nojs", NO_JS);
Expand Down
7 changes: 3 additions & 4 deletions uiautomator2Deps.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.UiAutomator2Plugin' + File.pathSeparator)
System.setProperty('selenium.browser.caps', '{"platformName":"Android","appium:automationName":"UiAutomator2","appium:app":"https://github.com/appium/appium/raw/master/packages/appium/sample-code/apps/ApiDemos-debug.apk"}')
System.setProperty('selenium.context.platform', 'android')
System.setProperty('selenium.grid.examples', 'false')
System.setProperty('appium.with.pm2', 'true')
System.setProperty('injected.selenium.browser.caps', '{"platformName":"Android","appium:automationName":"UiAutomator2","appium:app":"https://github.com/appium/appium/raw/master/packages/appium/sample-code/apps/ApiDemos-debug.apk"}')
System.setProperty('injected.selenium.context.platform', 'android')
System.setProperty('injected.selenium.grid.examples', 'false')
dependencies {
api('io.appium:java-client') {
exclude group: 'org.seleniumhq.selenium', module: 'selenium-java'
Expand Down
8 changes: 4 additions & 4 deletions windowsDeps.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.WindowsPlugin' + File.pathSeparator)
System.setProperty('selenium.browser.caps', '{"platformName":"Windows","appium:automationName":"Windows","appium:app":"C:/Windows/system32/notepad.exe"}')
System.setProperty('selenium.context.platform', 'windows')
System.setProperty('selenium.grid.examples', 'false')
System.setProperty('appium.with.pm2', 'true')
System.setProperty('injected.selenium.browser.caps', '{"platformName":"Windows","appium:automationName":"Windows","appium:app":"C:/Windows/system32/notepad.exe"}')
System.setProperty('injected.selenium.context.platform', 'windows')
System.setProperty('injected.selenium.grid.examples', 'false')
System.setProperty('injected.appium.with.pm2', 'true')
dependencies {
api('io.appium:java-client') {
exclude group: 'org.seleniumhq.selenium', module: 'selenium-java'
Expand Down
7 changes: 3 additions & 4 deletions xcuitestDeps.gradle
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
def driverPlugins = System.getProperty('selenium.grid.plugins', '')
System.setProperty('selenium.grid.plugins', driverPlugins + 'com.nordstrom.automation.selenium.plugins.XCUITestPlugin' + File.pathSeparator)
System.setProperty('selenium.browser.caps', '{"platformName":"iOS","appium:automationName":"XCUITest","appium:app":"https://github.com/appium/appium/raw/master/packages/appium/sample-code/apps/TestApp.app.zip"}')
System.setProperty('selenium.context.platform', 'ios-app')
System.setProperty('selenium.grid.examples', 'false')
System.setProperty('appium.with.pm2', 'true')
System.setProperty('injected.selenium.browser.caps', '{"platformName":"iOS","appium:automationName":"XCUITest","appium:app":"https://github.com/appium/appium/raw/master/packages/appium/sample-code/apps/TestApp.app.zip"}')
System.setProperty('injected.selenium.context.platform', 'ios-app')
System.setProperty('injected.selenium.grid.examples', 'false')
dependencies {
api('io.appium:java-client') {
exclude group: 'org.seleniumhq.selenium', module: 'selenium-java'
Expand Down