Skip to content

Commit

Permalink
#71: Add better Appium support
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Pfotenhauer committed Feb 14, 2019
1 parent 902b36e commit a72ca1b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 61 deletions.
14 changes: 11 additions & 3 deletions config/browser.properties
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,20 @@ browserprofile.Galaxy_Note3_Emulation.name Samsung Galaxy Note 3 Chrome Emulatio
browserprofile.Galaxy_Note3_Emulation.browser = chrome
browserprofile.Galaxy_Note3_Emulation.chromeEmulationProfile = Samsung Galaxy Note 3


browserprofile.iphone8.name = iphone 8 on saucelabs
browserprofile.GalaxyS9.name = Samsung Galaxy S9 on SauceLabs
browserprofile.GalaxyS9.browser = Android
browserprofile.GalaxyS9.browserName = Chrome
browserprofile.GalaxyS9.platformName = Android
browserprofile.GalaxyS9.platformVersion = 7.1
browserprofile.GalaxyS9.deviceName = Samsung Galaxy S9 WQHD GoogleAPI Emulator
browserprofile.GalaxyS9.deviceOrientation = portrait
browserprofile.GalaxyS9.testEnvironment = saucelabs

browserprofile.iphone8.name = iPhone 8 on SauceLabs
browserprofile.iphone8.browser = iphone
browserprofile.iphone8.browserName = Safari
browserprofile.iphone8.platformName = iOS
browserprofile.iphone8.platformVersion = 11.0
browserprofile.iphone8.platformVersion = 12.0
browserprofile.iphone8.deviceName = iPhone 8
browserprofile.iphone8.deviceOrientation = portrait
browserprofile.iphone8.testEnvironment = saucelabs
Expand Down
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,6 @@
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.0.0</version>
</dependency>


<!-- Test only dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.openqa.selenium.remote.BrowserType;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.CommandInfo;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.HttpCommandExecutor;
import org.openqa.selenium.remote.RemoteWebDriver;

Expand All @@ -42,27 +41,17 @@
import com.xceptance.neodymium.module.statement.browser.multibrowser.configuration.TestEnvironment;
import com.xceptance.neodymium.util.Neodymium;

import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.ios.IOSDriver;

public final class BrowserRunnerHelper
{
private static List<String> androidBrowsers = new LinkedList<String>();

private static List<String> chromeBrowsers = new LinkedList<String>();

private static List<String> firefoxBrowsers = new LinkedList<String>();

private static List<String> internetExplorerBrowsers = new LinkedList<String>();

private static List<String> iPhoneBrowsers = new LinkedList<String>();

private static List<String> iPadBrowsers = new LinkedList<String>();

static
{
androidBrowsers.add(BrowserType.ANDROID);

chromeBrowsers.add(BrowserType.ANDROID);
chromeBrowsers.add(BrowserType.CHROME);

firefoxBrowsers.add(BrowserType.FIREFOX);
Expand All @@ -73,9 +62,6 @@ public final class BrowserRunnerHelper
internetExplorerBrowsers.add(BrowserType.IE_HTA);
internetExplorerBrowsers.add(BrowserType.IEXPLORE);
internetExplorerBrowsers.add(BrowserType.IEXPLORE_PROXY);

iPhoneBrowsers.add(BrowserType.IPHONE);
iPadBrowsers.add(BrowserType.IPAD);
}

/**
Expand Down Expand Up @@ -302,28 +288,6 @@ else if (internetExplorerBrowsers.contains(browserName))

return new InternetExplorerDriver(options);
}
else if (androidBrowsers.contains(browserName))
{
DesiredCapabilities options = DesiredCapabilities.android();
options.merge(capabilities);

return new AndroidDriver<>(options);
}
else if (iPhoneBrowsers.contains(browserName))
{
DesiredCapabilities options = DesiredCapabilities.iphone();
options.merge(capabilities);

return new IOSDriver<>(options);

}
else if (iPadBrowsers.contains(browserName))
{
DesiredCapabilities options = DesiredCapabilities.ipad();
options.merge(capabilities);

return new IOSDriver<>(options);
}
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.safari.SafariOptions;

import io.appium.java_client.remote.MobileCapabilityType;

public class BrowserConfigurationMapper
{
private static final String BROWSER = "browser";
Expand Down Expand Up @@ -45,14 +43,14 @@ public class BrowserConfigurationMapper

private static final String ARGUMENTS = "arguments";

// appium specific propertys
// Appium specific properties
private static final String APPIUM_VERSION = "appiumVersion";

private static final String BROWSER_NAME = "browserName";

private static final String PLATFORM_NAME = "platformName";

private static final String PLATTFORM_VERSION = "platformVersion";
private static final String PLATFORM_VERSION = "platformVersion";

private static final String APP = "app";

Expand Down Expand Up @@ -116,10 +114,11 @@ else if ("opera".equals(emulatedBrowser))
*/
String emulatedPlatform = browserProfileConfiguration.get(PLATFORM);
if (!StringUtils.isEmpty(emulatedPlatform))
{
capabilities.setCapability(CapabilityType.PLATFORM, emulatedPlatform);
capabilities.setCapability(CapabilityType.PLATFORM_NAME, emulatedPlatform);
}

String emulatedPlatformName = browserProfileConfiguration.get(PLATFORM_NAME);
if (!StringUtils.isEmpty(emulatedPlatformName))
capabilities.setCapability(CapabilityType.PLATFORM_NAME, emulatedPlatformName);

String emulatedVersion = browserProfileConfiguration.get(BROWSER_VERSION);
if (!StringUtils.isEmpty(emulatedVersion))
Expand All @@ -141,31 +140,31 @@ else if ("opera".equals(emulatedBrowser))

String appiumVersion = browserProfileConfiguration.get(APPIUM_VERSION);
if (!StringUtils.isEmpty(appiumVersion))
capabilities.setCapability(MobileCapabilityType.APPIUM_VERSION, appiumVersion);
capabilities.setCapability(APPIUM_VERSION, appiumVersion);

String browserName = browserProfileConfiguration.get(BROWSER_NAME);
if (!StringUtils.isEmpty(browserName))
capabilities.setCapability(CapabilityType.BROWSER_NAME, browserName);
capabilities.setCapability(BROWSER_NAME, browserName);

String plattformVersion = browserProfileConfiguration.get(PLATTFORM_VERSION);
String plattformVersion = browserProfileConfiguration.get(PLATFORM_VERSION);
if (!StringUtils.isEmpty(plattformVersion))
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, plattformVersion);
capabilities.setCapability(PLATFORM_VERSION, plattformVersion);

String plattformName = browserProfileConfiguration.get(PLATFORM_NAME);
if (!StringUtils.isEmpty(plattformName))
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, plattformName);
capabilities.setCapability(PLATFORM_NAME, plattformName);

String app = browserProfileConfiguration.get(APP);
if (!StringUtils.isEmpty(app))
capabilities.setCapability(MobileCapabilityType.APP, app);
capabilities.setCapability(APP, app);

String automationName = browserProfileConfiguration.get(AUTOMATION_NAME);
if (!StringUtils.isEmpty(automationName))
capabilities.setCapability(MobileCapabilityType.AUTOMATION_NAME, automationName);
capabilities.setCapability(AUTOMATION_NAME, automationName);

String oriantation = browserProfileConfiguration.get(ORIENTATION);
if (!StringUtils.isEmpty(oriantation))
capabilities.setCapability(MobileCapabilityType.ORIENTATION, oriantation);
capabilities.setCapability(ORIENTATION, oriantation);

/*
* Chrome device emulation
Expand Down

0 comments on commit a72ca1b

Please sign in to comment.