Skip to content

Commit

Permalink
Add profiles for easy cross-browser unit testing (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbabcoc authored Jan 1, 2023
1 parent a8408bc commit 39b4439
Show file tree
Hide file tree
Showing 16 changed files with 477 additions and 89 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ dependencies {
api 'com.nordstrom.tools:junit-foundation:17.0.2'
api 'com.github.sbabcoc:logback-testng:2.0.0'
api 'org.hamcrest:hamcrest-core:2.2'
api 'org.yaml:snakeyaml:1.30'
api 'org.yaml:snakeyaml:1.32'
}
api 'com.nordstrom.tools:java-utils'
api 'com.nordstrom.tools:settings'
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
profile=selenium3
version=26.6.1-SNAPSHOT
version=26.7.0-SNAPSHOT
org.gradle.java.installations.auto-detect=false
org.gradle.java.installations.auto-download=false
org.gradle.java.installations.fromEnv=JDK8_HOME,JDK11_HOME
91 changes: 82 additions & 9 deletions mvn-build.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,98 @@
#!/bin/bash
error_exit()
{
echo
echo "$1" 1>&2
usage
exit 1
}

. gradle.properties
usage()
{
echo
echo "Usage: $0 [options...]" >&2
echo
echo " -b <browser> {chrome|edge|espresso|firefox|htmlunit|mac2|opera|phantomjs|safari|uiautomator2|windows|xcuitest}"
echo " -h run in 'headless' mode (only supported by Chrome, Edge, and Firefox)"
echo
echo "The browser-less support tests are executed if no options are specified"
}

. gradle.properties > /dev/null 2>&1
if [[ ! "${version}" =~ -SNAPSHOT$ ]]; then
error_exit "not snapshot version: ${version}"
fi

while getopts p: flag
revision=${version/-/-s3-}

while getopts :b:h flag
do
case "${flag}" in
p) profile=${OPTARG};;
b)
browser=${OPTARG}
;;
h)
headless='.headless'
;;

*)
error_exit "unsupported option: ${OPTARG}"
;;
esac
done
case "${profile}" in
selenium2) seleniumApi=s2;;
selenium3) seleniumApi=s3;;
*) error_exit "unknown profile: ${profile}";;

case "${browser}" in
htmlunit|opera|phantomjs|safari)
targetPlatform=web-app
browserProfile=-P${browser}
seleniumSettings=("-Dselenium.browser.name=${browser}")
;;

chrome|firefox)
targetPlatform=web-app
browserProfile="-P${browser}"
seleniumSettings=("-Dselenium.browser.name=${browser}${headless}")
;;

edge)
targetPlatform=web-app
browserProfile=-Pedge
seleniumSettings=("-Dselenium.browser.name=MicrosoftEdge${headless}")
;;

espresso)
targetPlatform=android
browserProfile=-Pespresso
seleniumSettings=(-Dselenium.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"}' -Dselenium.grid.examples=false)
;;

uiautomator2)
targetPlatform=android
browserProfile=-Puiautomator2
seleniumSettings=(-Dselenium.browser.caps='{"platformName":"Android","appium:automationName":"UiAutomator2","appium:app":"https://github.com/appium/appium/raw/master/packages/appium/sample-code/apps/ApiDemos-debug.apk"}' -Dselenium.grid.examples=false)
;;

xcuitest)
targetPlatform=ios-app
browserProfile=-Pxcuitest
seleniumSettings=(-Dselenium.browser.caps='{"platformName":"iOS","appium:automationName":"XCUITest","appium:app":"https://github.com/appium/appium/raw/master/packages/appium/sample-code/apps/TestApp.app.zip"}' -Dselenium.grid.examples=false)
;;

mac2)
targetPlatform=mac-app
browserProfile=-Pmac2
seleniumSettings=(-Dselenium.browser.caps='{"platformName":"Mac","appium:automationName":"Mac2","appium:app":"/Applications/TextEdit"}' -Dselenium.grid.examples=false)
;;

windows)
targetPlatform=windows
browserProfile=-Pwindows
seleniumSettings=(-Dselenium.browser.caps='{"platformName":"Windows","appium:automationName":"Windows","appium:app":"C:/Windows/system32/notepad.exe"}' -Dselenium.grid.examples=false)
;;

*)
targetPlatform=support
;;
esac
revision=${version/-/-${seleniumApi}-}
mvn -Drevision=${revision} clean install -P${profile}

mvn "-Drevision=${revision}" clean install -Pselenium3 ${browserProfile} "-Dselenium.context.platform=${targetPlatform}" "${seleniumSettings[@]}"
Loading

0 comments on commit 39b4439

Please sign in to comment.