@@ -22,6 +22,12 @@ public class DriverHelper {
2222
2323 private final static Logger LOG = LoggerFactory .getLogger (DriverHelper .class );
2424
25+ /**
26+ * Sending the keys into web element with click and clear
27+ *
28+ * @param element
29+ * @param text
30+ */
2531 public static void sendKeys (WebElement element , String text ) {
2632 element .click ();
2733 element .clear ();
@@ -30,31 +36,64 @@ public static void sendKeys(WebElement element, String text) {
3036 LOG .info ("Send text: " + text );
3137 }
3238
39+ /**
40+ * Sending keys into mobile element with full clearing (iOS driver)
41+ *
42+ * @param driver
43+ * @param element
44+ * @param text
45+ */
3346 public static void sendKeysFullClear (AndroidDriver driver , MobileElement element , String text ) {
3447 MobileHelper .clearField (driver , element ).sendKeys (text );
3548 driver .pressKeyCode (84 );
3649
3750 LOG .info ("Send text: " + text );
3851 }
3952
53+ /**
54+ * Scroll down web page for 1000px
55+ *
56+ * @param driver
57+ */
4058 public static void scrollDownWeb (WebDriver driver ) {
4159 JavascriptExecutor jse = (JavascriptExecutor ) driver ;
4260 jse .executeScript ("window.scroll(0,1000)" , "" );
4361 }
4462
63+ /**
64+ * Scroll up web page for 1000px
65+ *
66+ * @param driver
67+ */
4568 public static void scrollUpWeb (WebDriver driver ) {
4669 JavascriptExecutor jse = (JavascriptExecutor ) driver ;
4770 jse .executeScript ("window.scroll(0,-1000)" , "" );
4871 }
4972
73+ /**
74+ * Swipe down mobile page with duration 1sec
75+ *
76+ * @param driver
77+ */
5078 public static void scrollDownMobile (AppiumDriver driver ) {
5179 scrollDownMobile (driver , 1000 );
5280 }
5381
82+ /**
83+ * Swipe up mobile page with duration 1sec
84+ *
85+ * @param driver
86+ */
5487 public static void scrollUpMobile (AppiumDriver driver ) {
5588 scrollUpMobile (driver , 1000 );
5689 }
5790
91+ /**
92+ * Swipe down mobile page
93+ *
94+ * @param driver
95+ * @param duration
96+ */
5897 public static void scrollDownMobile (AppiumDriver driver , int duration ) {
5998 Dimension dimensions = driver .manage ().window ().getSize ();
6099 int screenHeightStart = dimensions .getHeight () / 2 ;
@@ -63,6 +102,12 @@ public static void scrollDownMobile(AppiumDriver driver, int duration) {
63102 driver .swipe (screenWidthStart , screenHeightStart , screenWidthStart , 0 , duration );
64103 }
65104
105+ /**
106+ * Swipe up mobile page
107+ *
108+ * @param driver
109+ * @param duration
110+ */
66111 public static void scrollUpMobile (AppiumDriver driver , int duration ) {
67112 Dimension dimensions = driver .manage ().window ().getSize ();
68113 int screenHeightStart = dimensions .getHeight () / 2 ;
@@ -102,6 +147,12 @@ public static void scrollUpMobileElement(AppiumDriver driver, MobileElement elem
102147 LOG .info ("Scroll up element " + element .getId ());
103148 }
104149
150+ /**
151+ * zoom In/Out the page
152+ *
153+ * @param driver
154+ * @param zoomPercent
155+ */
105156 public static void zoomInOutPage (WebDriver driver , int zoomPercent ) {
106157 if (zoomPercent > 0 ) {
107158 JavascriptExecutor jse = (JavascriptExecutor ) driver ;
@@ -124,6 +175,11 @@ public static String takeScreenshot(WebDriver driver) throws Exception {
124175 return fullFileName ;
125176 }
126177
178+ /**
179+ * Hide keyboard for iOS and Android in single method
180+ *
181+ * @param driver
182+ */
127183 public static void hideKeyboard (AppiumDriver driver ) {
128184 if (isIOS ()) {
129185 Dimension dimensions = driver .manage ().window ().getSize ();
@@ -164,6 +220,18 @@ public static void click(WebDriver driver, WebElement element) {
164220 }
165221 }
166222
223+ /**
224+ * Click web element by location using clickPoint:
225+ * TOP_LEFT,
226+ * TOP_RIGHT,
227+ * BOTTOM_LEFT,
228+ * BOTTOM_RIGHT,
229+ * CENTER
230+ *
231+ * @param driver
232+ * @param element
233+ * @param clickPoint
234+ */
167235 public static void clickByLocation (WebDriver driver , WebElement element , ClickPoint clickPoint ) {
168236 Point location = element .getLocation ();
169237 Dimension size = element .getSize ();
@@ -190,6 +258,18 @@ public static void clickByLocation(WebDriver driver, WebElement element, ClickPo
190258 LOG .info ("INFO" , "Click on " + clickPoint + " point" );
191259 }
192260
261+ /**
262+ * Click mobile element by location using clickPoint:
263+ * TOP_LEFT,
264+ * TOP_RIGHT,
265+ * BOTTOM_LEFT,
266+ * BOTTOM_RIGHT,
267+ * CENTER
268+ *
269+ * @param driver
270+ * @param element
271+ * @param clickPoint
272+ */
193273 public static void clickByLocation (AppiumDriver driver , MobileElement element , ClickPoint clickPoint ) {
194274 Point location = element .getLocation ();
195275 Dimension size = element .getSize ();
@@ -215,6 +295,12 @@ public static void clickByLocation(AppiumDriver driver, MobileElement element, C
215295 LOG .info ("INFO" , "Click on " + clickPoint + " point" );
216296 }
217297
298+ /**
299+ * Click on element using JQuery click()
300+ *
301+ * @param driver
302+ * @param element
303+ */
218304 public static void clickJQuery (WebDriver driver , WebElement element ) {
219305 JavascriptExecutor executor = (JavascriptExecutor ) driver ;
220306 if (!element .getAttribute ("id" ).equals ("" )) {
@@ -224,6 +310,12 @@ public static void clickJQuery(WebDriver driver, WebElement element) {
224310 }
225311 }
226312
313+ /**
314+ * Wait for Web page is loaded
315+ *
316+ * @param driver
317+ * @return
318+ */
227319 public static boolean waitForPageIsReady (WebDriver driver ) {
228320
229321 WebDriverWait wait = new WebDriverWait (driver , 30 );
0 commit comments