Skip to content

Commit

Permalink
only one platform for all mobile platforms
Browse files Browse the repository at this point in the history
1. using only one mobile platform and remove other not required elements
2. extending Abstract Element as base Element to support already defined functionality for Web
3. adding wait for multiple elements in WaitDriver Utils
4. updating tests with the new system
5. updating code generator for new system and removing suport for android and ios directly
6. updating archetype to generate current archetypes based on new changes.
  • Loading branch information
alizelzele committed Dec 20, 2016
1 parent 5682f9e commit 6084bf5
Show file tree
Hide file tree
Showing 104 changed files with 1,001 additions and 3,123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package ${package}.sample.selion;

import com.paypal.selion.platform.mobile.ios.UIANavigationBar;
import org.testng.annotations.Test;
import com.paypal.selion.reports.runtime.SeLionReporter;
import static org.testng.Assert.assertEquals;
Expand All @@ -41,19 +42,19 @@ public void readTextOnApp() {
// 3. We can set this at a specific <test> level by setting the parameter
// <parameter name="siteLocale" value="locale_value_to_be_set"/> in the suite xml file.
NativeAppTestPage samplePage = new NativeAppTestPage("US");

//The NativeAppTestPage.java gets its data from NativeAppTestPage.yaml"

// Navigating to the Mountain List page to click on the third Mountain
samplePage.getSampleUIATableView().clickCellAtIndex(2);
samplePage.getSampleList().clickCellAtIndex(2);

// Once landed on the Mountain 3 page, reading the text
String mountainDetail = samplePage.getSampleUIAStaticText().getValue();
String mountainDetail = samplePage.getSampleLabel().getValue();
assertEquals(mountainDetail, "AAA was first climbed on DDD and is BBB CCC feet hight");
// Take a screen shot of the 3rd mountain details
SeLionReporter.log("Mountain 3 Details", true);
// Get back to the Main page
samplePage.getSampleUIANavigationBar().clickLeftButton();
new UIANavigationBar(samplePage.getSampleElement().getLocator()).clickLeftButton();
// Take a screen shot of the main screen
SeLionReporter.log("List of mountains", true);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
baseClass: "com.paypal.selion.testcomponents.BasicPageImpl"
defaultLocale: "US"
elements:
sampleUIANavigationBar:
sampleElement:
locators:
US: "//UIAApplication[1]/UIAWindow[2]/UIANavigationBar[1]"
sampleUIATableView:
sampleList:
locators:
US: "//UIAApplication[1]/UIAWindow[2]/UIATableView[1]"
sampleUIAStaticText:
sampleLabel:
locators:
US: "//UIAApplication[1]/UIAWindow[2]/UIAStaticText[1]"
platform: "ios"
platform: "mobile"
12 changes: 6 additions & 6 deletions client/src/main/java/com/paypal/selion/platform/grid/Grid.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*-------------------------------------------------------------------------------------------------------------------*\
| Copyright (C) 2014-15 PayPal |
| Copyright (C) 2014-16 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 @@ -150,7 +150,7 @@ public static WebTestSession getWebTestSession() {
/**
* Helper method to load a URL in a browser. Can be used for browsers in the case of {@link WebTest} and
* {@link MobileTest}
*
*
* @param url
* The url of the web application that needs to be opened.
*/
Expand All @@ -160,7 +160,7 @@ public static void open(String url) {

/**
* Converts a {@link HttpResponse} into a {@link JSONObject}
*
*
* @param resp
* A {@link HttpResponse} obtained from executing a request against a host
* @return An object of type {@link JSONObject}
Expand All @@ -184,7 +184,7 @@ private static JSONObject extractObject(HttpResponse resp) throws IOException, J
/**
* For a given Session ID against a host on a particular port, this method returns the remote webdriver node and the
* port to which the execution was redirected to by the hub.
*
*
* @param hostName
* The name of the hub machine
* @param port
Expand All @@ -202,8 +202,8 @@ public static RemoteNodeInformation getRemoteNodeInfo(String hostName, int port,
// go ahead and abort if this is a known grid where know we won't be able to extract the proxy info via the hub
// api
if (Config.getBoolConfigProperty(ConfigProperty.SELENIUM_USE_SAUCELAB_GRID)) {
logger.exiting(node);
return node;
logger.exiting();
return null;
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,22 @@
| the specific language governing permissions and limitations under the License. |
\*-------------------------------------------------------------------------------------------------------------------*/

package com.paypal.selion.platform.mobile.android;
package com.paypal.selion.platform.grid;

import com.paypal.selion.platform.mobile.elements.MobileLabel;
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;

/**
* <code>UiLabel</code> represents a Label widget for Android UI automation framework.
*/
public class UiLabel extends UiObject implements MobileLabel {
public class MobileGrid {
@SuppressWarnings("unchecked")
public static AppiumDriver<MobileElement> mobileDriver() {
return AppiumDriver.class.cast(Grid.driver());
}

public static SeLionAppiumAndroidDriver androidDriver() {
return SeLionAppiumAndroidDriver.class.cast(Grid.driver());
}

public UiLabel(String locator) {
super(locator);
public static SeLionAppiumIOSDriver iOSDriver() {
return SeLionAppiumIOSDriver.class.cast(Grid.driver());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,12 @@
import org.openqa.selenium.remote.CommandExecutor;

import com.paypal.selion.logger.SeLionLogger;
import com.paypal.selion.platform.mobile.android.SeLionAndroidBridgeDriver;
import com.paypal.selion.platform.mobile.android.UiObject;
import com.paypal.test.utilities.logging.SimpleLogger;

/**
* <code>SeLionAppiumAndroidDriver</code> provides facility to add custom {@link CommandExecutor} to
* {@link AndroidDriver}. This class also implements the {@link SeLionAndroidBridgeDriver} interface to expose
* methods for {@link UiObject} and its subclasses.
* <code>SeLionAppiumAndroidDriver</code> provides facility to add custom {@link CommandExecutor} to {@link AndroidDriver}.
*/
public class SeLionAppiumAndroidDriver extends AndroidDriver<WebElement> implements SeLionAndroidBridgeDriver {
public class SeLionAppiumAndroidDriver extends AndroidDriver<WebElement> {

private static final int OPERATION_DURATION_MILLI_SECONDS = 1000;
private static final SimpleLogger logger = SeLionLogger.getLogger();
Expand All @@ -50,14 +46,12 @@ public SeLionAppiumAndroidDriver(CommandExecutor commandExecutor, Capabilities c
setCommandExecutor(commandExecutor);
}

@Override
public void click(WebElement webElement) {
logger.entering(webElement);
this.tap(1, webElement, 1);
logger.exiting();
}

@Override
public void clickBottomRight(WebElement webElement) {
logger.entering(webElement);
Point currentPoint = webElement.getLocation();
Expand All @@ -69,7 +63,6 @@ public void clickBottomRight(WebElement webElement) {
logger.exiting();
}

@Override
public void clickTopLeft(WebElement webElement) {
logger.entering(webElement);
Point currentPoint = webElement.getLocation();
Expand All @@ -78,94 +71,82 @@ public void clickTopLeft(WebElement webElement) {
logger.exiting();
}

@Override
public String getText(WebElement webElement) {
logger.entering(webElement);
String text = webElement.getAttribute("text");
logger.exiting(text);
return text;
}

@Override
public boolean isCheckable(WebElement webElement) {
logger.entering(webElement);
boolean result = Boolean.parseBoolean(webElement.getAttribute("checkable"));
logger.exiting(result);
return result;
}

@Override
public boolean isChecked(WebElement webElement) {
logger.entering(webElement);
boolean result = Boolean.parseBoolean(webElement.getAttribute("checked"));
logger.exiting(result);
return result;
}

@Override
public boolean isClickable(WebElement webElement) {
logger.entering(webElement);
boolean result = Boolean.parseBoolean(webElement.getAttribute("clickable"));
logger.exiting(result);
return result;
}

@Override
public boolean isEnabled(WebElement webElement) {
logger.entering(webElement);
boolean result = Boolean.parseBoolean(webElement.getAttribute("enabled"));
logger.exiting(result);
return result;
}

@Override
public boolean isFocusable(WebElement webElement) {
logger.entering(webElement);
boolean result = Boolean.parseBoolean(webElement.getAttribute("focusable"));
logger.exiting(result);
return result;
}

@Override
public boolean isFocused(WebElement webElement) {
logger.entering(webElement);
boolean result = Boolean.parseBoolean(webElement.getAttribute("focused"));
logger.exiting(result);
return result;
}

@Override
public boolean isLongClickable(WebElement webElement) {
logger.entering(webElement);
boolean result = Boolean.parseBoolean(webElement.getAttribute("longClickable"));
logger.exiting(result);
return result;
}

@Override
public boolean isScrollable(WebElement webElement) {
logger.entering(webElement);
boolean result = Boolean.parseBoolean(webElement.getAttribute("scrollable"));
logger.exiting(result);
return result;
}

@Override
public boolean isSelected(WebElement webElement) {
logger.entering(webElement);
boolean result = Boolean.parseBoolean(webElement.getAttribute("selected"));
logger.exiting(result);
return result;
}

@Override
public void longClick(WebElement webElement) {
logger.entering(webElement);
this.tap(1, webElement, OPERATION_DURATION_MILLI_SECONDS);
logger.exiting();
}

@Override
public void longClickBottomRight(WebElement webElement) {
logger.entering(webElement);
Point currentPoint = webElement.getLocation();
Expand All @@ -177,7 +158,6 @@ public void longClickBottomRight(WebElement webElement) {
logger.exiting();
}

@Override
public void longClickTopLeft(WebElement webElement) {
logger.entering(webElement);
Point currentPoint = webElement.getLocation();
Expand All @@ -186,7 +166,6 @@ public void longClickTopLeft(WebElement webElement) {
logger.exiting();
}

@Override
public void swipeLeft(WebElement webElement) {
logger.entering(webElement);
Point currentLocation = webElement.getLocation();
Expand All @@ -198,7 +177,6 @@ public void swipeLeft(WebElement webElement) {
logger.exiting();
}

@Override
public void swipeRight(WebElement webElement) {
logger.entering(webElement);
Point currentLocation = webElement.getLocation();
Expand All @@ -210,7 +188,6 @@ public void swipeRight(WebElement webElement) {
logger.exiting();
}

@Override
public void swipeUp(WebElement webElement) {
logger.entering(webElement);
Point currentLocation = webElement.getLocation();
Expand All @@ -222,7 +199,6 @@ public void swipeUp(WebElement webElement) {
logger.exiting();
}

@Override
public void swipeDown(WebElement webElement) {
logger.entering(webElement);
Point currentLocation = webElement.getLocation();
Expand All @@ -234,24 +210,17 @@ public void swipeDown(WebElement webElement) {
logger.exiting();
}

@Override
public void clearText(WebElement webElement) {
logger.entering(webElement);
webElement.clear();
logger.exiting();
}

@Override
public void setText(WebElement webElement, String text) {
logger.entering(webElement);
//As per the UI Object API doc a text field will be cleared before setting value
webElement.clear();
webElement.sendKeys(text);
logger.exiting();
}

@Override
public void swipe(int startx, int starty, int endx, int endy) {
super.swipe(startx, starty, endx, endy,OPERATION_DURATION_MILLI_SECONDS );
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package com.paypal.selion.platform.grid;

import com.paypal.selion.platform.mobile.elements.AbstractMobileElement;
import io.appium.java_client.ios.IOSDriver;

import java.net.URL;
Expand All @@ -28,15 +29,15 @@
import com.paypal.selion.logger.SeLionLogger;
import com.paypal.selion.platform.mobile.ios.GestureOptions;
import com.paypal.selion.platform.mobile.ios.SeLionIOSBridgeDriver;
import com.paypal.selion.platform.mobile.ios.UIAElement;
import com.paypal.test.utilities.logging.SimpleLogger;
import io.appium.java_client.TouchAction;
import org.openqa.selenium.Dimension;

/**
* <code>SeLionAppiumIOSDriver</code> provides facility to add custom {@link CommandExecutor} to {@link IOSDriver}. This
* class also implements the {@link SeLionIOSBridgeDriver} interface to expose methods for {@link UIAElement} and its
* subclasses.
* <code>SeLionAppiumIOSDriver</code> provides facility to add custom
* {@link CommandExecutor} to {@link IOSDriver}. This class also implements the
* {@link SeLionIOSBridgeDriver} interface to expose methods for
* {@link AbstractMobileElement} and its subclasses.
*/
public class SeLionAppiumIOSDriver extends IOSDriver<WebElement> implements SeLionIOSBridgeDriver {

Expand Down Expand Up @@ -104,7 +105,6 @@ public void tap(WebElement webElement) {
}

@Deprecated
@Override
public void tapWithOptions(WebElement webElement, EnumMap<GestureOptions, String> gestureOptions) {
logger.entering(webElement, gestureOptions);
String s = gestureOptions.get(GestureOptions.TOUCH_COUNT);
Expand Down Expand Up @@ -160,4 +160,9 @@ public String getValue(WebElement webElement) {
logger.exiting(value);
return value;
}
}

@Override
public void swipe(int startx, int starty, int endx, int endy, int duration) {
doSwipe(startx, starty, endx, endy, duration);
}
}

0 comments on commit 6084bf5

Please sign in to comment.