Skip to content

Commit

Permalink
Merge pull request #55 from WasiqB/issue-41
Browse files Browse the repository at this point in the history
Issue 41
  • Loading branch information
mfaisalkhatri authored Sep 28, 2018
2 parents 120f562 + 067e3bc commit 555aaea
Show file tree
Hide file tree
Showing 30 changed files with 323 additions and 629 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</ciManagement>

<properties>
<appium-version>5.0.4</appium-version>
<appium-version>6.1.0</appium-version>
<selenium-version>3.14.0</selenium-version>
<coteafs.config.version>1.6.0</coteafs.config.version>
<coteafs.error.version>1.5.0</coteafs.error.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidTouchAction;

/**
* @author wasiq.bhamla
* @since 26-Apr-2017 6:19:46 PM
*/
public abstract class AndroidActivity extends DeviceActivity <AndroidDriver <MobileElement>, AndroidDevice> {
public abstract class AndroidActivity
extends DeviceActivity <AndroidDriver <MobileElement>, AndroidDevice, AndroidTouchAction> {
private static final Logger log;

static {
Expand All @@ -40,7 +42,7 @@ public abstract class AndroidActivity extends DeviceActivity <AndroidDriver <Mob
* @param device
*/
public AndroidActivity (final AndroidDevice device) {
super (device);
super (device, new AndroidTouchAction (device.getDriver ()));
}

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidTouchAction;

/**
* @author wasiq.bhamla
* @since Oct 23, 2017 11:04:31 PM
*/
public abstract class AndroidActivityActions
extends DeviceActivityActions <AndroidDriver <MobileElement>, AndroidDevice> {
public abstract class AndroidActivityActions extends
DeviceActivityActions <AndroidDriver <MobileElement>, AndroidDevice, AndroidTouchAction> {
/**
* @author wasiq.bhamla
* @since Oct 23, 2017 11:05:14 PM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidTouchAction;

/**
* @author wasiq.bhamla
* @since 13-Apr-2017 5:32:01 PM
*/
public class AndroidDevice extends Device <AndroidDriver <MobileElement>> {
public class AndroidDevice extends Device <AndroidDriver <MobileElement>, AndroidTouchAction> {
/**
* @author wasiq.bhamla
* @since 13-Apr-2017 9:12:47 PM
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,16 @@

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidKeyCode;
import io.appium.java_client.android.AndroidTouchAction;
import io.appium.java_client.android.nativekey.AndroidKey;
import io.appium.java_client.android.nativekey.KeyEvent;

/**
* @author wasiq.bhamla
* @since 26-Apr-2017 9:05:27 PM
*/
public class AndroidDeviceActions extends DeviceActions <AndroidDriver <MobileElement>, AndroidDevice> {
public class AndroidDeviceActions
extends DeviceActions <AndroidDriver <MobileElement>, AndroidDevice, AndroidTouchAction> {
private static final Logger log;

static {
Expand All @@ -53,7 +56,7 @@ public class AndroidDeviceActions extends DeviceActions <AndroidDriver <MobileEl
* @param device
*/
public AndroidDeviceActions (final AndroidDevice device) {
super (device);
super (device, new AndroidTouchAction (device.getDriver ()));
}

/**
Expand All @@ -62,7 +65,8 @@ public AndroidDeviceActions (final AndroidDevice device) {
* @return activity
*/
public String currentActivity () {
return getValue ("Getting current activity name...", AndroidDriver <MobileElement>::currentActivity);
return getValue ("Getting current activity name...",
AndroidDriver <MobileElement>::currentActivity);
}

/**
Expand All @@ -76,13 +80,12 @@ public String handleAlert () {
try {
final AlertActivity perm = new AlertActivity (this.device);
final String description = perm.onElement ("Message")
.text ();
.text ();
log.trace (String.format (msg, description));
perm.onElement ("OK")
.tap ();
.tap ();
return description;
}
catch (final TimeoutException e) {
} catch (final TimeoutException e) {
log.warn ("Expected Alert not displayed...");
log.warn (e.getMessage ());
}
Expand All @@ -102,13 +105,12 @@ public String handlePermissionAlert (final String buttonText) {
try {
final PermissionActivity perm = new PermissionActivity (this.device);
final String description = perm.onElement ("Message")
.text ();
.text ();
log.trace (String.format (msg, description));
perm.onElement (buttonText)
.tap ();
.tap ();
return description;
}
catch (final TimeoutException e) {
} catch (final TimeoutException e) {
log.warn ("Expected Alert not displayed...");
log.warn (e.getMessage ());
}
Expand All @@ -122,7 +124,8 @@ public String handlePermissionAlert (final String buttonText) {
* @return isLocked
*/
public boolean isLocked () {
return getValue ("Checking if device is locked...", AndroidDriver <MobileElement>::isLocked);
return getValue ("Checking if device is locked...",
AndroidDriver <MobileElement>::isDeviceLocked);
}

/**
Expand All @@ -138,15 +141,17 @@ public void lock () {
* @since Oct 21, 2017 8:27:50 PM
*/
public void pressBack () {
perform ("Pressing Back button on Android device...", d -> d.pressKeyCode (AndroidKeyCode.BACK));
perform ("Pressing Back button on Android device...",
d -> d.pressKey (new KeyEvent (AndroidKey.BACK)));
}

/**
* @author wasiq.bhamla
* @since Mar 5, 2018 10:50:09 PM
*/
public void pressEnter () {
perform ("Pressing Enter button on Android device...", d -> d.pressKeyCode (AndroidKeyCode.ENTER));
perform ("Pressing Enter button on Android device...",
d -> d.pressKey (new KeyEvent (AndroidKey.ENTER)));
}

/**
Expand All @@ -157,25 +162,23 @@ public void unlock () {
perform ("Unlocking the Android device...", AndroidDriver <MobileElement>::unlockDevice);
}

private <T> T getValue (final String message, final Function <AndroidDriver <MobileElement>, T> action,
final Object... args) {
private <T> T getValue (final String message,
final Function <AndroidDriver <MobileElement>, T> action, final Object... args) {
log.info (format (message, args));
try {
return action.apply (this.driver);
}
catch (final NoSuchSessionException e) {
} catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
return null;
}

private void perform (final String message, final Consumer <AndroidDriver <MobileElement>> action,
final Object... args) {
private void perform (final String message,
final Consumer <AndroidDriver <MobileElement>> action, final Object... args) {
log.info (format (message, args));
try {
action.accept (this.driver);
}
catch (final NoSuchSessionException e) {
} catch (final NoSuchSessionException e) {
fail (AppiumServerStoppedError.class, SERVER_STOPPED, e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidTouchAction;

/**
* @author wasiq.bhamla
* @since 02-May-2017 6:31:57 PM
*/
public class AndroidDeviceElementActions extends DeviceElementActions <AndroidDriver <MobileElement>, AndroidDevice> {
public class AndroidDeviceElementActions extends
DeviceElementActions <AndroidDriver <MobileElement>, AndroidDevice, AndroidTouchAction> {
/**
* @author wasiq.bhamla
* @since 02-May-2017 6:32:14 PM
* @param device
* @param name
* @param element
*/
public AndroidDeviceElementActions (final AndroidDevice device, final String name, final MobileElement element) {
super (device, name, element);
public AndroidDeviceElementActions (final AndroidDevice device, final String name,
final MobileElement element) {
super (device, name, element, new AndroidTouchAction (device.getDriver ()));
}

/*
Expand All @@ -44,4 +47,5 @@ public AndroidDeviceElementActions (final AndroidDevice device, final String nam
public AndroidElementVerify verifyThat () {
return new AndroidElementVerify (this);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@

import io.appium.java_client.MobileElement;
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidTouchAction;

/**
* @author wasiq.bhamla
* @since 20-May-2017 12:26:00 PM
*/
public class AndroidElementVerify extends DeviceElementVerify <AndroidDriver <MobileElement>, AndroidDevice> {
public class AndroidElementVerify extends
DeviceElementVerify <AndroidDriver <MobileElement>, AndroidDevice, AndroidTouchAction> {
/**
* @author wasiq.bhamla
* @since 20-May-2017 12:26:38 PM
Expand Down
Loading

0 comments on commit 555aaea

Please sign in to comment.