Skip to content

Commit a4156a2

Browse files
committed
[1.4.2-documentation] - added java docs
1 parent b20211c commit a4156a2

File tree

4 files changed

+143
-4
lines changed

4 files changed

+143
-4
lines changed

src/main/java/http/helpers/TextFinder.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ public class TextFinder {
1010

1111
private static double DERIVATION = 0.3;
1212

13+
/**
14+
* Smart Text finder that allows to fins piece of corrupted text
15+
*
16+
* @param pattern
17+
* @param text
18+
* @return
19+
*/
1320
public static boolean textIsFound(String pattern, String text) {
1421
pattern = pattern.toLowerCase();
1522
text = text.toLowerCase();
@@ -81,10 +88,15 @@ public static boolean textIsFound(String pattern, String text) {
8188
}
8289
}
8390

84-
public static void setDerivation(int derivation){
85-
if (derivation > 1){
91+
/**
92+
* Set derivation for text searching
93+
*
94+
* @param derivation
95+
*/
96+
public static void setDerivation(int derivation) {
97+
if (derivation > 1) {
8698
derivation = 1;
87-
}else if (derivation < 0){
99+
} else if (derivation < 0) {
88100
derivation = 0;
89101
}
90102
DERIVATION = derivation;

src/main/java/util/driver/DriverHelper.java

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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);

src/main/java/util/general/SystemHelper.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
import static util.validator.Constants.TARGET_AUTOMOTION_JSON;
88

99
public class SystemHelper {
10+
11+
/**
12+
* Verify is display is retina
13+
*
14+
* @return
15+
*/
1016
public static boolean isRetinaDisplay() {
1117
boolean isRetina = false;
1218
try {
@@ -30,6 +36,13 @@ public static boolean isRetinaDisplay() {
3036
return isRetina;
3137
}
3238

39+
/**
40+
* Convert hex color to rgb or rgba
41+
*
42+
* @param hexARGB
43+
* @return
44+
* @throws IllegalArgumentException
45+
*/
3346
public static String hexStringToARGB(String hexARGB) throws IllegalArgumentException {
3447

3548
if (!hexARGB.startsWith("#") || !(hexARGB.length() == 7 || hexARGB.length() == 9)) {
@@ -57,7 +70,7 @@ public static String hexStringToARGB(String hexARGB) throws IllegalArgumentExcep
5770
}
5871
}
5972

60-
public static boolean isAutomotionFolderExists(){
73+
public static boolean isAutomotionFolderExists() {
6174
File file = new File(TARGET_AUTOMOTION_JSON);
6275

6376
return file.exists() && file.isDirectory() && file.list() != null && file.list().length > 0;

src/main/java/util/validator/LanguageChecker.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ public class LanguageChecker {
2222

2323
private static final Logger LOG = Logger.getLogger(LanguageChecker.class);
2424

25+
/**
26+
* Return recognized language on the page. E.g: 'en', 'es', ...
27+
*
28+
* @param text
29+
* @return
30+
* @throws IOException
31+
*/
2532
public static Optional<LdLocale> getRecognisedLanguage(String text) throws IOException {
2633
List<LanguageProfile> languageProfiles = new LanguageProfileReader().readAllBuiltIn();
2734

@@ -36,6 +43,13 @@ public static Optional<LdLocale> getRecognisedLanguage(String text) throws IOExc
3643
return languageDetector.detect(textObject);
3744
}
3845

46+
/**
47+
* Return recognized language on the page. E.g: 'en', 'es', ...
48+
*
49+
* @param driver
50+
* @return
51+
* @throws IOException
52+
*/
3953
public static Optional<LdLocale> getRecognisedLanguage(WebDriver driver) throws IOException {
4054
List<LanguageProfile> languageProfiles = new LanguageProfileReader().readAllBuiltIn();
4155

@@ -50,6 +64,14 @@ public static Optional<LdLocale> getRecognisedLanguage(WebDriver driver) throws
5064
return languageDetector.detect(textObject);
5165
}
5266

67+
/**
68+
* Verify if correct language on the web/mobile page
69+
*
70+
* @param driver
71+
* @param lang
72+
* @return
73+
* @throws IOException
74+
*/
5375
public static boolean isCorrectLanguageOnThePage(WebDriver driver, String lang) throws IOException {
5476
boolean isCorrectLang = true;
5577
String bodyText = getTextFromPage(driver);

0 commit comments

Comments
 (0)