-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump appium java-client to 5.0.3 #368
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,13 +15,14 @@ | |
|
||
package com.paypal.selion.appium.platform.grid; | ||
|
||
import io.appium.java_client.MultiTouchAction; | ||
import io.appium.java_client.TouchAction; | ||
import io.appium.java_client.android.AndroidDriver; | ||
|
||
import java.net.URL; | ||
import java.time.Duration; | ||
|
||
import org.openqa.selenium.Capabilities; | ||
import org.openqa.selenium.DeviceRotation; | ||
import org.openqa.selenium.Dimension; | ||
import org.openqa.selenium.Point; | ||
import org.openqa.selenium.WebElement; | ||
|
@@ -34,8 +35,8 @@ | |
|
||
/** | ||
* <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. | ||
* {@link AndroidDriver}. This class also implements the {@link SeLionAndroidBridgeDriver} interface to expose methods | ||
* for {@link UiObject} and its subclasses. | ||
*/ | ||
public class SeLionAppiumAndroidDriver extends AndroidDriver<WebElement> implements SeLionAndroidBridgeDriver { | ||
|
||
|
@@ -54,7 +55,7 @@ public SeLionAppiumAndroidDriver(CommandExecutor commandExecutor, Capabilities c | |
@Override | ||
public void click(WebElement webElement) { | ||
logger.entering(webElement); | ||
this.tap(1, webElement, 1); | ||
tap(1, webElement, 1); | ||
logger.exiting(); | ||
} | ||
|
||
|
@@ -162,7 +163,7 @@ public boolean isSelected(WebElement webElement) { | |
@Override | ||
public void longClick(WebElement webElement) { | ||
logger.entering(webElement); | ||
this.tap(1, webElement, OPERATION_DURATION_MILLI_SECONDS); | ||
tap(1, webElement, OPERATION_DURATION_MILLI_SECONDS); | ||
logger.exiting(); | ||
} | ||
|
||
|
@@ -192,10 +193,10 @@ public void swipeLeft(WebElement webElement) { | |
logger.entering(webElement); | ||
Point currentLocation = webElement.getLocation(); | ||
Dimension elementSize = webElement.getSize(); | ||
int x = currentLocation.getX() + elementSize.getWidth() - 1; | ||
int x = currentLocation.getX() + elementSize.getWidth() - 1; | ||
int y = currentLocation.getY(); | ||
int endx = currentLocation.getX(); | ||
this.swipe(x, y, endx, y, OPERATION_DURATION_MILLI_SECONDS); | ||
swipe(x, y, endx, y); | ||
logger.exiting(); | ||
} | ||
|
||
|
@@ -207,7 +208,7 @@ public void swipeRight(WebElement webElement) { | |
int x = currentLocation.getX(); | ||
int y = currentLocation.getY(); | ||
int endx = x + elementSize.getWidth() - 1; | ||
this.swipe(x,y,endx, y, OPERATION_DURATION_MILLI_SECONDS); | ||
swipe(x, y, endx, y); | ||
logger.exiting(); | ||
} | ||
|
||
|
@@ -219,7 +220,7 @@ public void swipeUp(WebElement webElement) { | |
int x = currentLocation.getX(); | ||
int y = currentLocation.getY() + elementSize.getHeight() - 1; | ||
int endy = currentLocation.getY(); | ||
this.swipe(x, y, x, endy, OPERATION_DURATION_MILLI_SECONDS); | ||
swipe(x, y, x, endy); | ||
logger.exiting(); | ||
} | ||
|
||
|
@@ -231,7 +232,7 @@ public void swipeDown(WebElement webElement) { | |
int x = currentLocation.getX(); | ||
int y = currentLocation.getY(); | ||
int endy = y + elementSize.getHeight() - 1; | ||
this.swipe(x, y, x, endy, OPERATION_DURATION_MILLI_SECONDS); | ||
swipe(x, y, x, endy); | ||
logger.exiting(); | ||
} | ||
|
||
|
@@ -245,27 +246,40 @@ public void clearText(WebElement webElement) { | |
@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 | ||
// 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 ); | ||
swipe(startx, starty, endx, endy, OPERATION_DURATION_MILLI_SECONDS); | ||
} | ||
|
||
// On Appium Android we mimic swipe via one finger tap | ||
this.tap(1, starty, endx, OPERATION_DURATION_MILLI_SECONDS); | ||
public void swipe(int startx, int starty, int endx, int endy, int duration) { | ||
new TouchAction(this).press(startx, starty).waitAction(Duration.ofMillis(duration)).moveTo(endx, endy).release().perform(); | ||
} | ||
|
||
@Override | ||
public void rotate(DeviceRotation rotation) { | ||
// TODO | ||
public void tap(int fingers, WebElement element, int duration) { | ||
MultiTouchAction multiTouch = new MultiTouchAction(this); | ||
|
||
for (int i = 0; i < fingers; i++) { | ||
TouchAction tap = new TouchAction(this); | ||
multiTouch.add(tap.press(element).waitAction(Duration.ofMillis(duration)).release()); | ||
} | ||
|
||
multiTouch.perform(); | ||
} | ||
|
||
@Override | ||
public DeviceRotation rotation() { | ||
return null; | ||
public void tap(int fingers, int x, int y, int duration) { | ||
MultiTouchAction multiTouch = new MultiTouchAction(this); | ||
|
||
for (int i = 0; i < fingers; i++) { | ||
TouchAction tap = new TouchAction(this); | ||
multiTouch.add(tap.press(x, y).waitAction(Duration.ofMillis(duration)).release()); | ||
} | ||
multiTouch.perform(); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please confirm if it is multi finger tap or multi tap action or combination of both? Above implementation completely depends on the duration parameter for example if I want to perform a double tap with duration 200ms, this will become two long press actions, but if I perform a double tap action with 30ms then that will be treated as double tap. My suggestion would be not use raw actions rather use tap action exposed by TouchAction api- Ex-
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Observation : Most of the methods are expecting WebElement as an argument, so in test first you have to grab the WebElement instance and then only you can invoke these methods. Why can't we follow the same approach we have taken for HTML elements where we are invoking the findElement internally to grab the element reference. I am not sure if that would violate the design of the framework. |
||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,11 +18,11 @@ | |
import io.appium.java_client.ios.IOSDriver; | ||
|
||
import java.net.URL; | ||
import java.time.Duration; | ||
import java.util.EnumMap; | ||
|
||
import org.openqa.selenium.By; | ||
import org.openqa.selenium.Capabilities; | ||
import org.openqa.selenium.DeviceRotation; | ||
import org.openqa.selenium.Dimension; | ||
import org.openqa.selenium.WebElement; | ||
import org.openqa.selenium.remote.CommandExecutor; | ||
|
@@ -32,6 +32,8 @@ | |
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.MultiTouchAction; | ||
import io.appium.java_client.TouchAction; | ||
|
||
/** | ||
|
@@ -68,11 +70,8 @@ public WebElement findElementBy(By by) { | |
@Override | ||
public void doubleTap(WebElement webElement) { | ||
logger.entering(webElement); | ||
new TouchAction(this) | ||
.tap(webElement).release() | ||
.waitAction(DOUBLE_TAP_WAIT_TIME) | ||
.tap(webElement).release() | ||
.perform(); | ||
new TouchAction(this).tap(webElement).release().waitAction(Duration.ofMillis(DOUBLE_TAP_WAIT_TIME)) | ||
.tap(webElement).release().perform(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would recommend to use appium provided doubleTap for iOS -
|
||
logger.exiting(); | ||
} | ||
|
||
|
@@ -88,7 +87,7 @@ public void scrollToVisible(WebElement webElement) { | |
found = true; | ||
break; | ||
} | ||
this.swipe(startx, height, startx, SWIPE_EDGE_OFFSET - height, SWIPE_DURATION); | ||
swipe(startx, height, startx, SWIPE_EDGE_OFFSET - height, SWIPE_DURATION); | ||
} | ||
if (!found && !webElement.isDisplayed()) { | ||
// giving up scrolling for element to be displayed after MAX_SCROLL_COUNT reached. | ||
|
@@ -100,7 +99,7 @@ public void scrollToVisible(WebElement webElement) { | |
@Override | ||
public void tap(WebElement webElement) { | ||
logger.entering(webElement); | ||
super.tap(1, webElement, TAP_DURATION); | ||
tap(1, webElement, TAP_DURATION); | ||
logger.exiting(); | ||
} | ||
|
||
|
@@ -112,14 +111,14 @@ public void tapWithOptions(WebElement webElement, EnumMap<GestureOptions, String | |
int touchCount = s == null ? 1 : Integer.parseInt(s); | ||
s = gestureOptions.get(GestureOptions.DURATION); | ||
int duration = s == null ? TAP_DURATION : Integer.parseInt(s); | ||
super.tap(touchCount, webElement, duration); | ||
tap(touchCount, webElement, duration); | ||
logger.exiting(); | ||
} | ||
|
||
@Override | ||
public void twoFingerTap(WebElement webElement) { | ||
logger.entering(webElement); | ||
super.tap(2, webElement, 1); | ||
tap(2, webElement, 1); | ||
logger.exiting(); | ||
} | ||
|
||
|
@@ -162,13 +161,27 @@ public String getValue(WebElement webElement) { | |
return value; | ||
} | ||
|
||
@Override | ||
public void rotate(DeviceRotation deviceRotation) { | ||
//TODO | ||
public void swipe(int startx, int starty, int endx, int endy) { | ||
swipe(startx, starty, endx, endy, SWIPE_DURATION); | ||
} | ||
|
||
@Override | ||
public DeviceRotation rotation() { | ||
return null; | ||
|
||
public void swipe(int startx, int starty, int endx, int endy, int duration) { | ||
int xOffset = endx - startx; | ||
int yOffset = endy - starty; | ||
new TouchAction(this).press(startx, starty).waitAction(Duration.ofMillis(duration)).moveTo(xOffset, yOffset) | ||
.release().perform(); | ||
} | ||
|
||
public void tap(int fingers, WebElement element, int duration) { | ||
MultiTouchAction multiTouch = new MultiTouchAction(this); | ||
|
||
for (int i = 0; i < fingers; i++) { | ||
TouchAction tap = new TouchAction(this); | ||
multiTouch.add(tap.press(element).waitAction(Duration.ofMillis(duration)).release()); | ||
} | ||
|
||
multiTouch.perform(); | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still need to test this action before I can comment on it since I am not sure if it is multi finger or multi tap action. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe these are all multi finger actions. |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
endx and endy - these are not absolute x,y value rather they represent the shift in x and y axis. So renaming them to shiftX and shiftY would make more sense
Also, consider a situation where you are swiping a carousel, most of the time you would be interested to go to a certain carousel content. To solve this problem if we can add a swipeCount argument then the author of the test can easily decide how many swipe is needed to go to the desired content, by default it will swipe only once.