diff options
author | Henri Sara <hesara@vaadin.com> | 2016-04-28 09:02:51 +0300 |
---|---|---|
committer | Henri Sara <hesara@vaadin.com> | 2016-04-28 09:26:46 +0300 |
commit | 98598f4f930da161849023917dd4e964cf8f0303 (patch) | |
tree | 0daaadd186d9dac9755a4211ada36ea5eaa09691 | |
parent | ae44989b05eed41de6b8ee54dd886ad01e89e78c (diff) | |
download | vaadin-framework-98598f4f930da161849023917dd4e964cf8f0303.tar.gz vaadin-framework-98598f4f930da161849023917dd4e964cf8f0303.zip |
Add browser factory for BrowserStack
Change-Id: Id761c99068410c9d00f2b2a124568e3c86d112d7
-rw-r--r-- | uitest/src/test/java/com/vaadin/tests/tb3/BrowserStackBrowserFactory.java | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/uitest/src/test/java/com/vaadin/tests/tb3/BrowserStackBrowserFactory.java b/uitest/src/test/java/com/vaadin/tests/tb3/BrowserStackBrowserFactory.java new file mode 100644 index 0000000000..326bcfdb3f --- /dev/null +++ b/uitest/src/test/java/com/vaadin/tests/tb3/BrowserStackBrowserFactory.java @@ -0,0 +1,128 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.tb3; + +import java.util.logging.Logger; + +import org.openqa.selenium.Platform; +import org.openqa.selenium.ie.InternetExplorerDriver; +import org.openqa.selenium.remote.DesiredCapabilities; + +import com.vaadin.shared.Version; +import com.vaadin.testbench.parallel.Browser; +import com.vaadin.testbench.parallel.DefaultBrowserFactory; + +/** + * Browser factory for the cloud test provider BrowserStack. + */ +public class BrowserStackBrowserFactory extends DefaultBrowserFactory { + + @Override + public DesiredCapabilities create(Browser browser, String version, + Platform platform) { + DesiredCapabilities caps; + + switch (browser) { + case CHROME: + caps = DesiredCapabilities.chrome(); + caps.setVersion(version); + break; + case PHANTOMJS: + throw new IllegalArgumentException( + "PhantomJS is not supported by BrowserStack"); + case SAFARI: + caps = DesiredCapabilities.safari(); + caps.setVersion(version); + break; + case IE8: + caps = DesiredCapabilities.internetExplorer(); + caps.setVersion("8"); + caps.setCapability("browser", "IE"); + caps.setCapability("browser_version", "8.0"); + caps.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, + true); + break; + case IE9: + caps = DesiredCapabilities.internetExplorer(); + caps.setVersion("9"); + caps.setCapability("browser", "IE"); + caps.setCapability("browser_version", "9.0"); + caps.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, + true); + break; + case IE10: + caps = DesiredCapabilities.internetExplorer(); + caps.setVersion("10"); + caps.setCapability("browser", "IE"); + caps.setCapability("browser_version", "10.0"); + caps.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, + true); + break; + case IE11: + caps = DesiredCapabilities.internetExplorer(); + caps.setVersion("11"); + caps.setCapability("browser", "IE"); + caps.setCapability("browser_version", "11.0"); + // There are 2 capabilities ie.ensureCleanSession and + // ensureCleanSession in Selenium + // IE 11 uses ie.ensureCleanSession + caps.setCapability("ie.ensureCleanSession", true); + caps.setCapability(InternetExplorerDriver.IE_ENSURE_CLEAN_SESSION, + true); + break; + case FIREFOX: + caps = DesiredCapabilities.firefox(); + caps.setVersion(version); + break; + default: + caps = DesiredCapabilities.firefox(); + caps.setVersion(version); + caps.setPlatform(platform); + } + + // BrowserStack specific parts + + // for now, run all tests on Windows 7 + caps.setCapability("os", "Windows"); + caps.setCapability("os_version", "7"); + caps.setPlatform(Platform.WINDOWS); + + // enable logging on BrowserStack + caps.setCapability("browserstack.debug", "true"); + + // tunnel + caps.setCapability("browserstack.local", "true"); + // optionally, could also set browserstack.localIdentifier if we have a + // tunnel name + + // build and project for easy identification in BrowserStack UI + caps.setCapability("project", "vaadin"); + caps.setCapability("build", Version.getFullVersion()); + + // accept self-signed certificates + caps.setCapability("acceptSslCerts", "true"); + + caps.setCapability("resolution", "1680x1050"); + + getLogger().info("Using BrowserStack capabilities " + caps); + + return caps; + } + + private static final Logger getLogger() { + return Logger.getLogger(BrowserStackBrowserFactory.class.getName()); + } +} |