22
33import io .appium .java_client .*;
44import io .appium .java_client .android .AndroidDriver ;
5+ import io .appium .java_client .touch .WaitOptions ;
6+ import io .appium .java_client .touch .offset .PointOption ;
57import org .apache .commons .io .FileUtils ;
68import org .openqa .selenium .*;
79import org .openqa .selenium .interactions .Actions ;
1517import java .time .Duration ;
1618import java .util .List ;
1719
20+ import static io .appium .java_client .touch .offset .PointOption .*;
1821import static java .lang .Thread .sleep ;
1922import static net .itarray .automotion .tools .environment .EnvironmentFactory .*;
2023
@@ -101,9 +104,9 @@ public static void scrollDownMobile(AppiumDriver driver, int duration) {
101104
102105 new MultiTouchAction (driver )
103106 .add (new TouchAction (driver )
104- .press (screenWidthStart , screenHeightStart )
105- .waitAction (Duration .ofMillis (duration ))
106- .moveTo (screenWidthStart , 0 ))
107+ .press (point ( new Point ( screenWidthStart , screenHeightStart )) )
108+ .waitAction (WaitOptions . waitOptions ( Duration .ofMillis (duration ) ))
109+ .moveTo (point ( screenWidthStart , 0 ) ))
107110 .perform ();
108111 }
109112
@@ -120,9 +123,9 @@ public static void scrollUpMobile(AppiumDriver driver, int duration) {
120123
121124 new MultiTouchAction (driver )
122125 .add (new TouchAction (driver )
123- .press (screenWidthStart , screenHeightStart )
124- .waitAction (Duration .ofMillis (duration ))
125- .moveTo (screenWidthStart , dimensions .getHeight ()))
126+ .press (point ( screenWidthStart , screenHeightStart ) )
127+ .waitAction (WaitOptions . waitOptions ( Duration .ofMillis (duration ) ))
128+ .moveTo (point ( screenWidthStart , dimensions .getHeight () )))
126129 .perform ();
127130 }
128131
@@ -142,9 +145,9 @@ public static void scrollDownMobileElement(AppiumDriver driver, MobileElement el
142145
143146 new MultiTouchAction (driver )
144147 .add (new TouchAction (driver )
145- .press (screenWidthStart , screenHeightStart )
146- .waitAction (Duration .ofMillis (duration ))
147- .moveTo (screenWidthStart , position .getY ()))
148+ .press (point ( screenWidthStart , screenHeightStart ) )
149+ .waitAction (WaitOptions . waitOptions ( Duration .ofMillis (duration ) ))
150+ .moveTo (point ( screenWidthStart , position .getY () )))
148151 .perform ();
149152
150153 LOG .info ("Scroll down element " + element .getId ());
@@ -159,9 +162,9 @@ public static void scrollUpMobileElement(AppiumDriver driver, MobileElement elem
159162
160163 new MultiTouchAction (driver )
161164 .add (new TouchAction (driver )
162- .press (screenWidthStart , screenHeightStart )
163- .waitAction (Duration .ofMillis (500 ))
164- .moveTo (screenWidthStart , dimensions .getHeight ()))
165+ .press (point ( screenWidthStart , screenHeightStart ) )
166+ .waitAction (WaitOptions . waitOptions ( Duration .ofMillis (500 ) ))
167+ .moveTo (point ( screenWidthStart , dimensions .getHeight () )))
165168 .perform ();
166169
167170 LOG .info ("Scroll up element " + element .getId ());
@@ -213,15 +216,15 @@ public static void hideKeyboard(AppiumDriver driver) {
213216
214217 new MultiTouchAction (driver )
215218 .add (new TouchAction (driver )
216- .press (screenWidthStart , screenHeightStart )
217- .waitAction (Duration .ofMillis (500 ))
218- .moveTo (screenWidthStart , dimensions .getHeight ()))
219+ .press (point ( screenWidthStart , screenHeightStart ) )
220+ .waitAction (WaitOptions . waitOptions ( Duration .ofMillis (500 ) ))
221+ .moveTo (point ( screenWidthStart , dimensions .getHeight () )))
219222 .perform ();
220223 } else {
221224 int x = dimensions .getWidth () - 30 ;
222225 int y = dimensions .getHeight () - 30 ;
223226
224- new TouchAction (driver ).tap (x , y );
227+ new TouchAction (driver ).tap (point ( x , y ) );
225228 }
226229 } else if (isAndroid ()) {
227230 try {
@@ -310,19 +313,19 @@ public static void clickMobileElementByLocation(AppiumDriver driver, MobileEleme
310313 int y = location .getY ();
311314 switch (clickPoint ) {
312315 case TOP_LEFT :
313- new TouchAction (driver ).tap (x + 5 , y + 5 );
316+ new TouchAction (driver ).tap (point ( x + 5 , y + 5 ) );
314317 break ;
315318 case TOP_RIGHT :
316- new TouchAction (driver ).tap (x + size .getWidth () - 5 , y + 5 );
319+ new TouchAction (driver ).tap (point ( x + size .getWidth () - 5 , y + 5 ) );
317320 break ;
318321 case BOTTOM_LEFT :
319- new TouchAction (driver ).tap (x + 5 , y + size .getHeight () - 5 );
322+ new TouchAction (driver ).tap (point ( x + 5 , y + size .getHeight () - 5 ) );
320323 break ;
321324 case BOTTOM_RIGHT :
322- new TouchAction (driver ).tap (x + size .getWidth () - 5 , y + size .getHeight () - 5 );
325+ new TouchAction (driver ).tap (point ( x + size .getWidth () - 5 , y + size .getHeight () - 5 ) );
323326 break ;
324327 case CENTER :
325- new TouchAction (driver ).tap (x + size .getWidth () / 2 , y + size .getHeight () / 2 );
328+ new TouchAction (driver ).tap (point ( x + size .getWidth () / 2 , y + size .getHeight () / 2 ) );
326329 break ;
327330 }
328331 LOG .info ("INFO" , "Click on " + clickPoint + " point" );
0 commit comments