Skip to content

Commit

Permalink
Release v3.1.0 (#93)
Browse files Browse the repository at this point in the history
* Added funding option (#89)

* Updated dependencies for Appium, Selenium and other supporting libraries. (#88)

* Updated outdated dependencies.

* Fixed SonarCloud issues. (#91)

* Released beta 1 for v3.1.0
  • Loading branch information
WasiqB authored Sep 2, 2019
1 parent b2ecca5 commit b016560
Show file tree
Hide file tree
Showing 15 changed files with 114 additions and 134 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>appium</artifactId>
<version>3.0.0</version>
<version>3.1.0-beta1</version>
<name>${project.groupId}:${project.artifactId}</name>
<description>Robust Automation Framework wrapped over Appium.</description>
<url>https://github.com/WasiqB/coteafs-appium</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
*/
public abstract class AndroidActivity
extends DeviceActivity <AndroidDriver <MobileElement>, AndroidDevice, AndroidTouchAction> {
private static final Logger log = LogManager.getLogger (AndroidActivity.class);
private static final Logger LOG = LogManager.getLogger (AndroidActivity.class);

/**
* @author wasiq.bhamla
Expand All @@ -52,19 +52,20 @@ public AndroidActivity (final AndroidDevice device) {
@Override
public AndroidDeviceActions onDevice () {
checkBattery ();
log.trace ("Preparing to perform actions on Android device...");
LOG.trace ("Preparing to perform actions on Android device...");
return new AndroidDeviceActions (this.device);
}

/*
* (non-Javadoc)
* @see com.github.wasiqb.coteafs.appium.device.DeviceActivity#onElement(java.lang.String)
* @see
* com.github.wasiqb.coteafs.appium.device.DeviceActivity#onElement(java.lang.
* String)
*/
@Override
public AndroidDeviceElementActions onElement (final String name) {
checkBattery ();
final String msg = "Preparing to perform actions on Android device element [%s]...";
log.trace (String.format (msg, name));
LOG.trace ("Preparing to perform actions on Android device element [{}]...", name);
return new AndroidDeviceElementActions (this.device, name, getElement (name));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import static com.github.wasiqb.coteafs.appium.constants.ErrorMessage.SERVER_STOPPED;
import static com.github.wasiqb.coteafs.appium.utils.ErrorUtils.fail;
import static java.lang.String.format;

import java.util.function.Consumer;
import java.util.function.Function;
Expand Down Expand Up @@ -46,7 +45,7 @@
*/
public class AndroidDeviceActions
extends DeviceActions <AndroidDriver <MobileElement>, AndroidDevice, AndroidTouchAction> {
private static final Logger log = LogManager.getLogger (AndroidDeviceActions.class);
private static final Logger LOG = LogManager.getLogger (AndroidDeviceActions.class);

/**
* @author wasiq.bhamla
Expand All @@ -63,7 +62,7 @@ public AndroidDeviceActions (final AndroidDevice device) {
* @return clipboard text
*/
public String clipboard () {
log.info ("Getting clipboard text...");
LOG.info ("Getting clipboard text...");
return this.driver.getClipboardText ();
}

Expand All @@ -74,7 +73,7 @@ public String clipboard () {
* @return clipboard
*/
public String clipboard (final ClipboardType type) {
log.info (format ("Getting clipboard for [%s]...", type));
LOG.info ("Getting clipboard for [{}]...", type);
return this.driver.getClipboard (type.getType ());
}

Expand All @@ -95,19 +94,18 @@ public String currentActivity () {
*/
public String handleAlert () {
return getValue ("Handling Android Alert pop-up...", d -> {
final String msg = "Alert Text: %s";
try {
final AlertActivity perm = new AlertActivity (this.device);
final String description = perm.onElement ("Message")
.text ();
log.trace (String.format (msg, description));
LOG.trace ("Alert Text: {}", description);
perm.onElement ("OK")
.tap ();
return description;
}
catch (final TimeoutException e) {
log.warn ("Expected Alert not displayed...");
log.warn (e.getMessage ());
LOG.warn ("Expected Alert not displayed...");
LOG.warn (e.getMessage ());
}
return null;
});
Expand All @@ -121,19 +119,18 @@ public String handleAlert () {
*/
public String handlePermissionAlert (final String buttonText) {
return getValue ("Handling Android Permission Alert pop-up...", d -> {
final String msg = "Alert Text: %s";
try {
final PermissionActivity perm = new PermissionActivity (this.device);
final String description = perm.onElement ("Message")
.text ();
log.trace (String.format (msg, description));
LOG.trace ("Alert Text: {}", description);
perm.onElement (buttonText)
.tap ();
return description;
}
catch (final TimeoutException e) {
log.warn ("Expected Alert not displayed...");
log.warn (e.getMessage ());
LOG.warn ("Expected Alert not displayed...");
LOG.warn (e.getMessage ());
}
return null;
});
Expand All @@ -144,7 +141,7 @@ public String handlePermissionAlert (final String buttonText) {
* @since Oct 20, 2018
*/
public void hideKeyboard () {
log.info ("Hiding the keyboard...");
LOG.info ("Hiding the keyboard...");
try {
if (this.driver.isKeyboardShown ()) {
this.driver.hideKeyboard ();
Expand Down Expand Up @@ -184,7 +181,7 @@ public void pinch (final int distance) {
super.pinch (distance);
}
else {
log.warn ("Pinch is only available when Automation type is Espresso...");
LOG.warn ("Pinch is only available when Automation type is Espresso...");
}
}

Expand All @@ -211,7 +208,7 @@ public void pressEnter () {
* @since Nov 2, 2018
*/
public void toggleAirplane () {
log.info ("Toggling Airplane...");
LOG.info ("Toggling Airplane...");
this.driver.toggleAirplaneMode ();
}

Expand All @@ -220,7 +217,7 @@ public void toggleAirplane () {
* @since Nov 2, 2018
*/
public void toggleData () {
log.info ("Toggling Data...");
LOG.info ("Toggling Data...");
this.driver.toggleData ();
}

Expand All @@ -229,7 +226,7 @@ public void toggleData () {
* @since Nov 2, 2018
*/
public void toggleLocation () {
log.info ("Toggling Location services...");
LOG.info ("Toggling Location services...");
this.driver.toggleLocationServices ();
}

Expand All @@ -238,7 +235,7 @@ public void toggleLocation () {
* @since Nov 2, 2018
*/
public void toggleWifi () {
log.info ("Toggling Wifi...");
LOG.info ("Toggling Wifi...");
this.driver.toggleWifi ();
}

Expand All @@ -261,13 +258,13 @@ public void zoom (final int distance) {
super.zoom (distance);
}
else {
log.warn ("Zoom is only available when Automation type is Espresso...");
LOG.warn ("Zoom is only available when Automation type is Espresso...");
}
}

private <T> T getValue (final String message,
final Function <AndroidDriver <MobileElement>, T> action, final Object... args) {
log.info (format (message, args));
LOG.info (message, args);
try {
return action.apply (this.driver);
}
Expand All @@ -279,7 +276,7 @@ private <T> T getValue (final String message,

private void perform (final String message,
final Consumer <AndroidDriver <MobileElement>> action, final Object... args) {
log.info (format (message, args));
LOG.info (message, args);
try {
action.accept (this.driver);
}
Expand Down
18 changes: 7 additions & 11 deletions src/main/java/com/github/wasiqb/coteafs/appium/device/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ public void executeCommand (final String command, final Map <String, Object> arg
* @return driver
*/
public D getDriver () {
final String msg = "Getting [%s] device driver...";
LOG.trace (format (msg, this.platform));
LOG.trace ("Getting [{}] device driver...", this.platform);
return this.driver;
}

Expand Down Expand Up @@ -205,8 +204,7 @@ public void stop () {
this.driver = null;
}
else {
final String message = "[%s] device driver already stopped...";
LOG.trace (format (message, this.platform));
LOG.trace ("[{}] device driver already stopped...", this.platform);
}
}

Expand Down Expand Up @@ -243,9 +241,9 @@ private void buildCapabilities () {
}
final File file = new File (path);
if (!file.exists ()) {
final String msg = "App not found on mentioned location [%s]...";
LOG.error (format (msg, path));
fail (DeviceAppNotFoundError.class, format (msg, path));
final String msg = format ("App not found on mentioned location [%s]...", path);
LOG.error (msg);
fail (DeviceAppNotFoundError.class, msg);
}
appPath = path;
}
Expand Down Expand Up @@ -277,8 +275,7 @@ private D init (final URL url, final Capabilities capability) {
}

private void quitApp () {
final String message = "Closing & Quitting [%s] device driver...";
LOG.trace (format (message, this.platform));
LOG.trace ("Closing & Quitting [{}] device driver...", this.platform);
try {
this.driver.closeApp ();
this.driver.quit ();
Expand Down Expand Up @@ -402,8 +399,7 @@ private void setIOSCapabilities () {
}

private void startDriver () {
final String msg = "Starting [%s] device driver...";
LOG.trace (format (msg, this.platform));
LOG.trace ("Starting [{}] device driver...", this.platform);
try {
this.driver = init (this.server.getServiceUrl (), this.capabilities);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
*/
public class DeviceActions <D extends AppiumDriver <MobileElement>, E extends Device <D, T>,
T extends TouchAction <T>> {
private static final Logger log = LogManager.getLogger (DeviceActions.class);
private static final Logger LOG = LogManager.getLogger (DeviceActions.class);

/**
* @author wasiq.bhamla
Expand All @@ -66,8 +66,8 @@ private static void copyFile (final File source, final String destination) {
FileUtils.copyFile (source, new File (destination));
}
catch (final IOException e) {
log.error ("Error occurred while capturing screensshot...");
log.catching (e);
LOG.error ("Error occurred while capturing screensshot...");
LOG.catching (e);
}
}

Expand Down Expand Up @@ -112,7 +112,7 @@ public void captureScreenshot () {
* @param url
*/
public void navigateTo (final String url) {
log.info (format ("Navigating to URL [%S]...", url));
LOG.info ("Navigating to URL [{}]...", url);
this.driver.get (url);
}

Expand All @@ -122,7 +122,7 @@ public void navigateTo (final String url) {
* @param distance
*/
public void pinch (final int distance) {
log.info (format ("Pinching on device screen by [%d]% distance...", distance));
LOG.info ("Pinching on device screen by [{}]% distance...", distance);
doubleFingerGesture (SwipeDirection.DOWN, SwipeDirection.UP, SwipeStartPosition.TOP,
SwipeStartPosition.BOTTOM, distance);
}
Expand All @@ -133,7 +133,7 @@ public void pinch (final int distance) {
* @param type
*/
public void rotate (final ScreenOrientation type) {
log.info (format ("Rotating device screen as [%s]c...", type));
LOG.info ("Rotating device screen as [{}]...", type);
this.driver.rotate (type);
}

Expand All @@ -143,7 +143,7 @@ public void rotate (final ScreenOrientation type) {
* @return rotation
*/
public ScreenOrientation rotation () {
log.info ("Getting rotation type for device...");
LOG.info ("Getting rotation type for device...");
return this.driver.getOrientation ();
}

Expand All @@ -156,9 +156,8 @@ public ScreenOrientation rotation () {
*/
public void swipe (final SwipeDirection direction, final SwipeStartPosition start,
final int distance) {
log.info (format (
"Swiping [%s] on device screen by [%d] perc distance from [%s] of the screen...",
direction, distance, start));
LOG.info ("Swiping [%s] on device screen by [{}] perc distance from [%s] of the screen...",
direction, distance, start);
swipeTo (direction, start, distance).perform ();
}

Expand All @@ -168,19 +167,13 @@ public void swipe (final SwipeDirection direction, final SwipeStartPosition star
* @param distance
*/
public void zoom (final int distance) {
log.info (format ("Zooming in device screen by [%d]% distance...", distance));
LOG.info ("Zooming in device screen by [{}]% distance...", distance);
doubleFingerGesture (SwipeDirection.UP, SwipeDirection.DOWN, SwipeStartPosition.CENTER,
SwipeStartPosition.CENTER, distance);
}

/**
* @author wasiq.bhamla
* @since 01-May-2017 8:24:34 PM
* @param path
*/
private void captureScreenshot (final String path) {
final String msg = "Capturing screenshot and saving at [%s]...";
log.info (format (msg, path));
LOG.info ("Capturing screenshot and saving at [{}]...", path);
try {
final File srcFiler = this.driver.getScreenshotAs (OutputType.FILE);
copyFile (srcFiler, path);
Expand Down
Loading

0 comments on commit b016560

Please sign in to comment.