Skip to content

Commit

Permalink
Merge pull request #432 from asolntsev/remove_excessive_remote_web_el…
Browse files Browse the repository at this point in the history
…ement_usages

Use weaker interface HasIdentity instead of class RemoteWebElement
  • Loading branch information
TikhomirovSergey authored Jul 1, 2016
2 parents 64b2a9f + 15376fd commit d0c21fa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
24 changes: 12 additions & 12 deletions src/main/java/io/appium/java_client/TouchAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.google.common.collect.ImmutableMap;

import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebElement;
import org.openqa.selenium.internal.HasIdentity;


/**
Expand Down Expand Up @@ -50,7 +50,7 @@ public TouchAction(MobileDriver driver) {
* @return this TouchAction, for chaining.
*/
public TouchAction press(WebElement el) {
ActionParameter action = new ActionParameter("press", (RemoteWebElement) el);
ActionParameter action = new ActionParameter("press", (HasIdentity) el);
parameterBuilder.add(action);
return this;
}
Expand Down Expand Up @@ -79,7 +79,7 @@ public TouchAction press(int x, int y) {
* @return this TouchAction, for chaining.
*/
public TouchAction press(WebElement el, int x, int y) {
ActionParameter action = new ActionParameter("press", (RemoteWebElement) el);
ActionParameter action = new ActionParameter("press", (HasIdentity) el);
action.addParameter("x", x);
action.addParameter("y", y);
parameterBuilder.add(action);
Expand All @@ -104,7 +104,7 @@ public TouchAction release() {
* @return this TouchAction, for chaining.
*/
public TouchAction moveTo(WebElement el) {
ActionParameter action = new ActionParameter("moveTo", (RemoteWebElement) el);
ActionParameter action = new ActionParameter("moveTo", (HasIdentity) el);
parameterBuilder.add(action);
return this;
}
Expand Down Expand Up @@ -135,7 +135,7 @@ public TouchAction moveTo(int x, int y) {
* @return this TouchAction, for chaining.
*/
public TouchAction moveTo(WebElement el, int x, int y) {
ActionParameter action = new ActionParameter("moveTo", (RemoteWebElement) el);
ActionParameter action = new ActionParameter("moveTo", (HasIdentity) el);
action.addParameter("x", x);
action.addParameter("y", y);
parameterBuilder.add(action);
Expand All @@ -149,7 +149,7 @@ public TouchAction moveTo(WebElement el, int x, int y) {
* @return this TouchAction, for chaining.
*/
public TouchAction tap(WebElement el) {
ActionParameter action = new ActionParameter("tap", (RemoteWebElement) el);
ActionParameter action = new ActionParameter("tap", (HasIdentity) el);
parameterBuilder.add(action);
return this;
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public TouchAction tap(int x, int y) {
* @return this TouchAction, for chaining.
*/
public TouchAction tap(WebElement el, int x, int y) {
ActionParameter action = new ActionParameter("tap", (RemoteWebElement) el);
ActionParameter action = new ActionParameter("tap", (HasIdentity) el);
action.addParameter("x", x);
action.addParameter("y", y);
parameterBuilder.add(action);
Expand Down Expand Up @@ -216,7 +216,7 @@ public TouchAction waitAction(int ms) {
* @return this TouchAction, for chaining.
*/
public TouchAction longPress(WebElement el) {
ActionParameter action = new ActionParameter("longPress", (RemoteWebElement) el);
ActionParameter action = new ActionParameter("longPress", (HasIdentity) el);
parameterBuilder.add(action);
return this;
}
Expand All @@ -229,7 +229,7 @@ public TouchAction longPress(WebElement el) {
* @return this TouchAction, for chaining.
*/
public TouchAction longPress(WebElement el, int duration) {
ActionParameter action = new ActionParameter("longPress", (RemoteWebElement) el);
ActionParameter action = new ActionParameter("longPress", (HasIdentity) el);
action.addParameter("duration", duration);
parameterBuilder.add(action);
return this;
Expand Down Expand Up @@ -279,7 +279,7 @@ public TouchAction longPress(int x, int y, int duration) {
* @return this TouchAction, for chaining.
*/
public TouchAction longPress(WebElement el, int x, int y) {
ActionParameter action = new ActionParameter("longPress", (RemoteWebElement) el);
ActionParameter action = new ActionParameter("longPress", (HasIdentity) el);
action.addParameter("x", x);
action.addParameter("y", y);
parameterBuilder.add(action);
Expand All @@ -297,7 +297,7 @@ public TouchAction longPress(WebElement el, int x, int y) {
* @return this TouchAction, for chaining.
*/
public TouchAction longPress(WebElement el, int x, int y, int duration) {
ActionParameter action = new ActionParameter("longPress", (RemoteWebElement) el);
ActionParameter action = new ActionParameter("longPress", (HasIdentity) el);
action.addParameter("x", x);
action.addParameter("y", y);
action.addParameter("duration", duration);
Expand Down Expand Up @@ -355,7 +355,7 @@ public ActionParameter(String actionName) {
optionsBuilder = ImmutableMap.builder();
}

public ActionParameter(String actionName, RemoteWebElement el) {
public ActionParameter(String actionName, HasIdentity el) {
this.actionName = actionName;
optionsBuilder = ImmutableMap.builder();
addParameter("element", el.getId());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.appium.java_client.pagefactory_tests.widgets.ios.simple;

import io.appium.java_client.TouchableElement;
import io.appium.java_client.ios.IOSElement;
import io.appium.java_client.pagefactory.iOSFindBy;
import io.appium.java_client.pagefactory_tests.widgets.Movie;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.RemoteWebElement;

import java.util.List;

Expand All @@ -25,10 +25,10 @@ protected IOSMovie(WebElement element) {
}

@Override public Object getPoster() {
return ((RemoteWebElement) getWrappedElement()).getSize();
return getWrappedElement().getSize();
}

@Override public void goToReview() {
((IOSElement) getWrappedElement()).tap(1, 1500);
((TouchableElement) getWrappedElement()).tap(1, 1500);
}
}

0 comments on commit d0c21fa

Please sign in to comment.