Skip to content

Commit d0c21fa

Browse files
Merge pull request #432 from asolntsev/remove_excessive_remote_web_element_usages
Use weaker interface HasIdentity instead of class RemoteWebElement
2 parents 64b2a9f + 15376fd commit d0c21fa

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

src/main/java/io/appium/java_client/TouchAction.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import com.google.common.collect.ImmutableMap;
2121

2222
import org.openqa.selenium.WebElement;
23-
import org.openqa.selenium.remote.RemoteWebElement;
23+
import org.openqa.selenium.internal.HasIdentity;
2424

2525

2626
/**
@@ -50,7 +50,7 @@ public TouchAction(MobileDriver driver) {
5050
* @return this TouchAction, for chaining.
5151
*/
5252
public TouchAction press(WebElement el) {
53-
ActionParameter action = new ActionParameter("press", (RemoteWebElement) el);
53+
ActionParameter action = new ActionParameter("press", (HasIdentity) el);
5454
parameterBuilder.add(action);
5555
return this;
5656
}
@@ -79,7 +79,7 @@ public TouchAction press(int x, int y) {
7979
* @return this TouchAction, for chaining.
8080
*/
8181
public TouchAction press(WebElement el, int x, int y) {
82-
ActionParameter action = new ActionParameter("press", (RemoteWebElement) el);
82+
ActionParameter action = new ActionParameter("press", (HasIdentity) el);
8383
action.addParameter("x", x);
8484
action.addParameter("y", y);
8585
parameterBuilder.add(action);
@@ -104,7 +104,7 @@ public TouchAction release() {
104104
* @return this TouchAction, for chaining.
105105
*/
106106
public TouchAction moveTo(WebElement el) {
107-
ActionParameter action = new ActionParameter("moveTo", (RemoteWebElement) el);
107+
ActionParameter action = new ActionParameter("moveTo", (HasIdentity) el);
108108
parameterBuilder.add(action);
109109
return this;
110110
}
@@ -135,7 +135,7 @@ public TouchAction moveTo(int x, int y) {
135135
* @return this TouchAction, for chaining.
136136
*/
137137
public TouchAction moveTo(WebElement el, int x, int y) {
138-
ActionParameter action = new ActionParameter("moveTo", (RemoteWebElement) el);
138+
ActionParameter action = new ActionParameter("moveTo", (HasIdentity) el);
139139
action.addParameter("x", x);
140140
action.addParameter("y", y);
141141
parameterBuilder.add(action);
@@ -149,7 +149,7 @@ public TouchAction moveTo(WebElement el, int x, int y) {
149149
* @return this TouchAction, for chaining.
150150
*/
151151
public TouchAction tap(WebElement el) {
152-
ActionParameter action = new ActionParameter("tap", (RemoteWebElement) el);
152+
ActionParameter action = new ActionParameter("tap", (HasIdentity) el);
153153
parameterBuilder.add(action);
154154
return this;
155155
}
@@ -178,7 +178,7 @@ public TouchAction tap(int x, int y) {
178178
* @return this TouchAction, for chaining.
179179
*/
180180
public TouchAction tap(WebElement el, int x, int y) {
181-
ActionParameter action = new ActionParameter("tap", (RemoteWebElement) el);
181+
ActionParameter action = new ActionParameter("tap", (HasIdentity) el);
182182
action.addParameter("x", x);
183183
action.addParameter("y", y);
184184
parameterBuilder.add(action);
@@ -216,7 +216,7 @@ public TouchAction waitAction(int ms) {
216216
* @return this TouchAction, for chaining.
217217
*/
218218
public TouchAction longPress(WebElement el) {
219-
ActionParameter action = new ActionParameter("longPress", (RemoteWebElement) el);
219+
ActionParameter action = new ActionParameter("longPress", (HasIdentity) el);
220220
parameterBuilder.add(action);
221221
return this;
222222
}
@@ -229,7 +229,7 @@ public TouchAction longPress(WebElement el) {
229229
* @return this TouchAction, for chaining.
230230
*/
231231
public TouchAction longPress(WebElement el, int duration) {
232-
ActionParameter action = new ActionParameter("longPress", (RemoteWebElement) el);
232+
ActionParameter action = new ActionParameter("longPress", (HasIdentity) el);
233233
action.addParameter("duration", duration);
234234
parameterBuilder.add(action);
235235
return this;
@@ -279,7 +279,7 @@ public TouchAction longPress(int x, int y, int duration) {
279279
* @return this TouchAction, for chaining.
280280
*/
281281
public TouchAction longPress(WebElement el, int x, int y) {
282-
ActionParameter action = new ActionParameter("longPress", (RemoteWebElement) el);
282+
ActionParameter action = new ActionParameter("longPress", (HasIdentity) el);
283283
action.addParameter("x", x);
284284
action.addParameter("y", y);
285285
parameterBuilder.add(action);
@@ -297,7 +297,7 @@ public TouchAction longPress(WebElement el, int x, int y) {
297297
* @return this TouchAction, for chaining.
298298
*/
299299
public TouchAction longPress(WebElement el, int x, int y, int duration) {
300-
ActionParameter action = new ActionParameter("longPress", (RemoteWebElement) el);
300+
ActionParameter action = new ActionParameter("longPress", (HasIdentity) el);
301301
action.addParameter("x", x);
302302
action.addParameter("y", y);
303303
action.addParameter("duration", duration);
@@ -355,7 +355,7 @@ public ActionParameter(String actionName) {
355355
optionsBuilder = ImmutableMap.builder();
356356
}
357357

358-
public ActionParameter(String actionName, RemoteWebElement el) {
358+
public ActionParameter(String actionName, HasIdentity el) {
359359
this.actionName = actionName;
360360
optionsBuilder = ImmutableMap.builder();
361361
addParameter("element", el.getId());

src/test/java/io/appium/java_client/pagefactory_tests/widgets/ios/simple/IOSMovie.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package io.appium.java_client.pagefactory_tests.widgets.ios.simple;
22

3+
import io.appium.java_client.TouchableElement;
34
import io.appium.java_client.ios.IOSElement;
45
import io.appium.java_client.pagefactory.iOSFindBy;
56
import io.appium.java_client.pagefactory_tests.widgets.Movie;
67
import org.openqa.selenium.WebElement;
7-
import org.openqa.selenium.remote.RemoteWebElement;
88

99
import java.util.List;
1010

@@ -25,10 +25,10 @@ protected IOSMovie(WebElement element) {
2525
}
2626

2727
@Override public Object getPoster() {
28-
return ((RemoteWebElement) getWrappedElement()).getSize();
28+
return getWrappedElement().getSize();
2929
}
3030

3131
@Override public void goToReview() {
32-
((IOSElement) getWrappedElement()).tap(1, 1500);
32+
((TouchableElement) getWrappedElement()).tap(1, 1500);
3333
}
3434
}

0 commit comments

Comments
 (0)