2. Cloud Browser Testing
• Each browser has behavioral quirks
• Often the same page will behave differently in different
browsers (Chrome, FireFox, Safari, Internet Explorer)
• Some behaviors will vary based on the browser version
or operating system
• Test all of them!
• But that’s a lot of work… cloud services to the rescue
3. Sauce Labs/BrowserStack
• Services that provide access to VM-based browsers
on demand
• Provide support for secure tunneling to test apps
within your firewall
• Easy to test lots of browser/version/OS combinations
• https://saucelabs.com
• https://www.browserstack.com
4. Geb
• Library for browser automation in Groovy
• Powered by WebDriver
• Often used with Spock/JUnit/TestNG
• www.gebish.org
5. Geb Config
BrowserStackDriverFactory
• Sets up a connection to the cloud service with a browser configuration
• «browser»:«operating system»:«version»
def browserStackBrowser = System.getProperty("geb.browserstack.browser")
if (browserStackBrowser) {
driver = {
def username = System.getenv("GEB_BROWSERSTACK_USERNAME")
def accessKey = System.getenv("GEB_BROWSERSTACK_AUTHKEY")
new BrowserStackDriverFactory().create(browserStackBrowser, username, accessKey)
}
}
SauceLabsDriverFactory is very similar
6. Gradle Config
Gradle geb-browserstack Plugin
• Open manages secure tunnel for local testing
• Configures tasks for different browser specifications
• Example: firefoxMac19Test, chromeMacTest, internetExplorerWindows9Test... and
allBrowserStackTests
apply plugin: "geb-browserstack"
buildscript {
repositories { mavenCentral() }
dependencies { classpath ‘org.gebish:geb-gradle:@geb-version@' }
}
browserStack {
application 'http://localhost:8080'
browsers {
firefox_mac_19
chrome_mac
internetExplorer_windows_9
}
task {
testClassesDir = test.testClassesDir
testSrcDirs = test.testSrcDirs
classpath = test.classpath
}
account {
username = System.getenv(BrowserStackAccount.USER_ENV_VAR)
accessKey = System.getenv(BrowserStackAccount.ACCESS_KEY_ENV_VAR)
}
}
Gradle geb-saucelabs Plugin is very similar