29
29
import org .openqa .selenium .By ;
30
30
import org .openqa .selenium .Capabilities ;
31
31
import org .openqa .selenium .DeviceRotation ;
32
+ import org .openqa .selenium .Dimension ;
33
+ import org .openqa .selenium .Point ;
32
34
import org .openqa .selenium .ScreenOrientation ;
33
35
import org .openqa .selenium .WebDriver ;
34
36
import org .openqa .selenium .WebDriverException ;
43
45
import org .openqa .selenium .remote .Response ;
44
46
import org .openqa .selenium .remote .html5 .RemoteLocationContext ;
45
47
import org .openqa .selenium .remote .http .HttpClient ;
46
- import org .openqa .selenium .remote .internal .JsonToWebElementConverter ;
47
48
48
49
import java .net .URL ;
49
50
import java .util .LinkedHashSet ;
56
57
* Instances of the defined type will be returned via findElement* and findElements*
57
58
* Warning (!!!). Allowed types:
58
59
* {@link org.openqa.selenium.WebElement}
59
- * {@link io.appium.java_client.TouchableElement}
60
60
* {@link org.openqa.selenium.remote.RemoteWebElement}
61
61
* {@link io.appium.java_client.MobileElement} and its subclasses that designed
62
62
* specifically
@@ -191,36 +191,35 @@ public List<T> findElementsByXPath(String using) {
191
191
192
192
/**
193
193
* This method is deprecated and it is going to be removed soon.
194
- * Please use {@link MultiTouchAction#tap(int, WebElement, int)}.
195
194
*/
196
195
@ Deprecated
197
196
public void tap (int fingers , WebElement element , int duration ) {
198
197
MultiTouchAction multiTouch = new MultiTouchAction (this );
199
198
200
199
for (int i = 0 ; i < fingers ; i ++) {
201
- multiTouch .add (createTap (element , duration ));
200
+ TouchAction tap = new TouchAction (this );
201
+ multiTouch .add (tap .press (element ).waitAction (duration ).release ());
202
202
}
203
203
204
204
multiTouch .perform ();
205
205
}
206
206
207
207
/**
208
208
* This method is deprecated and it is going to be removed soon.
209
- * Please use {@link MultiTouchAction#tap(int, int, int, int)}.
210
209
*/
211
210
@ Deprecated
212
211
public void tap (int fingers , int x , int y , int duration ) {
213
212
MultiTouchAction multiTouch = new MultiTouchAction (this );
214
213
215
214
for (int i = 0 ; i < fingers ; i ++) {
216
- multiTouch .add (createTap (x , y , duration ));
215
+ TouchAction tap = new TouchAction (this );
216
+ multiTouch .add (tap .press (x ,y ).waitAction (duration ).release ());
217
217
}
218
218
multiTouch .perform ();
219
219
}
220
220
221
221
/**
222
- * This method is deprecated.
223
- * It was moved to {@link CreatesSwipeAction#swipe(int, int, int, int, int)}.
222
+ * This method is deprecated. It is going to be removed
224
223
*/
225
224
@ Deprecated
226
225
public void swipe (int startx , int starty , int endx , int endy , int duration ) {
@@ -229,19 +228,29 @@ public void swipe(int startx, int starty, int endx, int endy, int duration) {
229
228
230
229
/**
231
230
* This method is deprecated and it is going to be removed soon.
232
- * Please use {@link MultiTouchAction#pinch(WebElement)}.
233
231
*/
234
232
@ Deprecated
235
233
public void pinch (WebElement el ) {
236
234
MultiTouchAction multiTouch = new MultiTouchAction (this );
237
235
238
- multiTouch .pinch (el ).perform ();
236
+ Dimension dimensions = el .getSize ();
237
+ Point upperLeft = el .getLocation ();
238
+ Point center = new Point (upperLeft .getX () + dimensions .getWidth () / 2 ,
239
+ upperLeft .getY () + dimensions .getHeight () / 2 );
240
+ int yOffset = center .getY () - upperLeft .getY ();
241
+
242
+ TouchAction action0 =
243
+ new TouchAction (this ).press (el , center .getX (), center .getY () - yOffset ).moveTo (el )
244
+ .release ();
245
+ TouchAction action1 =
246
+ new TouchAction (this ).press (el , center .getX (), center .getY () + yOffset ).moveTo (el )
247
+ .release ();
248
+
249
+ multiTouch .add (action0 ).add (action1 ).perform ();
239
250
}
240
251
241
252
/**
242
253
* This method is deprecated and it is going to be removed soon.
243
- * Please use {@link MultiTouchAction#pinch(int, int, int, int)} or
244
- * {@link MultiTouchAction#pinch(int, int, int)}
245
254
*/
246
255
@ Deprecated
247
256
public void pinch (int x , int y ) {
@@ -264,19 +273,27 @@ public void pinch(int x, int y) {
264
273
265
274
/**
266
275
* This method is deprecated and it is going to be removed soon.
267
- * Please use {@link MultiTouchAction#zoom(WebElement)}.
268
276
*/
269
277
@ Deprecated
270
278
public void zoom (WebElement el ) {
271
279
MultiTouchAction multiTouch = new MultiTouchAction (this );
272
280
273
- multiTouch .zoom (el ).perform ();
281
+ Dimension dimensions = el .getSize ();
282
+ Point upperLeft = el .getLocation ();
283
+ Point center = new Point (upperLeft .getX () + dimensions .getWidth () / 2 ,
284
+ upperLeft .getY () + dimensions .getHeight () / 2 );
285
+ int yOffset = center .getY () - upperLeft .getY ();
286
+
287
+ TouchAction action0 = new TouchAction (this ).press (center .getX (), center .getY ())
288
+ .moveTo (el , center .getX (), center .getY () - yOffset ).release ();
289
+ TouchAction action1 = new TouchAction (this ).press (center .getX (), center .getY ())
290
+ .moveTo (el , center .getX (), center .getY () + yOffset ).release ();
291
+
292
+ multiTouch .add (action0 ).add (action1 ).perform ();
274
293
}
275
294
276
295
/**
277
296
* This method is deprecated and it is going to be removed soon.
278
- * Please use {@link MultiTouchAction#zoom(int, int, int, int)} or
279
- * {@link MultiTouchAction#zoom(int, int, int)}.
280
297
*/
281
298
@ Deprecated
282
299
public void zoom (int x , int y ) {
@@ -364,18 +381,6 @@ public void zoom(int x, int y) {
364
381
locationContext .setLocation (location );
365
382
}
366
383
367
- @ Deprecated
368
- private TouchAction createTap (WebElement element , int duration ) {
369
- TouchAction tap = new TouchAction (this );
370
- return tap .press (element ).waitAction (duration ).release ();
371
- }
372
-
373
- @ Deprecated
374
- private TouchAction createTap (int x , int y , int duration ) {
375
- TouchAction tap = new TouchAction (this );
376
- return tap .press (x , y ).waitAction (duration ).release ();
377
- }
378
-
379
384
public URL getRemoteAddress () {
380
385
return remoteAddress ;
381
386
}
0 commit comments