Skip to content

Commit

Permalink
common interface for android and ios
Browse files Browse the repository at this point in the history
  1. adding a common interface for both android and ios objects
  2. changing yaml reader and code generator to  support new interface and yaml files.
  3. add more elements to Android elements.
  4. add parameters to config Mobile annotation parameters from suite and command line.
  5. changing appium config builder to support selenium grid with multiple appium client nodes.
  6. creating new android test app that match with ios test app to be able to test common interface.
  7. adding test suites and test cases for testing common interface and updating old testcases to be able to work with new one.
  • Loading branch information
alizelzele committed Mar 30, 2016
1 parent 69f5a6c commit d735cb8
Show file tree
Hide file tree
Showing 113 changed files with 3,298 additions and 1,078 deletions.
21 changes: 21 additions & 0 deletions client/src/main/java/com/paypal/selion/configuration/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,21 @@ public enum ConfigProperty {
*/
MOBILE_APP_LOCALE("mobileAppLocale", "en_US", false),

/**
* This parameter represents the appium device.
*/
MOBILE_DEVICE("mobileDevice", "", false),

/**
* This parameter represents the appium device platform version.
*/
MOBILE_PLATFORM_VERSION("mobilePlatformVersion", "", false),

/**
* This parameter represents the appium device type.
*/
MOBILE_DEVICE_TYPE("mobileDeviceType", "", false),

/**
* Use this parameter to provide SeLion with a custom element listener that implements
* {@link ElementEventListener}. SeLion will invoke the custom implementation when the relevant events happen.
Expand Down Expand Up @@ -525,6 +540,12 @@ public enum ConfigProperty {
*/
SITE_LOCALE("siteLocale", "US", false),

/**
* Site will show country used for tests.<br>
* Default is set to <b>UNDEFINED</b>
*/
MOBILE_PLATFORM("mobilePlatform", "UNDEFINED", false),

/**
* Browser specified by user.<br>
* Default is set to <b>firefox</b>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-------------------------------------------------------------------------------------------------------------------*\
| Copyright (C) 2014-15 PayPal |
| Copyright (C) 2014-2016 PayPal |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| with the License. |
Expand Down Expand Up @@ -149,6 +149,18 @@ public void initializeTestSession(InvokedMethodInformation method) {
appLanguage = getLocalConfigProperty(ConfigProperty.MOBILE_APP_LANGUAGE);
}

if (StringUtils.isNotBlank(getLocalConfigProperty(ConfigProperty.MOBILE_DEVICE))) {
device = getLocalConfigProperty(ConfigProperty.MOBILE_DEVICE);
}

if (StringUtils.isNotBlank(getLocalConfigProperty(ConfigProperty.MOBILE_PLATFORM_VERSION))) {
platformVersion = getLocalConfigProperty(ConfigProperty.MOBILE_PLATFORM_VERSION);
}

if (StringUtils.isNotBlank(getLocalConfigProperty(ConfigProperty.MOBILE_DEVICE_TYPE))) {
deviceType = getLocalConfigProperty(ConfigProperty.MOBILE_DEVICE_TYPE);
}

// Override values when supplied via the annotation
if (deviceTestAnnotation != null) {
if (StringUtils.isNotBlank(deviceTestAnnotation.appName())) {
Expand Down Expand Up @@ -233,7 +245,7 @@ private String getSelionHubStorageUrl(String selionHubAppPath) {
String appPathTokens[] = StringUtils.split(selionHubAppPath, ":");
String hostName = Config.getConfigProperty(ConfigProperty.SELENIUM_HOST);
int port = Integer.parseInt(Config.getConfigProperty(ConfigProperty.SELENIUM_PORT));
StringBuffer url = new StringBuffer("http://");
StringBuilder url = new StringBuilder("http://");
url.append(hostName);
url.append(COLON);
url.append(port);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-------------------------------------------------------------------------------------------------------------------*\
| Copyright (C) 2015 PayPal |
| Copyright (C) 2015-2016 PayPal |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| with the License. |
Expand All @@ -18,6 +18,7 @@
import io.appium.java_client.remote.MobileCapabilityType;

import org.apache.commons.lang.StringUtils;
import org.openqa.selenium.Platform;
import org.openqa.selenium.remote.DesiredCapabilities;

import com.paypal.selion.internal.platform.grid.MobileTestSession;
Expand All @@ -44,14 +45,19 @@ public DesiredCapabilities getCapabilities(DesiredCapabilities capabilities) {
}
capabilities.setCapability(MOBILE_NODE_TYPE, mobileSession.getMobileNodeType().getAsString());
capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, mobileSession.getDeviceType());
if (mobileSession.getDeviceType() != null) {
capabilities.setBrowserName(mobileSession.getDeviceType().toLowerCase());
}
capabilities.setCapability(MobileCapabilityType.PLATFORM_VERSION, mobileSession.getPlatformVersion());
capabilities.setCapability(APPIUM_LOCALE_TYPE, mobileSession.getAppLocale());
capabilities.setCapability(APPIUM_LANGUAGE_TYPE, mobileSession.getAppLanguage());
if (mobileSession.getPlatform() == WebDriverPlatform.ANDROID) {
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, APPIUM_ANDROID_PLATFORM_TYPE);
capabilities.setPlatform(Platform.ANDROID);
}
if (mobileSession.getPlatform() == WebDriverPlatform.IOS) {
capabilities.setCapability(MobileCapabilityType.PLATFORM_NAME, APPIUM_IOS_PLATFORM_TYPE);
capabilities.setPlatform(Platform.MAC);
}

return capabilities;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-------------------------------------------------------------------------------------------------------------------*\
| Copyright (C) 2014 PayPal |
| Copyright (C) 2014-2016 PayPal |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| with the License. |
Expand All @@ -15,6 +15,8 @@

package com.paypal.selion.internal.platform.pageyaml;

import com.paypal.selion.internal.platform.grid.WebDriverPlatform;

import java.util.List;
import java.util.Map;

Expand All @@ -31,8 +33,9 @@ public interface GuiMapReader {

Map<String, String> getGuiMap(String locale);

Map<String,String> getGuiMap(String locale, WebDriverPlatform platform);

Map<String, String> getGuiMapForContainer(String containerKey, String locale);

List<String> getPageValidators();

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-------------------------------------------------------------------------------------------------------------------*\
| Copyright (C) 2014-15 PayPal |
| Copyright (C) 2014-2016 PayPal |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| with the License. |
Expand All @@ -25,6 +25,7 @@
import java.util.logging.Level;

import com.google.common.collect.Lists;
import com.paypal.selion.internal.platform.grid.WebDriverPlatform;
import com.paypal.selion.platform.dataprovider.impl.FileSystemResource;

/**
Expand Down Expand Up @@ -63,7 +64,7 @@ public YamlV1Reader(String fileName) throws IOException {
public Map<String, String> getGuiMap(String locale) {
logger.entering(locale);

Map<String, String> instanceMap = new HashMap<String, String>();
Map<String, String> instanceMap = new HashMap<>();
List<Object> allObj = getAllObjects();

for (Object temp : allObj) {
Expand All @@ -84,6 +85,11 @@ public Map<String, String> getGuiMap(String locale) {
return instanceMap;
}

@Override
public Map<String, String> getGuiMap(String locale, WebDriverPlatform platform) {
return getGuiMap(locale);
}

/**
* The user needs to provide the locale for which data needs to be read. After successfully reading the data from
* the input stream, it is placed in the hash map and returned to the users.
Expand All @@ -98,7 +104,7 @@ public Map<String, String> getGuiMap(String locale) {
public Map<String, String> getGuiMapForContainer(String containerKey, String locale) {
logger.entering(new Object[] { containerKey, locale });

Map<String, String> instanceMap = new HashMap<String, String>();
Map<String, String> instanceMap = new HashMap<>();
List<Object> allObj = getAllObjects();

for (Object temp : allObj) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-------------------------------------------------------------------------------------------------------------------*\
| Copyright (C) 2014-15 PayPal |
| Copyright (C) 2014-2016 PayPal |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| with the License. |
Expand All @@ -24,6 +24,7 @@
import java.util.Map.Entry;
import java.util.logging.Level;

import com.paypal.selion.internal.platform.grid.WebDriverPlatform;
import com.paypal.selion.platform.dataprovider.impl.FileSystemResource;
import com.paypal.selion.platform.web.GUIElement;
import com.paypal.selion.platform.web.HtmlContainerElement;
Expand Down Expand Up @@ -63,9 +64,18 @@ public YamlV2Reader(String fileName) throws IOException {
@SuppressWarnings("unchecked")
@Override
public Map<String, String> getGuiMap(String locale) {
logger.entering(locale);
return getGuiMap(locale, WebDriverPlatform.UNDEFINED);
}

Map<String, String> instanceMap = new HashMap<String, String>();
@Override
public Map<String, String> getGuiMap(String locale, WebDriverPlatform platform) {
if (platform.equals(WebDriverPlatform.UNDEFINED)) {
logger.entering(locale);
} else {
logger.entering(platform, locale);
}

Map<String, String> instanceMap = new HashMap<>();
List<Object> allObj = getAllObjects();

for (Object temp : allObj) {
Expand All @@ -75,7 +85,13 @@ public Map<String, String> getGuiMap(String locale) {
+ "the Yaml file. Ignoring the Null document.");
continue;
}
String value = map.get(locale);
String value = map.get(platform + "--" + locale);
if (value == null) {
value = map.get(locale);
}
if (value == null) {
value = map.get(platform + "--" + getDefaultLocale());
}
if (value == null) {
value = map.get(getDefaultLocale());
}
Expand All @@ -100,7 +116,7 @@ public Map<String, String> getGuiMap(String locale) {
public Map<String, String> getGuiMapForContainer(String containerKey, String locale) {
logger.entering(new Object[] { containerKey, locale });

Map<String, String> instanceMap = new HashMap<String, String>();
Map<String, String> instanceMap = new HashMap<>();
List<Object> allObj = getAllObjects();

for (Object temp : allObj) {
Expand Down Expand Up @@ -153,13 +169,13 @@ public void processPage(FileSystemResource resource) throws IOException {
try (InputStream input = resource.getInputStream()) {
Page page = PageFactory.getPage(input);

Map<Object, Object> map = new HashMap<Object, Object>();
Map<Object, Object> map = new HashMap<>();
map.put(KEY, "baseClass");
map.put("Value", page.getBaseClass());

appendObject(map);

map = new HashMap<Object, Object>();
map = new HashMap<>();
map.put(KEY, "pageTitle");
for (Entry<String, String> eachPage : page.getAllPageTitles().entrySet()) {
map.put(eachPage.getKey(), eachPage.getValue());
Expand All @@ -168,17 +184,23 @@ public void processPage(FileSystemResource resource) throws IOException {
appendObject(map);

for (Entry<String, GUIElement> eachElement : page.getElements().entrySet()) {
map = new HashMap<Object, Object>();
map = new HashMap<>();
map.put(KEY, eachElement.getKey());
for (Entry<String, String> eachLocale : eachElement.getValue().getAndroid().entrySet()) {
map.put("ANDROID--" + eachLocale.getKey(), eachLocale.getValue());
}
for (Entry<String, String> eachLocale : eachElement.getValue().getIos().entrySet()) {
map.put("IOS--" + eachLocale.getKey(), eachLocale.getValue());
}
for (Entry<String, String> eachLocale : eachElement.getValue().getLocators().entrySet()) {
map.put(eachLocale.getKey(), eachLocale.getValue());
}

Map<String, HtmlContainerElement> containerElements = eachElement.getValue().getContainerElements();
if (eachElement.getKey().endsWith(CONTAINER) && !containerElements.isEmpty()) {
Map<String, Map<String, String>> containerMap = new HashMap<String, Map<String, String>>();
Map<String, Map<String, String>> containerMap = new HashMap<>();
for (Entry<String, HtmlContainerElement> eachContainerElement : containerElements.entrySet()) {
Map<String, String> localeMap = new HashMap<String, String>(eachContainerElement.getValue()
Map<String, String> localeMap = new HashMap<>(eachContainerElement.getValue()
.getLocators());
containerMap.put(eachContainerElement.getKey(), localeMap);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-------------------------------------------------------------------------------------------------------------------*\
| Copyright (C) 2015 PayPal |
| Copyright (C) 2015-2016 PayPal |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance |
| with the License. |
Expand Down Expand Up @@ -332,7 +332,7 @@ private void performLongClickAction(Point point) {
}
}

private void performSwipeAction(Point start, Point end) {
public void performSwipeAction(Point start, Point end) {
new TouchActions(this).down(start.getX(), start.getY()).move(end.getX(), end.getY()).up(end.getX(), end.getY()).perform();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*-------------------------------------------------------------------------------------------------------------------*\
| Copyright (C) 2016 PayPal |
| |
| 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.paypal.selion.platform.mobile;

import com.paypal.selion.platform.mobile.elements.MobileElement;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* this annotation is used to define the implementation of annotated interface
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Implementor {
Class<? extends MobileElement> ios() default MobileElement.class;
Class<? extends MobileElement> android() default MobileElement.class;
}

0 comments on commit d735cb8

Please sign in to comment.