Source:android.view.InflateException Error inflating class android.webkit.WebView
long difference = (sDt4.getTime() - sDt3.getTime()) / 1000;
System.out.println(difference);
Best Testng code snippet using org.testng.Reporter
Source:Android_Hybrid.java
...78 79 sAppReference = (sAppReference.equals("")) ? "Default" : sAppReference;80 Utils.putObjectDriver(sTestName, driver, sAppReference);81 82 org.testng.Reporter.log("----------------------------------------------");83 org.testng.Reporter.log("STEP :: "+sDesc);84 org.testng.Reporter.log("App launched :: ");85 org.testng.Reporter.log(" ");86 }87 catch (Exception ex) { 88 89 org.testng.Reporter.log("----------------------------------------------");90 org.testng.Reporter.log("STEP :: "+sDesc);91 org.testng.Reporter.log("Exception :: "+ex);92 org.testng.Reporter.log(" ");93 }94 return driver;95 96 }97 /*98 * To type the text provided by user in the object99 */ 100 101 public static void native_Type(String sTestName, WebElement oEle, String sObjStr, String sVal) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {102 103 String sDesc = "" ; boolean flag = true; 104 105 try { 106 107 sVal = Utils.Helper.validateUserInput(sTestName, sVal);108 sDesc = Logs.log(sTestName) + " in Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " ) , Value = " + sVal ;109 110 try {111 oEle.clear(); Thread.sleep(500L); 112 }113 catch (Exception e) {114 flag = false;115 oEle.sendKeys(sVal);116 native_HideKeyboard(sTestName);117 118 }119 if(flag)120 oEle.sendKeys(sVal);121 native_HideKeyboard(sTestName);122 123 org.testng.Reporter.log("----------------------------------------------");124 org.testng.Reporter.log("STEP :: "+sDesc + " :: Performed");125 org.testng.Reporter.log(" ");126 127 } catch(Exception e) {128 if (Utils.handleIntermediateIssue()) { native_Type(sTestName, oEle, sObjStr, sVal); }129 130 org.testng.Reporter.log("----------------------------------------------");131 org.testng.Reporter.log("STEP :: "+sDesc);132 org.testng.Reporter.log("Exception :: "+e);133 screenShot(sTestName);134 org.testng.Reporter.log(" ");135 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);136 Assert.fail();137 }138 }139 140 /*141 * Scrolls Down to half the height of the screen 142 */143 144 public static void native_ScrollDown(String sTestName, WebElement oEle, String sObjStr) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {145 146 String sDesc = Logs.log(sTestName)+": Scroll to object : " +sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;147 148 try{149 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName); 150 151 Dimension size = lDriver.manage().window().getSize(); 152 int startx = (int) (size.width * 0.70); 153 int starty = size.height / 2; 154 int endy = (int) (size.height * 0.20);155 //lDriver.swipe(startx, starty, startx, endy, 3000); 156 new TouchAction(lDriver).press(startx, starty).waitAction(Duration.ofMillis(3000)).moveTo(startx,endy ).release().perform();157 while(!Helper.waitForElement(lDriver, oEle, 2)) {158 //lDriver.swipe(startx, starty, startx, endy, 3000); 159 new TouchAction(lDriver).press(startx, starty).waitAction(Duration.ofMillis(3000)).moveTo(startx,endy ).release().perform();160 }161 162 } catch(Exception e) {163 164 if (Utils.handleIntermediateIssue()) { native_ScrollDown(sTestName,oEle,sObjStr); }165 166 org.testng.Reporter.log("----------------------------------------------");167 org.testng.Reporter.log("STEP :: "+sDesc);168 org.testng.Reporter.log("Exception :: "+e);169 org.testng.Reporter.log(" ");170 }171 }172 /*173 * Perform the Scroll down function the number of time provided by user 174 */175 176 public static void native_Scroll_Ntimes(String sTestName, String sVal) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException, InvalidInputException {177 178 179 String sDesc = Logs.log(sTestName)+": Scroll : " +sVal + " times" ;180 181 sVal = Utils.Helper.validateUserInput(sTestName, sVal);182 int sValue= Integer.parseInt(sVal);183 184 try{185 186 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);187 Dimension dimensions = lDriver.manage().window().getSize();188 for(int i=0;i<sValue;i++) {189 190 Double screenHeightStart = dimensions.getHeight() * 0.5;191 Double screenHeightEnd = dimensions.getHeight() * 0.05;192 193 //lDriver.swipe(0, screenHeightStart.intValue(), 0, screenHeightEnd.intValue(), 2000);194 new TouchAction(lDriver).press(0, screenHeightStart.intValue()).waitAction(Duration.ofMillis(2000)).moveTo(0, screenHeightEnd.intValue()).release().perform();195 }196 197 198 org.testng.Reporter.log("----------------------------------------------");199 org.testng.Reporter.log("STEP :: "+sDesc + " :: Performed");200 org.testng.Reporter.log("Parameter :: "+sVal);201 org.testng.Reporter.log(" ");202 203 } catch(Exception e) {204 205 if (Utils.handleIntermediateIssue()) { native_Scroll_Ntimes(sTestName, sVal);; }206 207 org.testng.Reporter.log("----------------------------------------------");208 org.testng.Reporter.log("STEP :: "+sDesc);209 org.testng.Reporter.log("Exception :: "+e);210 org.testng.Reporter.log(" ");211 }212 }213 /*214 * Returns True if keyboard is displayed on screen.215 */216 217 public static boolean native_IsKeyboardPresent(String sTestName) throws HeadlessException, IOException, AWTException, InterruptedException {218 219 String checkKeyboardCommand = "adb shell dumpsys input_method";220 String sDesc = Logs.log(sTestName) + " :: Verifying Keyboard is Displayed or Not" ;221 boolean presentFlg = false;222 223 try {224 Process process = Runtime.getRuntime().exec(checkKeyboardCommand);225 BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));226 227 int read; char[] buffer = new char[4096]; StringBuffer output = new StringBuffer();228 while ((read = reader.read(buffer)) > 0) {229 output.append(buffer, 0, read);230 }231 reader.close(); process.waitFor();232 if (output.toString().contains("mInputShown=true"))233 presentFlg = true;234 235 org.testng.Reporter.log("----------------------------------------------");236 org.testng.Reporter.log("STEP :: "+sDesc);237 org.testng.Reporter.log("Expected Value :: True");238 org.testng.Reporter.log("Actual Value :: "+String.valueOf(presentFlg));239 org.testng.Reporter.log(" ");240 241 } catch(Exception e) {242 243 if (Utils.handleIntermediateIssue()) { native_IsKeyboardPresent(sTestName); }244 245 org.testng.Reporter.log("----------------------------------------------");246 org.testng.Reporter.log("STEP :: "+sDesc);247 org.testng.Reporter.log("Exception :: "+e);248 org.testng.Reporter.log(" ");249 }250 return presentFlg; 251 }252 253 /*254 * Hides Keyboard if it is displayed on screen.255 */256 public static boolean native_HideKeyboard(String sTestName) throws HeadlessException, IOException, AWTException, InterruptedException {257 258 259 String sDesc = Logs.log(sTestName) + " :: Hide Keyboard in Native App" ;260 boolean presentFlg = false;261 262 try {263 264 presentFlg = Helper.IsKeyboardPresent();265 if (presentFlg) {266 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);267 String drivercontext=lDriver.getContext();268 lDriver.context("NATIVE_APP");269 lDriver.hideKeyboard();270 lDriver.context(drivercontext);271 272 }273 274 275 org.testng.Reporter.log("----------------------------------------------");276 org.testng.Reporter.log("STEP :: "+sDesc+":: Performed");277 org.testng.Reporter.log(" "); 278 } catch(Exception e) {279 280 if (Utils.handleIntermediateIssue()) { native_HideKeyboard(sTestName); } 281 org.testng.Reporter.log("----------------------------------------------");282 org.testng.Reporter.log("STEP :: "+sDesc);283 org.testng.Reporter.log("Exception :: "+e);284 org.testng.Reporter.log(" ");285 }286 return presentFlg; 287 }288 289 /*290 * Switches Context in the Native app from NATIVE to WEBVIEW or vice versa291 * 292 */293 294 @SuppressWarnings("unchecked")295 public static void switchContext(String sTestName, String Text) throws HeadlessException, IOException, AWTException, InterruptedException {296 297 String sDesc = Logs.log(sTestName) + " :: Switch to Context : " + Text ;298 299 try {300 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);301 Set<String> contexts = lDriver.getContextHandles(); 302 for(String s:contexts) { 303 if(s.contains(Text)) 304 lDriver.context(s); 305 } 306 307 } catch(Exception e) {308 if (Utils.handleIntermediateIssue()) { switchContext(sTestName, Text); } 309 org.testng.Reporter.log("----------------------------------------------");310 org.testng.Reporter.log("STEP :: "+sDesc);311 org.testng.Reporter.log("Exception :: "+e);312 org.testng.Reporter.log(" ");313 }314 }315/* public static void ahNative_SwipeInDropdown(String sTestName,WebElement oEle, String sObjStr, String Text) throws HeadlessException, IOException, AWTException, InterruptedException { 316 317 String sDesc = Logs.log(sTestName);318 319 try { 320 321 Text = Utils.Helper.validateUserInput(sTestName, Text); 322 sDesc=Logs.log(sTestName); 323 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName); 324 325 Dimension size = lDriver.manage().window().getSize(); 326 int startx = (int) (size.width * 0.70); 327 int starty = size.height / 2; 328 int endy = (int) (size.height * 0.20); 329 330 331 while (!ahVerify_ElementPresent(sTestName, oEle, sObjStr, "")) 332 { 333 if (Text.contains("VERTICALT2B")){ 334 //Swipe from Top to Bottom. 335 lDriver.swipe(startx, endy, startx, starty, 3000); 336 Thread.sleep(2000); 337 } 338 else if (Text.contains("VERTICALB2T")) { 339 //Swipe from Bottom to Top. 340 lDriver.swipe(startx, starty, startx, endy, 3000); 341 Thread.sleep(2000); 342 } 343 344 Reporter.print(sTestName, sDesc+" :: Performed"); 345 } 346 } catch(Exception e) { 347 348 if (Utils.handleIntermediateIssue()) { ahNative_SwipeInDropdown(sTestName,oEle,sObjStr, Text); } 349 Reporter.printError(sTestName, e, sDesc); 350 } 351 }*/352 /**353 * @param sTestName354 * @param sBrowserPref355 * @return356 * @throws AWTException 357 * @throws HeadlessException 358 * @throws Exception359 */360 361 /*362 * Closes the NativeApp363 */ 364 public static void native_closeApp(String sTestName) throws IOException, InterruptedException, HeadlessException, AWTException {365 try {366 ((AppiumDriver)Utils.getObjectDriver(sTestName)).quit();367 Thread.sleep(1900); 368 org.testng.Reporter.log("----------------------------------------------");369 org.testng.Reporter.log("CLOSE PERFORMED");370 org.testng.Reporter.log(" ");371 } catch(Exception e)372 {373 374 org.testng.Reporter.log("----------------------------------------------");375 org.testng.Reporter.log("STEP :: PROBLEM IN CLOSING");376 org.testng.Reporter.log("Exception :: "+e);377 org.testng.Reporter.log(" ");378 }379 }380 381 public static Object ahSet_CurrentReference(String sTestName, String sBrowserReference) throws HeadlessException, IOException, AWTException, InterruptedException {382 383 return Utils.Set_CurrentObjectReference(sTestName, sBrowserReference);384 }385 public static void set_AndroidPreference(String sTestName, String sPreferences, String sValue) throws HeadlessException, IOException, AWTException, InterruptedException { // TODO - Expose List of Prefs386 Hashtable <String, String > hPref = new Hashtable<>();387 hPref.put(sPreferences, sValue);388 389 String sDesc = Logs.log(sTestName);390 391 try { 392 sPreferences=Utils.Helper.validateUserInput(sTestName, sPreferences);393 sValue=Utils.Helper.validateUserInput(sTestName, sValue);394 if (Android_Web.h2AndroidPrefs.containsKey(sTestName))395 Android_Web.h2AndroidPrefs.get(sTestName).put(sPreferences, sValue);396 else {397 Android_Web.h2AndroidPrefs.put(sTestName,hPref);398 }399 400 401 org.testng.Reporter.log("--------------------------------------------------");402 org.testng.Reporter.log("STEP :: "+sDesc);403 org.testng.Reporter.log ("\nAndroid Preference :" + sPreferences + " Set to : " + sValue + " -- Done");404 org.testng.Reporter.log(" ");405 406 } catch (Exception ex) { 407 408 org.testng.Reporter.log("----------------------------------------------");409 org.testng.Reporter.log("STEP :: "+sDesc);410 org.testng.Reporter.log("Exception :: "+ex);411 org.testng.Reporter.log(" ");412 413 }414 }415 416 /*417 * Verifies the text of the alert box present.418 * Usage : To check whether expected alert has popped up or not.419 * 420 * User has to provide the text , the same is then checked whether it is equal to the text of the alert.421 * Note:422 * If user want to stop the test execution against a validation failure, append *EXIT_ON_FAIL* at end of argument.423 * For negative validation, append *NOT* at end of argument. E.g. <Arg_By_User>*NOT*424 * Append *EXIT_ON_FAIL**NOT* for both cases to work simultaneously.425 *426 * Parameter 1 - test case name427 * Parameter 2 - expected text in alert box428 * */ 429 430 public static boolean verify_Alert(String sTestName, String sExpAlertTxt) throws HeadlessException, IOException, AWTException, InterruptedException {431 String sDesc, sActVal, sExpVal; boolean bStatus = false;432 sDesc = Logs.log(sTestName);433 434 435 try { 436 sExpAlertTxt = Utils.Helper.validateUserInput(sTestName, sExpAlertTxt);437 sExpVal = Reporter.filterUserInput(sExpAlertTxt);438 439 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);440 sActVal = lDriver.switchTo().alert().getText();441 lDriver.switchTo().alert().accept(); 442 443 bStatus = sExpVal.equals(sActVal);444 org.testng.Reporter.log("--------------------------------------------------");445 org.testng.Reporter.log("STEP :: "+sDesc);446 org.testng.Reporter.log("expected Value :: "+sExpVal);447 org.testng.Reporter.log("Actual Value :: "+sActVal);448 org.testng.Reporter.log("Step Status ::"+bStatus); 449 screenShot(sTestName);450 org.testng.Reporter.log(" ");451 452 } catch(Exception e) {453 454 if (Utils.handleIntermediateIssue()) { verify_Alert(sTestName, sExpAlertTxt); }455 456 org.testng.Reporter.log("----------------------------------------------");457 org.testng.Reporter.log("STEP :: "+sDesc);458 org.testng.Reporter.log("Exception :: "+e);459 screenShot(sTestName);460 org.testng.Reporter.log(" ");461 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);462 Assert.fail();463 }464 return bStatus;465 }466 /*467 * Used to set current execution platform e.g Execution type :: WEB and Execution platform :: chrome468 * 469 * Parameter 1 : test case name470 * Parameter 2 : execution type(Web/Mobile)471 * Parameter 3 : Execution platform (Browser name)472 * */ 473 474 public static void set_CurrentPlatform(String sTestName,String sExeType,String sExe_platfrom) throws HeadlessException, IOException, AWTException {475 try{476 Utils.set_CurrentPlatform(sTestName, sExeType, sExe_platfrom);477 }478 catch(Exception e) {479 System.out.println(e);480 }481 }482 483 @SuppressWarnings("unused")484 public static boolean verify_AlertPresent(String sTestName, String sVal) throws HeadlessException, IOException, AWTException, InterruptedException {485 486 String sDesc, sExpVal ; boolean bStatus = false;487 sDesc = Logs.log(sTestName); 488 try { 489 sVal = Utils.Helper.validateUserInput(sTestName, sVal);490 sExpVal = Reporter.filterUserInput(sVal);491 492 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);493 WebDriverWait wait = new WebDriverWait(lDriver, 20);494 495 try {496 if (wait.until(ExpectedConditions.alertIsPresent()) != null) { bStatus = true; }497 }498 catch (Exception e) {}499 500 org.testng.Reporter.log("--------------------------------------------------");501 org.testng.Reporter.log("STEP :: "+sDesc);502 org.testng.Reporter.log("prameter Value :: "+sVal);503 org.testng.Reporter.log("expected Value :: "+sExpVal);504 org.testng.Reporter.log("Step Status ::"+bStatus);505 screenShot(sTestName);506 org.testng.Reporter.log(" ");507 } catch(Exception e) {508 509 if (Utils.handleIntermediateIssue()) { verify_AlertPresent(sTestName,sVal); }510 511 org.testng.Reporter.log("----------------------------------------------");512 org.testng.Reporter.log("STEP :: "+sDesc);513 org.testng.Reporter.log("Exception :: "+e);514 screenShot(sTestName);515 org.testng.Reporter.log(" ");516 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);517 Assert.fail();518 }519 return bStatus;520 }521 522 /*523 * to clear web element524 **/ 525 public static void clear(String sTestName, WebElement oEle, String sObjStr) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {526 527 String sDesc = "" ; 528 529 try { 530 531 sDesc = Logs.log(sTestName) + " Clear in Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " ) " ;532 //Helper.checkReady(sTestName, oEle);533 oEle.clear(); Thread.sleep(500L); 534 org.testng.Reporter.log("----------------------------------------------");535 org.testng.Reporter.log("STEP :: "+sDesc+" :: Performed");536 org.testng.Reporter.log("CLOSE PERFORMED");537 org.testng.Reporter.log(" ");538 }539 catch(Exception e) {540 541 if (Utils.handleIntermediateIssue()) { clear(sTestName, oEle, sObjStr); } 542 org.testng.Reporter.log("----------------------------------------------");543 org.testng.Reporter.log("STEP :: "+sDesc);544 org.testng.Reporter.log("Exception :: "+e);545 screenShot(sTestName);546 org.testng.Reporter.log(" ");547 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);548 Assert.fail();549 }550 }551 552 /*553 * Verifies the value of the attribute in given object.554 * Usage : To verify values of attributes like class,name,id,style,width etc.555 * 556 * Parameter 1 : test case name557 * Parameter 2 : xPath from object map558 * Parameter 3 : xPath from object map in string format559 * Parameter 4 : provide the attribute name 560 * Parameter 5 : expected value e.g. ""width"" in parameter 4 and its value ""500px"" in parameter 5.561 * 562 * Note:563 * If user want to stop the test execution against a validation failure, append *EXIT_ON_FAIL* at end of argument.564 * For negative validation, append *NOT* at end of argument. E.g. <Arg_By_User>*NOT*565 * Append *EXIT_ON_FAIL**NOT* for both cases to work simultaneously."566 *567 * */568 569 public static boolean verify_Attribute(String sTestName, WebElement oEle, String sObjStr, String sAttribName,String sExpVal) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {570 String sDesc, sActVal, sVal=sAttribName; boolean bStatus = false; 571 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )";572 try { 573 sAttribName = Utils.Helper.validateUserInput(sTestName, sAttribName);574 sExpVal = Utils.Helper.validateUserInput(sTestName, sExpVal);575 sAttribName = Reporter.filterUserInput(sAttribName); 576 //Helper.checkReady(sTestName, oEle);577 sActVal= oEle.getAttribute(sAttribName);578 579 bStatus = sExpVal.equals(sActVal); 580 org.testng.Reporter.log("--------------------------------------------------");581 org.testng.Reporter.log("STEP :: "+sDesc+ " :: Validate the atttibute - ");582 org.testng.Reporter.log("prameter Value :: "+sVal);583 org.testng.Reporter.log("expected Value :: "+sExpVal);584 org.testng.Reporter.log("Step Status ::"+bStatus);585 screenShot(sTestName);586 org.testng.Reporter.log(" ");587 } catch(Exception e) {588 589 if (Utils.handleIntermediateIssue()) { verify_Attribute(sTestName, oEle, sObjStr,sVal, sExpVal); }590 591 org.testng.Reporter.log("----------------------------------------------");592 org.testng.Reporter.log("STEP :: "+sDesc);593 org.testng.Reporter.log("Exception :: "+e);594 screenShot(sTestName);595 org.testng.Reporter.log(" ");596 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);597 Assert.fail();598 }599 return bStatus;600 }601 /*602 * Verifies whether the object is selected or not.603 * Usage : Check whether checkbox/radiobutton is selected or not.604 * 605 * Note:606 * If user want to stop the test execution against a validation failure, append *EXIT_ON_FAIL* at end of argument.607 * For negative validation, append *NOT* at end of argument. E.g. <Arg_By_User>*NOT*608 * Append *EXIT_ON_FAIL**NOT* for both cases to work simultaneously.609 * 610 * Parameter 1 : test case name611 * Parameter 2 : xPath from object map612 * Parameter 3 : xPath from object map in string format613 * Parameter 4 : value of check box614 * */615 public static boolean verify_Checked(String sTestName, WebElement oEle, String sObjStr, String sVal) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {616 617 String sDesc; boolean bStatus = false;618 619 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;620 621 622 try { 623 sVal = Utils.Helper.validateUserInput(sTestName, sVal);624 Reporter.filterUserInput(sVal);625 //Helper.checkReady(sTestName, oEle);626 627 if (oEle.isSelected()) {628 bStatus = true;629 }630 631 org.testng.Reporter.log("--------------------------------------------------");632 org.testng.Reporter.log("STEP :: "+sDesc);633 org.testng.Reporter.log("prameter Value :: "+sVal);634 org.testng.Reporter.log("Step Status ::"+bStatus);635 screenShot(sTestName);636 org.testng.Reporter.log(" ");637 638 } catch(Exception e) {639 640 if (Utils.handleIntermediateIssue()) { verify_Checked(sTestName, oEle, sObjStr, sVal); }641 642 org.testng.Reporter.log("----------------------------------------------");643 org.testng.Reporter.log("STEP :: "+sDesc);644 org.testng.Reporter.log("Exception :: "+e);645 screenShot(sTestName);646 org.testng.Reporter.log(" ");647 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);648 Assert.fail();649 }650 return bStatus;651 }652 /*653 * Verifies the value of the cookie.654 * 655 * Parameter 1 : test case name656 * Parameter 2 : Provide the cookie name 657 * Parameter 3 : Expected value 658 * e.g. "domain_name" in Parameter 2 and its value "http://www.google.com" in Parameter 3.659 * Note:660 * If user want to stop the test execution against a validation failure, append *EXIT_ON_FAIL* at end of argument.661 * For negative validation, append *NOT* at end of argument. E.g. <Arg_By_User>*NOT*662 * Append *EXIT_ON_FAIL**NOT* for both cases to work simultaneously."663 *664 * */665 666 public static boolean verify_Cookies(String sTestName,String sCookieName, String sExpVal) throws HeadlessException, IOException, AWTException, InterruptedException {667 668 String sDesc, sActVal,sVal=sCookieName; boolean bStatus = false;669 670 sDesc = Logs.log(sTestName);671 672 673 try { 674 sCookieName = Utils.Helper.validateUserInput(sTestName, sCookieName);675 sExpVal = Utils.Helper.validateUserInput(sTestName, sExpVal);676 sCookieName = Reporter.filterUserInput(sCookieName);677 678 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);679 sActVal = lDriver.manage().getCookieNamed(sCookieName).getValue();680 bStatus = sExpVal.equals(sActVal); 681 org.testng.Reporter.log("--------------------------------------------------");682 org.testng.Reporter.log("STEP :: "+sDesc);683 org.testng.Reporter.log("prameter Value :: "+sVal);684 org.testng.Reporter.log("expected Value :: "+sExpVal);685 org.testng.Reporter.log("Step Status ::"+bStatus);686 screenShot(sTestName);687 org.testng.Reporter.log(" ");688 689 } catch(Exception e) {690 691 if (Utils.handleIntermediateIssue()) { verify_Cookies(sTestName, sVal,sExpVal); }692 693 org.testng.Reporter.log("----------------------------------------------");694 org.testng.Reporter.log("STEP :: "+sDesc);695 org.testng.Reporter.log("Exception :: "+e);696 screenShot(sTestName);697 org.testng.Reporter.log(" ");698 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);699 Assert.fail();700 }701 return bStatus;702 }703 /*704 * Verifies whether object is Enabled or not. 705 * 706 * Parameter 1 : Test case name707 * Parameter 2 : xPath from object map708 * Parameter 3 : xPath from object map in string format709 * Parameter 4 : expected value to be checked [optional]710 * 711 * Note:712 * If user want to stop the test execution against a validation failure, append *EXIT_ON_FAIL* at end of argument.713 * For negative validation, append *NOT* at end of argument. E.g. <Arg_By_User>*NOT*714 * Append *EXIT_ON_FAIL**NOT* for both cases to work simultaneously.715 * */ 716 public static boolean verify_Editable(String sTestName, WebElement oEle, String sObjStr, String sVal) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {717 718 String sDesc; boolean bStatus = false; 719 720 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;721 722 try { 723 724 sVal = Utils.Helper.validateUserInput(sTestName, sVal);725 Reporter.filterUserInput(sVal);726 //Helper.checkReady(sTestName, oEle);727 728 if (oEle.isEnabled()) { 729 bStatus = true;730 }731 732 org.testng.Reporter.log("--------------------------------------------------");733 org.testng.Reporter.log("STEP :: "+sDesc);734 org.testng.Reporter.log("prameter Value :: "+sVal);735 org.testng.Reporter.log("Step Status ::"+bStatus);736 screenShot(sTestName);737 org.testng.Reporter.log(" ");738 739 } catch(Exception e) {740 741 if (Utils.handleIntermediateIssue()) { verify_Editable(sTestName, oEle, sObjStr, sVal); }742 743 org.testng.Reporter.log("----------------------------------------------");744 org.testng.Reporter.log("STEP :: "+sDesc);745 org.testng.Reporter.log("Exception :: "+e);746 screenShot(sTestName);747 org.testng.Reporter.log(" ");748 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);749 Assert.fail();750 }751 return bStatus;752 }753 /*754 * It Works for following 3 scenarios: 755 * To verify the Height of the object.756 * To verify the width of the object.757 * To verify both height and width of the object.758 * 759 * Parameter 1 : test case name.760 * Parameter 2 : xPath from object map.761 * Parameter 3 : xPath from object map in string format.762 * Parameter 4 : provide the attribute name763 * Parameter 5 : expected value 764 * e.g. "height" in Parameter 4 and its value "200px" in Parameter 5.765 * "width" in Parameter 4 and its value "100px" in Parameter 5.766 * for both, ""Both"" in Parameter 4 and value in Variable name like ""200|500"".767 *768 * Note:769 * If user want to stop the test execution against a validation failure, append *EXIT_ON_FAIL* at end of argument.770 * For negative validation, append *NOT* at end of argument. E.g. <Arg_By_User>*NOT*771 * Append *EXIT_ON_FAIL**NOT* for both cases to work simultaneously."772 *773 * */ 774 public static boolean verify_Object_Dimension(String sTestName, WebElement oEle, String sObjStr, String sDimenType,String sDimenVal) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {775 String sDesc, sActVal = null,sVal=sDimenType; boolean bStatus = false;776 777 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;778 779 780 try { 781 sDimenType = Utils.Helper.validateUserInput(sTestName, sDimenType);782 sDimenVal = Utils.Helper.validateUserInput(sTestName, sDimenVal);783 sDimenType = Reporter.filterUserInput(sDimenType);784 785 //Helper.checkReady(sTestName, oEle);786 787 if (sDimenType.equalsIgnoreCase("Height")) {788 sActVal = String.valueOf(oEle.getSize().getHeight());789 790 } else if (sDimenType.equalsIgnoreCase("Width")) {791 sActVal = String.valueOf(oEle.getSize().getWidth());792 793 } else if (sDimenType.equalsIgnoreCase("Both")) {794 795 sActVal = String.valueOf(oEle.getSize().getHeight()) + "|" + String.valueOf(oEle.getSize().getWidth());796 }797 798 bStatus = sDimenVal.equals(sActVal);799 800 org.testng.Reporter.log("--------------------------------------------------");801 org.testng.Reporter.log("STEP :: "+sDesc + " :: DimenType - " + sDimenType+", DimenVal :: "+sDimenVal);802 org.testng.Reporter.log("Actual Value :: "+sActVal); 803 org.testng.Reporter.log("Step Status ::"+bStatus);804 screenShot(sTestName);805 org.testng.Reporter.log(" ");806 807 } catch(Exception e) {808 809 if (Utils.handleIntermediateIssue()) { verify_Object_Dimension(sTestName, oEle, sObjStr, sVal,sDimenVal); }810 811 org.testng.Reporter.log("----------------------------------------------");812 org.testng.Reporter.log("STEP :: "+sDesc);813 org.testng.Reporter.log("Exception :: "+e);814 screenShot(sTestName);815 org.testng.Reporter.log(" ");816 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);817 Assert.fail();818 }819 return bStatus;820 }821 /*822 * Verifies whether Element Is Displayed on page or not.823 * To Check element presence before performing any operation on it.824 * 825 * Argument is optional. User can provide argument for negation and Exit_on_Fail.826 * Note:827 * If user want to stop the test execution against a validation failure, write *EXIT_ON_FAIL* as argument.828 * For negative validation, write *NOT* as argument. E.g. *NOT*829 * Append *EXIT_ON_FAIL**NOT* for both cases to work simultaneously.830 *831 * Parameter 1 : test case name [mandatory]832 * Parameter 2 : xpath from object map [mandatory]833 * Parameter 3 : xpath from object map in string format [mandatory]834 * Parameter 4 : Element to be verified [optional]835 * */836 837 public static boolean verify_ElementPresent(String sTestName, WebElement oEle, String sObjStr, String sVal) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {838 839 String sDesc; boolean bStatus = false; 840 841 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;842 843 try { 844 845 sVal = Utils.Helper.validateUserInput(sTestName, sVal);846 Reporter.filterUserInput(sVal);847 //Helper.checkReady(sTestName, oEle);848 AppiumDriver driver = (AppiumDriver)Utils.getObjectDriver(sTestName);849 try {850 851 bStatus = Helper.waitForElement(driver,oEle, Integer.parseInt(Utils.hEnvParams.get("OBJ_TIMEOUT")));852 853 org.testng.Reporter.log("--------------------------------------------------");854 org.testng.Reporter.log("STEP :: "+sDesc);855 org.testng.Reporter.log("prameter Value :: "+sVal);856 org.testng.Reporter.log("Step Status ::"+bStatus);857 screenShot(sTestName);858 org.testng.Reporter.log(" ");859 860 }861 catch (NoSuchElementException e) {862 863 org.testng.Reporter.log("----------------------------------------------");864 org.testng.Reporter.log("STEP :: "+sDesc);865 org.testng.Reporter.log("Exception :: "+e);866 org.testng.Reporter.log("Step Status ::"+bStatus);867 screenShot(sTestName);868 org.testng.Reporter.log(" ");869 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);870 Assert.fail();871 }872 873 874 } catch(Exception e) {875 876 if (Utils.handleIntermediateIssue()) { verify_ElementPresent(sTestName, oEle, sObjStr, sVal); }877 878 org.testng.Reporter.log("----------------------------------------------");879 org.testng.Reporter.log("STEP :: "+sDesc);880 org.testng.Reporter.log("Exception :: "+e);881 screenShot(sTestName);882 org.testng.Reporter.log(" ");883 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);884 Assert.fail();885 }886 return bStatus;887 }888 889 /*890 * Verifies the text given as argument matches the actual text of the object.891 * 892 * 893 * Parameter 1 : test case name894 * Parameter 2 : xpath from object map895 * Parameter 3 : xpath from object map in string format896 * Parameter 4 : expected text which needs to be verified897 * 898 * Note:899 * If user want to stop the test execution against a validation failure, write *EXIT_ON_FAIL* as argument.900 * For negative validation, write *NOT* as argument. E.g. *NOT*901 * Append *EXIT_ON_FAIL**NOT* for both cases to work simultaneously.902 * 903 * */904 public static boolean verify_Text(String sTestName, WebElement oEle, String sObjStr, String sExpText) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {905 906 String sDesc, sActVal = null, sExpVal; boolean bStatus = false;907 908 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;909 910 try { 911 912 sExpText = Utils.Helper.validateUserInput(sTestName, sExpText);913 sExpVal = Reporter.filterUserInput(sExpText);914 //Helper.checkReady(sTestName, oEle);915 916 sActVal = oEle.getText();917 bStatus = sExpVal.equalsIgnoreCase(sActVal);918 919 920 org.testng.Reporter.log("--------------------------------------------------");921 org.testng.Reporter.log("STEP :: "+sDesc);922 org.testng.Reporter.log("Actual Value :: "+sActVal);923 org.testng.Reporter.log("expected Value :: "+sExpVal);924 org.testng.Reporter.log("Step Status ::"+bStatus);925 screenShot(sTestName);926 org.testng.Reporter.log(" ");927 928 } catch(Exception e) {929 930 if (Utils.handleIntermediateIssue()) { verify_Text(sTestName, oEle, sObjStr, sExpText); }931 932 org.testng.Reporter.log("----------------------------------------------");933 org.testng.Reporter.log("STEP :: "+sDesc);934 org.testng.Reporter.log("Exception :: "+e);935 screenShot(sTestName);936 org.testng.Reporter.log(" ");937 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);938 Assert.fail();939 }940 return bStatus;941 942 }943 /*944 * Checks if two values provided are equal or not. It is Case-Sensitive.945 * Usage : User can match a stored value in local parameters to another value.946 * 947 * Parameter 1 : test case name948 * parameter 2: value 1 949 * Parameter 3 : value 2 950 * e.g. ""Local{UserName}"" in parameter 2 and ""User1"" in parameter 3 .951 *952 * Note:953 * If user want to stop the test execution against a validation failure, append *EXIT_ON_FAIL* at end of argument.954 * For negative validation, append *NOT* at end of argument. E.g. <Arg_By_User>*NOT*955 * Append *EXIT_ON_FAIL**NOT* for both cases to work simultaneously."956 * 957 * */ 958 public static boolean equals(String sTestName, String sExpVal,String sActVal) throws HeadlessException, IOException, AWTException, InterruptedException {959 960 String sDesc = "",sVal=sExpVal; boolean bStatus = false;961 962 try { 963 964 sExpVal = Utils.Helper.validateUserInput(sTestName, sExpVal);965 sActVal = Utils.Helper.validateUserInput(sTestName, sActVal);966 sDesc = Logs.log(sTestName) + " :: Values - " + sExpVal +" And "+ sActVal;967 sExpVal = Reporter.filterUserInput(sExpVal);968 969 bStatus = sExpVal.equals(sActVal);970 971 org.testng.Reporter.log("--------------------------------------------------");972 org.testng.Reporter.log("STEP :: "+sDesc);973 org.testng.Reporter.log("Actual Value :: "+sActVal);974 org.testng.Reporter.log("expected Value :: "+sExpVal);975 org.testng.Reporter.log("Step Status ::"+bStatus);976 org.testng.Reporter.log(" ");977 978 } catch(Exception e) {979 980 if (Utils.handleIntermediateIssue()) { equals(sTestName, sVal,sActVal); }981 982 org.testng.Reporter.log("----------------------------------------------");983 org.testng.Reporter.log("STEP :: "+sDesc);984 org.testng.Reporter.log("Exception :: "+e);985 org.testng.Reporter.log(" ");986 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);987 Assert.fail();988 }989 return bStatus;990 }991 992 /*993 * Verifies whether the value given as argument is present in HTML code of the page or not.994 * 995 * Parameter 1 : test case name996 * Parameter 2 : Expected value which need to be verified in HTML source997 * */998 public static boolean verifyIn_HTMLSource(String sTestName, String sExpText) throws HeadlessException, IOException, AWTException, InterruptedException {999 1000 String sDesc, sExpVal; boolean bStatus = false;1001 sDesc = Logs.log(sTestName) + " :: Values - " + sExpText;1002 sExpVal = Reporter.filterUserInput(sExpText);1003 1004 try { 1005 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1006 1007 bStatus = lDriver.getPageSource().contains(sExpVal);1008 //Reporter.print(sTestName, sExpText, sDesc, "NA", "NA", bStatus, Helper.takeScreenshot((AppiumDriver)Utils.getObjectDriver(sTestName)));1009 org.testng.Reporter.log("--------------------------------------------------");1010 org.testng.Reporter.log("STEP :: "+sDesc);1011 1012 org.testng.Reporter.log("expected Value :: "+sExpVal);1013 //org.testng.Reporter.log("expected Text :: "+ sExpText);1014 org.testng.Reporter.log("Step Status ::"+bStatus);1015 screenShot(sTestName);1016 org.testng.Reporter.log(" ");1017 1018 } catch(Exception e) {1019 1020 if (Utils.handleIntermediateIssue()) { verifyIn_HTMLSource(sTestName, sExpText); }1021 1022 org.testng.Reporter.log("----------------------------------------------");1023 org.testng.Reporter.log("STEP :: "+sDesc);1024 org.testng.Reporter.log("Exception :: "+e);1025 screenShot(sTestName);1026 org.testng.Reporter.log(" ");1027 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1028 Assert.fail();1029 1030 }1031 return bStatus;1032 }1033 /*1034 * Verifies the current URL of the Browser contains expected URL given as argument.1035 * Usage : User can assure whether he is on the right page as expected.1036 * 1037 * Parameter 1 : test case name1038 * Parameter 2 : User has to provide the URL , the same is then checked whether it is contained in the URL of the current page1039 * 1040 * Note:1041 * If user want to stop the test execution against a validation failure, append *EXIT_ON_FAIL* at end of argument.1042 * For negative validation, append *NOT* at end of argument. E.g. <Arg_By_User>*NOT*1043 * Append *EXIT_ON_FAIL**NOT* for both cases to work simultaneously."1044 * */ 1045 1046 public static boolean verifyIn_URL(String sTestName, String sExpText) throws HeadlessException, IOException, AWTException, InterruptedException {1047 1048 String sDesc, sActVal = null, sExpVal; boolean bStatus = false;1049 sDesc = Logs.log(sTestName);1050 1051 try { 1052 sExpText = Utils.Helper.validateUserInput(sTestName, sExpText);1053 sExpVal = Reporter.filterUserInput(sExpText);1054 1055 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1056 1057 sActVal = lDriver.getCurrentUrl();1058 bStatus = sActVal.contains(sExpVal);1059 //Reporter.print(sTestName, sExpText, sDesc, sExpVal, sActVal, bStatus, Helper.takeScreenshot(lDriver));1060 org.testng.Reporter.log("--------------------------------------------------");1061 org.testng.Reporter.log("STEP :: "+sDesc);1062 org.testng.Reporter.log("Actual Value :: "+sActVal);1063 org.testng.Reporter.log("expected Value :: "+sExpVal);1064 org.testng.Reporter.log("Step Status ::"+bStatus);1065 //org.testng.Reporter.log("expected Text :: "+sExpText);1066 screenShot(sTestName);1067 org.testng.Reporter.log(" ");1068 1069 } catch(Exception e) {1070 1071 if (Utils.handleIntermediateIssue()) { verifyIn_URL(sTestName, sExpText); }1072 1073 org.testng.Reporter.log("----------------------------------------------");1074 org.testng.Reporter.log("STEP :: "+sDesc);1075 org.testng.Reporter.log("Exception :: "+e);1076 screenShot(sTestName);1077 org.testng.Reporter.log(" ");1078 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1079 Assert.fail();1080 }1081 return bStatus;1082 }1083 /*1084 * Verifies whether the options given as parameter are present in SelectBox or not. 1085 * Usage : To Verify option presence in SelectBox before selecting it.1086 * 1087 * Parameter 1 : test case name1088 * Parameter 2 : xPath from object map1089 * Parameter 3 : xPath from object map in string format1090 * Parameter 4 : User has to provide the options separated by a "|", same are then checked whether they are present in SelectBox or not. 1091 * e.g.Option1|Option2|........|OptionN1092 * Note:1093 * If user want to stop the test execution against a validation failure, append *EXIT_ON_FAIL* at end of argument.1094 * For negative validation, append *NOT* at end of argument. E.g. <Arg_By_User>*NOT*1095 * Append *EXIT_ON_FAIL**NOT* for both cases to work simultaneously.1096 * 1097 * */1098 public static boolean verify_SelectOptions(String sTestName, WebElement oEle, String sObjStr, String sExpOptions) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {1099 String sDesc, sActVal = null, sExpVal; boolean bStatus = false;1100 1101 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )";1102 1103 1104 try { 1105 1106 sExpOptions = Utils.Helper.validateUserInput(sTestName, sExpOptions);1107 sExpVal = Reporter.filterUserInput(sExpOptions);1108 //Helper.checkReady(sTestName, oEle);1109 1110 if(oEle.getTagName().toString().equalsIgnoreCase("select")){1111 1112 Select selList = new Select(oEle); List<WebElement> oSize = selList.getOptions();1113 for(int i =0; i<oSize.size(); i++) { 1114 sActVal = sActVal + "|" + selList.getOptions().get(i).getText(); 1115 } 1116 1117 for (String sExpOption: sExpVal.split("\\|")) {1118 1119 if (!sActVal.contains(sExpOption)) {1120 bStatus = false; break;1121 } else 1122 bStatus = true;1123 }1124 1125 org.testng.Reporter.log("--------------------------------------------------");1126 org.testng.Reporter.log("STEP :: "+sDesc);1127 org.testng.Reporter.log("Actual Value :: "+sActVal);1128 org.testng.Reporter.log("expected Value :: "+sExpVal);1129 org.testng.Reporter.log("Step Status ::"+bStatus);1130 screenShot(sTestName);1131 org.testng.Reporter.log(" ");1132 }1133 else1134 Reporter.print(sTestName, sDesc + " :: Error : This Method Works only for Html : 'Select' tag");1135 } catch(Exception e) {1136 1137 if (Utils.handleIntermediateIssue()) { verify_SelectOptions(sTestName, oEle, sObjStr, sExpOptions); }1138 1139 org.testng.Reporter.log("----------------------------------------------");1140 org.testng.Reporter.log("STEP :: "+sDesc);1141 org.testng.Reporter.log("Exception :: "+e);1142 screenShot(sTestName);1143 org.testng.Reporter.log(" ");1144 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1145 Assert.fail();1146 }1147 return bStatus;1148 }1149 /*1150 * Verifies whether the options provided in parameters are selected in the selectBox.1151 * 1152 * Parameter 1 : test case name1153 * Parameter 2 : xPath from object map1154 * Parameter 3 : xPath from object map in string format1155 * Parameter 4 : User has to provide options to be checked separated by a pipe "|". e.g. "Option1|Option2"1156 * 1157 * */1158 1159 public static boolean verify_SelectedOptions(String sTestName, WebElement oEle, String sObjStr, String sExpOptions) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {1160 1161 String sDesc, sActVal = null, sExpVal; boolean bStatus = false;1162 1163 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )";1164 1165 try {1166 1167 sExpOptions = Utils.Helper.validateUserInput(sTestName, sExpOptions);1168 sExpVal = Reporter.filterUserInput(sExpOptions);1169 //Helper.checkReady(sTestName, oEle);1170 1171 if(oEle.getTagName().toString().equalsIgnoreCase("select")){1172 1173 Select selList = new Select(oEle); List<WebElement> oSize = selList.getAllSelectedOptions();1174 for(int i =0; i<oSize.size(); i++) { 1175 sActVal = sActVal + "|" + selList.getAllSelectedOptions().get(i).getText(); 1176 } 1177 1178 for (String sExpOption: sExpVal.split("\\|")) {1179 1180 if (!sActVal.contains(sExpOption)) {1181 bStatus = false; break;1182 } else 1183 bStatus = true;1184 }1185 1186 1187 org.testng.Reporter.log("--------------------------------------------------");1188 org.testng.Reporter.log("STEP :: "+sDesc);1189 org.testng.Reporter.log("Actual Value :: "+sActVal);1190 org.testng.Reporter.log("expected Value :: "+sExpVal);1191 org.testng.Reporter.log("Step Status ::"+bStatus);1192 //org.testng.Reporter.log("exoptions ::"+sExpOptions);1193 screenShot(sTestName);1194 org.testng.Reporter.log(" ");1195 }1196 else1197 Reporter.print(sTestName, sDesc + " :: Error : This Method Works only for Html : 'Select' tag");1198 org.testng.Reporter.log("--------------------------------------------------");1199 org.testng.Reporter.log("STEP :: "+sDesc);1200 org.testng.Reporter.log("Step Status ::"+bStatus);1201 screenShot(sTestName);1202 org.testng.Reporter.log(" ");1203 } catch(Exception e) {1204 1205 if (Utils.handleIntermediateIssue()) { verify_SelectedOptions(sTestName, oEle, sObjStr, sExpOptions); }1206 1207 org.testng.Reporter.log("----------------------------------------------");1208 org.testng.Reporter.log("STEP :: "+sDesc);1209 org.testng.Reporter.log("Exception :: "+e);1210 screenShot(sTestName);1211 org.testng.Reporter.log(" ");1212 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1213 Assert.fail();1214 }1215 return bStatus;1216 }1217 /*1218 * Verifies that text given as argument is present anywhere on Page.1219 * 1220 * Parameter 1 : test case name1221 * Parameter 2 : expected text to check1222 * */1223 @SuppressWarnings("unchecked")1224 public static boolean verify_TextPresent(String sTestName, String sExpText) throws HeadlessException, IOException, AWTException, InterruptedException {1225 1226 String sDesc = "", sExpVal; boolean bStatus = false;1227 1228 try { 1229 1230 sExpText = Utils.Helper.validateUserInput(sTestName, sExpText);1231 sDesc = Logs.log(sTestName) + " :: Validating text '" + sExpText + "'";1232 sExpVal = Reporter.filterUserInput(sExpText);1233 1234 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1235 1236 List<WebElement> oList = lDriver.findElements(By.xpath("//*[contains(text(),'" + sExpVal + "')]"));1237 1238 if (oList.size() > 0) bStatus = true;1239 1240 1241 org.testng.Reporter.log("--------------------------------------------------");1242 org.testng.Reporter.log("STEP :: "+sDesc);1243 org.testng.Reporter.log("expected Text :: "+sExpText);1244 org.testng.Reporter.log("Step Status ::"+bStatus);1245 screenShot(sTestName);1246 org.testng.Reporter.log(" ");1247 1248 } catch(Exception e) {1249 1250 if (Utils.handleIntermediateIssue()) { verify_TextPresent(sTestName, sExpText); }1251 1252 org.testng.Reporter.log("----------------------------------------------");1253 org.testng.Reporter.log("STEP :: "+sDesc);1254 org.testng.Reporter.log("Exception :: "+e);1255 screenShot(sTestName);1256 org.testng.Reporter.log(" ");1257 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1258 Assert.fail();1259 }1260 return bStatus;1261 }1262 /*1263 * Verifies the current title of the Browser contains the expected title given as argument.1264 * Usage : User can assure whether he is on the right page as expected.1265 * 1266 * Parameter 1 : test case name1267 * Parameter 2 : expected title value1268 * */1269 public static boolean verifyIn_Title(String sTestName, String sExpTitle) throws HeadlessException, IOException, AWTException, InterruptedException , InterruptedException {1270 1271 String sDesc = "", sExpVal; boolean bStatus = false;1272 1273 try { 1274 1275 sExpTitle = Utils.Helper.validateUserInput(sTestName, sExpTitle);1276 sDesc = Logs.log(sTestName) + " :: Validating Title '" + sExpTitle + "'";1277 sExpVal = Reporter.filterUserInput(sExpTitle);1278 1279 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1280 1281 if (lDriver.getTitle().contains(sExpVal))1282 bStatus = true;1283 1284 //Reporter.print(sTestName, sExpTitle, sDesc, sExpVal, lDriver.getTitle(), bStatus, Helper.takeScreenshot(lDriver));1285 org.testng.Reporter.log("--------------------------------------------------");1286 org.testng.Reporter.log("STEP :: "+sDesc);1287 org.testng.Reporter.log("expected Title :: "+sExpTitle);1288 org.testng.Reporter.log("expected value :: "+sExpVal);1289 org.testng.Reporter.log("Step Status ::"+bStatus);1290 screenShot(sTestName);1291 org.testng.Reporter.log(" ");1292 1293 } catch(Exception e) {1294 1295 if (Utils.handleIntermediateIssue()) { verifyIn_Title(sTestName, sExpTitle); }1296 1297 org.testng.Reporter.log("----------------------------------------------");1298 org.testng.Reporter.log("STEP :: "+sDesc);1299 org.testng.Reporter.log("Exception :: "+e);1300 screenShot(sTestName);1301 org.testng.Reporter.log(" ");1302 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1303 Assert.fail();1304 }1305 return bStatus;1306 }1307 /*1308 * Verifies whether object is displayed or not.1309 * 1310 * Parameter 1 : test case name1311 * Parameter 2 : xPath from object map1312 * Parameter 3 : xPath from object map in string format1313 * Parameter 4 : value which needs to be checked in object [optional]1314 * */1315 public static boolean verify_Visible(String sTestName, WebElement oEle, String sObjStr, String sUserVal) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {1316 1317 String sDesc; boolean bStatus = false;1318 1319 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )";1320 1321 try { 1322 1323 sUserVal = Utils.Helper.validateUserInput(sTestName, sUserVal);1324 Reporter.filterUserInput(sUserVal);1325 //Helper.checkReady(sTestName, oEle);1326 1327 if (oEle.isDisplayed())1328 bStatus = true;1329 1330 1331 org.testng.Reporter.log("--------------------------------------------------");1332 org.testng.Reporter.log("STEP :: "+sDesc+ " :: Validating visible '" + sUserVal + "'");1333 org.testng.Reporter.log("Step Status ::"+bStatus);1334 screenShot(sTestName);1335 org.testng.Reporter.log(" ");1336 1337 } catch(Exception e) {1338 1339 if (Utils.handleIntermediateIssue()) { verify_Visible(sTestName, oEle, sObjStr, sUserVal); }1340 1341 org.testng.Reporter.log("----------------------------------------------");1342 org.testng.Reporter.log("STEP :: "+sDesc);1343 org.testng.Reporter.log("Exception :: "+e);1344 screenShot(sTestName);1345 org.testng.Reporter.log(" ");1346 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1347 Assert.fail();1348 }1349 return bStatus;1350 }1351 1352 /*1353 * To select/Deselect a checkBox/radiobutton.1354 * 1355 * Parameter 1 : test case name1356 * Parameter 2 : xPath from object map1357 * Parameter 3 : xPath from object map in string format1358 * Parameter 4 : User has to provide "true" for Selecting and "false" for Deselecting.1359 * */1360 public static void check_Uncheck(String sTestName, WebElement oEle, String sObjStr, String sUserVal) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {1361 1362 String sDesc; 1363 1364 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;1365 1366 try { 1367 sUserVal = Utils.Helper.validateUserInput(sTestName, sUserVal); 1368 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1369 if (sUserVal.equalsIgnoreCase("true")) {1370 1371 if (!oEle.isSelected()) {1372 Helper.forceClick(lDriver, oEle);1373 }1374 } else if (sUserVal.equalsIgnoreCase("false")) {1375 1376 if (oEle.isSelected()) {1377 Helper.forceClick(lDriver, oEle);1378 }1379 }1380 1381 1382 org.testng.Reporter.log("--------------------------------------------------");1383 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");1384 org.testng.Reporter.log(" ");1385 1386 } catch(Exception e) {1387 1388 if (Utils.handleIntermediateIssue()) { check_Uncheck(sTestName, oEle, sObjStr, sUserVal); }1389 1390 org.testng.Reporter.log("----------------------------------------------");1391 org.testng.Reporter.log("STEP :: "+sDesc);1392 org.testng.Reporter.log("Exception :: "+e);1393 screenShot(sTestName);1394 org.testng.Reporter.log(" ");1395 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1396 Assert.fail();1397 }1398 }1399 /*1400 * This method is used to perform click operation on web page at given location1401 * 1402 * Parameter 1 : test case name1403 * Parameter 2 : xPath from object map1404 * Parameter 3 : xPath from object map in string format1405 * 1406 * */1407 public static void click(String sTestName, WebElement oEle, String sObjStr) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {1408 1409 String sDesc = "";1410 1411 sDesc = Logs.log(sTestName) + " on Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )";1412 1413 1414 try { 1415 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1416 try {1417 1418 Helper.forceClick(lDriver, oEle);1419 }1420 catch (Exception e) {1421 oEle.click();1422 }1423 1424 org.testng.Reporter.log("--------------------------------------------------");1425 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");1426 org.testng.Reporter.log(" ");1427 1428 } catch(Exception e) {1429 1430 if (Utils.handleIntermediateIssue()) { click(sTestName, oEle, sObjStr); }1431 1432 org.testng.Reporter.log("----------------------------------------------");1433 org.testng.Reporter.log("STEP :: "+sDesc);1434 org.testng.Reporter.log("Exception :: "+e);1435 screenShot(sTestName);1436 org.testng.Reporter.log(" ");1437 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1438 Assert.fail();1439 }1440 }1441 /*1442 * Prints the message in logs.1443 * 1444 * Parameter1 : test case name1445 * Parameter 2 : User has to provide the Text to be printed.1446 * 1447 * */1448 public static void print(String sTestName, String sTxt) throws HeadlessException, IOException, AWTException, InterruptedException, InvalidInputException {1449 String sDesc = Logs.log(sTestName);1450 sTxt = Utils.Helper.validateUserInput(sTestName, sTxt); 1451 org.testng.Reporter.log("--------------------------------------------------");1452 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed"); 1453 org.testng.Reporter.log(" ");1454 }1455 /*1456 * This method is used to navigate back to previous page 1457 * */1458 public static void goBack(String sTestName) throws HeadlessException, IOException, AWTException, InterruptedException {1459 1460 String sDesc; 1461 sDesc = Logs.log(sTestName);1462 1463 try { 1464 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1465 lDriver.navigate().back();1466 org.testng.Reporter.log("--------------------------------------------------");1467 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");1468 org.testng.Reporter.log(" ");1469 1470 } catch(Exception e) {1471 1472 if (Utils.handleIntermediateIssue()) { goBack(sTestName); }1473 1474 org.testng.Reporter.log("----------------------------------------------");1475 org.testng.Reporter.log("STEP :: "+sDesc);1476 org.testng.Reporter.log("Exception :: "+e);1477 screenShot(sTestName);1478 org.testng.Reporter.log(" ");1479 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1480 Assert.fail();1481 }1482 }1483 /*1484 * Opens the URL provided as argument.1485 *1486 * Parameter 1 : test case name1487 * parameter 2 : "User has to provide the URL to be opened. e.g. "http://www.google.co.in/"1488 * 1489 * */1490 public static void openURL(String sTestName, String sURL) throws HeadlessException, IOException, AWTException, InterruptedException {1491 1492 String sDesc = ""; 1493 1494 try {1495 1496 sURL = Utils.Helper.validateUserInput(sTestName, sURL);1497 1498 sDesc = Logs.log(sTestName) + ": " + sURL;1499 1500 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1501 lDriver.get(sURL);1502 1503 org.testng.Reporter.log("--------------------------------------------------");1504 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");1505 org.testng.Reporter.log(" ");1506 1507 } catch ( Exception e) {1508 1509 if (Utils.handleIntermediateIssue()) { openURL(sTestName, sURL); }1510 1511 org.testng.Reporter.log("----------------------------------------------");1512 org.testng.Reporter.log("STEP :: "+sDesc);1513 org.testng.Reporter.log("Exception :: "+e);1514 org.testng.Reporter.log(" ");1515 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1516 Assert.fail();1517 }1518 1519 }1520 /*1521 * This method is used to refresh browser.1522 * */1523 public static void refresh(String sTestName) throws HeadlessException, IOException, AWTException, InterruptedException {1524 1525 String sDesc; 1526 sDesc = Logs.log(sTestName);1527 1528 try { 1529 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1530 lDriver.navigate().refresh();1531 1532 org.testng.Reporter.log("--------------------------------------------------");1533 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");1534 org.testng.Reporter.log(" ");1535 1536 } catch(Exception e) {1537 1538 if (Utils.handleIntermediateIssue()) { refresh(sTestName); }1539 1540 org.testng.Reporter.log("----------------------------------------------");1541 org.testng.Reporter.log("STEP :: "+sDesc);1542 org.testng.Reporter.log("Exception :: "+e);1543 screenShot(sTestName);1544 org.testng.Reporter.log(" ");1545 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1546 Assert.fail();1547 }1548 }1549 /*1550 * Select multiple options in SelectBox.1551 * 1552 * Parameter 1 : test case name1553 * Parameter 2 : xpath from object map1554 * Parameter 3 : xPath from object map in string format1555 * Parameter 4 : User has to provide the options to be selected seperated by a pipe "|".1556 * 1557 * */1558 public static void multiSelect(String sTestName, WebElement oEle, String sObjStr, String sOptions) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {1559 String sDesc; 1560 1561 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;1562 1563 try {1564 1565 sOptions = Utils.Helper.validateUserInput(sTestName, sOptions);1566 1567 if(oEle.getTagName().toString().equalsIgnoreCase("select")){1568 Select oSelect = new Select(oEle);1569 1570 for (String sValToBeSelected : sOptions.split("\\|")) {1571 oSelect.selectByVisibleText(sValToBeSelected);1572 oEle.sendKeys(Keys.CONTROL);1573 }1574 1575 org.testng.Reporter.log("--------------------------------------------------");1576 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");1577 org.testng.Reporter.log(" ");1578 }1579 else1580 1581 org.testng.Reporter.log("--------------------------------------------------");1582 org.testng.Reporter.log("Step ::"+sDesc + " :: Error : This Method Works only for Html : 'Select' tag");1583 org.testng.Reporter.log(" ");1584 } catch(Exception e) {1585 1586 if (Utils.handleIntermediateIssue()) { multiSelect(sTestName, oEle, sObjStr, sOptions); }1587 1588 org.testng.Reporter.log("----------------------------------------------");1589 org.testng.Reporter.log("STEP :: "+sDesc);1590 org.testng.Reporter.log("Exception :: "+e);1591 screenShot(sTestName);1592 org.testng.Reporter.log(" ");1593 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1594 Assert.fail();1595 }1596 }1597 /*1598 * Select option from SelectBox.1599 * 1600 * Parameter 1 : test case name1601 * Parameter 2 : xpath from object map1602 * Parameter 3 : xpath from object map in string format1603 * Parameter 4 : User has to provide the text of the option to be selected.1604 * 1605 * */1606 public static void select(String sTestName, WebElement oEle, String sObjStr, String sOption) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {1607 1608 String sDesc; 1609 1610 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )";1611 1612 try { 1613 sOption = Utils.Helper.validateUserInput(sTestName, sOption);1614 1615 if(oEle.getTagName().toString().equalsIgnoreCase("select")){1616 Select oSelect = new Select(oEle);1617 oSelect.selectByVisibleText(sOption); 1618 org.testng.Reporter.log("--------------------------------------------------");1619 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");1620 org.testng.Reporter.log(" ");1621 }1622 else1623 1624 org.testng.Reporter.log("--------------------------------------------------");1625 org.testng.Reporter.log("Step ::"+sDesc + " :: Error : This Method Works only for Html : 'Select' tag");1626 org.testng.Reporter.log(" ");1627 1628 } catch(Exception e) {1629 1630 if (Utils.handleIntermediateIssue()) { select(sTestName, oEle, sObjStr, sOption); }1631 1632 org.testng.Reporter.log("----------------------------------------------");1633 org.testng.Reporter.log("STEP :: "+sDesc);1634 org.testng.Reporter.log("Exception :: "+e);1635 screenShot(sTestName);1636 org.testng.Reporter.log(" ");1637 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1638 Assert.fail();1639 }1640 }1641 /*1642 * Verifies whether frame given as parameter is present in the page or not .1643 * Parameter 1 : test case name1644 * Parameter 2 : User can provide any attribute's value that is unique to that frame(id,class,name etc). e.g. "frame1"1645 * 1646 * */1647 public static void verify_Frame(String sTestName, String sFrameInfo) throws HeadlessException, IOException, AWTException, InterruptedException {1648 1649 String sDesc, sExpVal; boolean bStatus = false;1650 sDesc = Logs.log(sTestName);1651 1652 try { 1653 1654 sFrameInfo = Utils.Helper.validateUserInput(sTestName, sFrameInfo);1655 sExpVal = Reporter.filterUserInput(sFrameInfo);1656 1657 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1658 @SuppressWarnings("unchecked")1659 List<WebElement> oFrameList = lDriver.findElements(By.xpath("//iframe|//frame"));1660 for (WebElement oFrame : oFrameList) {1661 if (oFrame.isDisplayed()) {1662 1663 JavascriptExecutor executor = (JavascriptExecutor) lDriver;1664 String sOutAttribs = executor.executeScript("var items = {}; for (index = 0; index < arguments[0].attributes.length; ++index)" +1665 "{ items[arguments[0].attributes[index].name] = arguments[0].attributes[index].value }; return items;", oFrame).toString();1666 if (sOutAttribs.contains(sExpVal)) {1667 bStatus=true; break;1668 }1669 }1670 }1671 1672 1673 org.testng.Reporter.log("--------------------------------------------------");1674 org.testng.Reporter.log("STEP :: "+sDesc); 1675 org.testng.Reporter.log("expected Value :: "+ sFrameInfo);1676 org.testng.Reporter.log("Step Status ::"+bStatus);1677 screenShot(sTestName);1678 org.testng.Reporter.log(" ");1679 1680 } catch(Exception e) {1681 1682 if (Utils.handleIntermediateIssue()) { verify_Frame(sTestName, sFrameInfo); }1683 1684 org.testng.Reporter.log("----------------------------------------------");1685 org.testng.Reporter.log("STEP :: "+sDesc);1686 org.testng.Reporter.log("Exception :: "+e);1687 screenShot(sTestName);1688 org.testng.Reporter.log(" ");1689 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1690 Assert.fail();1691 }1692 }1693 1694 /*1695 * Switches the handle to Frame/Iframe provided as argument. It switches to first frame displayed if Parameter is left empty.1696 * Usage : Switching to frame/iframe is necessary before performing any operation inside that frame.1697 * 1698 * 1699 * Parameter 1 : test case name1700 * Parameter 2 : User can provide any attribute's value that is unique to that frame(id,class,name etc). e.g. ""frame1"1701 * 1702 * */1703 public static void switch_To_Frame(String sTestName, String sFrameInfo) throws HeadlessException, IOException, AWTException, InterruptedException {1704 1705 String sDesc; boolean bStatus = false;1706 sDesc = Logs.log(sTestName);1707 1708 try { 1709 1710 sFrameInfo = Utils.Helper.validateUserInput(sTestName, sFrameInfo);1711 1712 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1713 @SuppressWarnings("unchecked")1714 List<WebElement> oFrameList = lDriver.findElements(By.xpath("//iframe|//frame"));1715 for (WebElement oFrame : oFrameList) {1716 if (oFrame.isDisplayed()) {1717 1718 if (!sFrameInfo.isEmpty()) { 1719 JavascriptExecutor executor = (JavascriptExecutor) lDriver;1720 String sOutAttribs = executor.executeScript("var items = {}; for (index = 0; index < arguments[0].attributes.length; ++index)" +1721 "{ items[arguments[0].attributes[index].name] = arguments[0].attributes[index].value }; return items;", oFrame).toString();1722 if (sOutAttribs.contains(sFrameInfo)) {1723 lDriver.switchTo().frame(oFrame); bStatus=true; break;1724 }1725 } else {1726 lDriver.switchTo().frame(oFrame); bStatus=true; break;1727 }1728 }1729 }1730 1731 if (!bStatus) {1732 1733 org.testng.Reporter.log("--------------------------------------------------");1734 org.testng.Reporter.log("Step ::"+sDesc + " :: Frame '" + sFrameInfo + "' not found");1735 org.testng.Reporter.log(" ");1736 }1737 else {1738 1739 org.testng.Reporter.log("--------------------------------------------------");1740 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed - '" + sFrameInfo + "'");1741 org.testng.Reporter.log(" ");1742 }1743 } catch(Exception e) {1744 1745 if (Utils.handleIntermediateIssue()) { switch_To_Frame(sTestName, sFrameInfo); }1746 1747 org.testng.Reporter.log("----------------------------------------------");1748 org.testng.Reporter.log("STEP :: "+sDesc);1749 org.testng.Reporter.log("Exception :: "+e);1750 screenShot(sTestName);1751 org.testng.Reporter.log(" ");1752 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1753 Assert.fail();1754 }1755 }1756 /*1757 * Switches the handle back to default content.1758 * Usage : To switch back to default content when user has switched to a iframe/frame.1759 * 1760 * */1761 public static void switch_To_Default(String sTestName) throws HeadlessException, IOException, AWTException, InterruptedException {1762 1763 String sDesc; 1764 sDesc = Logs.log(sTestName);1765 1766 try { 1767 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1768 lDriver.switchTo().defaultContent();1769 1770 org.testng.Reporter.log("--------------------------------------------------");1771 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");1772 org.testng.Reporter.log(" ");1773 1774 } catch(Exception e) {1775 1776 if (Utils.handleIntermediateIssue()) { switch_To_Default(sTestName); }1777 1778 org.testng.Reporter.log("----------------------------------------------");1779 org.testng.Reporter.log("STEP :: "+sDesc);1780 org.testng.Reporter.log("Exception :: "+e);1781 screenShot(sTestName);1782 org.testng.Reporter.log(" ");1783 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1784 Assert.fail();1785 }1786 }1787 public static void switch_To_Tab(String sTestName, String sWindowInfo) throws HeadlessException, IOException, AWTException, InterruptedException {1788 1789 String sDesc; 1790 sDesc = Logs.log(sTestName);1791 1792 try { 1793 sWindowInfo = Utils.Helper.validateUserInput(sTestName, sWindowInfo);1794 1795 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1796 if (sWindowInfo.isEmpty()) {1797 1798 Utils.setScriptParams(sTestName, "Parent_Brwsr", lDriver.getWindowHandle());1799 for (String sWinHandle : lDriver.getWindowHandles()) {1800 lDriver.switchTo().window(sWinHandle);1801 }1802 Utils.setScriptParams(sTestName, "Child_Brwsr", lDriver.getWindowHandle());1803 } else if (sWindowInfo.equalsIgnoreCase("Parent")) {1804 1805 if (!Utils.h2TestName_ScriptParams.get(sTestName).get("Parent_Brwsr").isEmpty()) { 1806 lDriver.switchTo().window(Utils.h2TestName_ScriptParams.get(sTestName).get("Parent_Brwsr"));1807 } else { 1808 for (String sWinHandle : lDriver.getWindowHandles()) {1809 lDriver.switchTo().window(sWinHandle);1810 }1811 Utils.setScriptParams(sTestName, "Parent_Brwsr", lDriver.getWindowHandle());1812 }1813 1814 } else if (sWindowInfo.equalsIgnoreCase("Child")) {1815 if (!Utils.h2TestName_ScriptParams.get(sTestName).get("Child_Brwsr").isEmpty()) { 1816 lDriver.switchTo().window(Utils.h2TestName_ScriptParams.get(sTestName).get("Child_Brwsr"));1817 } else { 1818 for (String sWinHandle : lDriver.getWindowHandles()) {1819 lDriver.switchTo().window(sWinHandle);1820 }1821 Utils.setScriptParams(sTestName, "Child_Brwsr", lDriver.getWindowHandle());1822 }1823 }1824 1825 1826 org.testng.Reporter.log("--------------------------------------------------");1827 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed - '" + sWindowInfo + "'");1828 org.testng.Reporter.log(" ");1829 1830 } catch(Exception e) {1831 1832 if (Utils.handleIntermediateIssue()) { switch_To_Tab(sTestName, sWindowInfo); }1833 1834 org.testng.Reporter.log("----------------------------------------------");1835 org.testng.Reporter.log("STEP :: "+sDesc);1836 org.testng.Reporter.log("Exception :: "+e);1837 screenShot(sTestName);1838 org.testng.Reporter.log(" ");1839 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1840 Assert.fail();1841 }1842 }1843 /*1844 * Finds the value of the attribute in given object and stores in the Variable Name provided in argument.1845 * Usage : To store values of attributes like class,name,id,style,width etc.1846 * 1847 * Parameter 1 : Test case name.1848 * Parameter 2 : xPath from object map.1849 * Parameter 3 : xPath from object map in string format.1850 * Parameter 4 : Attribute value which needs to be stored.1851 * Parameter 5 : Variable value in which the value needs to be stored.1852 * e.g. "id" in Argument 1 and variabe "temp" in Argument 2.1853 *1854 * */1855 1856 public static void store_Attribute(String sTestName, WebElement oEle, String sObjStr, String sComputedVal,String sVarName) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {1857 1858 String sDesc = "", sActVal; 1859 1860 1861 try { 1862 1863 sComputedVal = Utils.Helper.validateUserInput(sTestName, sComputedVal);1864 sVarName = Utils.Helper.validateUserInput(sTestName, sVarName);1865 1866 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )";1867 1868 if (sVarName.equals("")) {1869 sVarName = "Temp";1870 } 1871 sActVal = oEle.getAttribute(sComputedVal);1872 Utils.setScriptParams(sTestName, sVarName, sActVal);1873 1874 1875 org.testng.Reporter.log("--------------------------------------------------");1876 org.testng.Reporter.log("Step ::"+sDesc + " :: Store (Attribute-" + sComputedVal + ", Value-" + sActVal + ") in Local Variable '" + sVarName + "'");1877 org.testng.Reporter.log(" ");1878 } catch(Exception e) {1879 1880 if (Utils.handleIntermediateIssue()) { store_Attribute(sTestName, oEle, sObjStr,sComputedVal,sVarName ); }1881 1882 org.testng.Reporter.log("----------------------------------------------");1883 org.testng.Reporter.log("STEP :: "+sDesc);1884 org.testng.Reporter.log("Exception :: "+e);1885 screenShot(sTestName);1886 org.testng.Reporter.log(" ");1887 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1888 Assert.fail();1889 }1890 }1891 /*1892 * Stores the current URL in Variable Name provided as argument.1893 * 1894 * Parameter 1 : test case name1895 * Parameter 2 : "User has to provide the Variable Name to store the current URL. e.g. "Temp"1896 * 1897 * */1898public static void store_URL(String sTestName, String sUserVal) throws HeadlessException, IOException, AWTException, InterruptedException {1899 1900 String sDesc = "", sActVal, sVarName; 1901 1902 1903 try { 1904 sUserVal = Utils.Helper.validateUserInput(sTestName, sUserVal);1905 1906 sDesc = Logs.log(sTestName);1907 1908 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);1909 1910 sVarName = sUserVal;1911 if (sUserVal.equals("")) {1912 sVarName = "Temp"; 1913 }1914 1915 sActVal = lDriver.getCurrentUrl();1916 Utils.setScriptParams(sTestName, sVarName, sActVal);1917 1918 1919 org.testng.Reporter.log("--------------------------------------------------");1920 org.testng.Reporter.log("Step ::"+sDesc + " :: Store (Current URL -" + sActVal + ") in Local Variable '" + sVarName + "'");1921 org.testng.Reporter.log(" ");1922 } catch(Exception e) {1923 1924 if (Utils.handleIntermediateIssue()) { store_URL(sTestName, sUserVal); }1925 1926 org.testng.Reporter.log("----------------------------------------------");1927 org.testng.Reporter.log("STEP :: "+sDesc);1928 org.testng.Reporter.log("Exception :: "+e);1929 screenShot(sTestName);1930 org.testng.Reporter.log(" ");1931 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1932 Assert.fail();1933 }1934 1935 }1936/*1937 * Stores all options of SelectBox in Variable Name provided as argument.1938 * 1939 * Parameter 1 : test case name1940 * Parameter 2 : xPath from object map1941 * Parameter 3 : xPath from object map in string format1942 * Parameter 4 : "User has to provide variable name to store options of the SelectBox.e.g.Temp"1943 * 1944 * */1945 public static void store_SelectOptions(String sTestName, WebElement oEle, String sObjStr, String sVarName) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {1946 1947 String sDesc, sActVal = null; 1948 1949 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )";1950 1951 try { 1952 sVarName = Utils.Helper.validateUserInput(sTestName, sVarName);1953 1954 if(oEle.getTagName().toString().equalsIgnoreCase("select")){1955 1956 Select selList = new Select(oEle); List<WebElement> oSize = selList.getOptions();1957 for(int i =0; i<oSize.size(); i++) { 1958 sActVal = sActVal + "|" + selList.getOptions().get(i).getText(); 1959 } 1960 1961 if (sVarName.equals("")) {1962 sVarName = "Temp"; 1963 }1964 1965 sActVal = sActVal.substring(2);1966 Utils.setScriptParams(sTestName, sVarName, sActVal);1967 1968 1969 org.testng.Reporter.log("--------------------------------------------------");1970 org.testng.Reporter.log("Step ::"+sDesc + " :: Store options '" + sActVal + "' of "+ sObjStr + " in Local Variable '" + sVarName + "'");1971 org.testng.Reporter.log(" ");1972 }1973 else1974 1975 org.testng.Reporter.log("--------------------------------------------------");1976 org.testng.Reporter.log("Step ::"+sDesc + " :: Error : This Method Works only for Html : 'Select' tag");1977 org.testng.Reporter.log(" ");1978 } catch(Exception e) {1979 1980 if (Utils.handleIntermediateIssue()) { store_SelectOptions(sTestName, oEle, sObjStr, sVarName); }1981 1982 org.testng.Reporter.log("----------------------------------------------");1983 org.testng.Reporter.log("STEP :: "+sDesc);1984 org.testng.Reporter.log("Exception :: "+e);1985 screenShot(sTestName);1986 org.testng.Reporter.log(" ");1987 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);1988 Assert.fail();1989 }1990 }1991 /*1992 * Stores all Selected options of SelectBox in Variable Name provided as argument.1993 * 1994 * Parameter 1 : test case name1995 * Parameter 2 : "User has to provide variable name to store selected options of the SelectBox. e.g. "Temp"1996 * 1997 * */1998 public static void store_SelectedValue(String sTestName, WebElement oEle, String sObjStr, String sVarName) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {1999 2000 String sDesc, sActVal = null; 2001 2002 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )";2003 2004 try { 2005 sVarName = Utils.Helper.validateUserInput(sTestName, sVarName);2006 2007 if(oEle.getTagName().toString().equalsIgnoreCase("select")){2008 2009 Select selList = new Select(oEle); List<WebElement> oSize = selList.getAllSelectedOptions();2010 for(int i =0; i<oSize.size(); i++) { 2011 sActVal = sActVal + "|" + selList.getAllSelectedOptions().get(i).getText(); 2012 } 2013 2014 if (sVarName.equals("")) {2015 sVarName = "Temp"; 2016 }2017 2018 sActVal = sActVal.substring(2);2019 Utils.setScriptParams(sTestName, sVarName, sActVal);2020 2021 2022 org.testng.Reporter.log("--------------------------------------------------");2023 org.testng.Reporter.log("Step ::"+sDesc + " :: Store selected options '" + sActVal + "' of "+ sObjStr + " in Local Variable '" + sVarName + "'");2024 org.testng.Reporter.log(" ");2025 }2026 else2027 2028 org.testng.Reporter.log("--------------------------------------------------");2029 org.testng.Reporter.log("Step ::"+sDesc + " :: Error : This Method Works only for Html : 'Select' tag");2030 org.testng.Reporter.log(" ");2031 2032 } catch(Exception e) {2033 2034 if (Utils.handleIntermediateIssue()) { store_SelectedValue(sTestName, oEle, sObjStr, sVarName); }2035 2036 org.testng.Reporter.log("----------------------------------------------");2037 org.testng.Reporter.log("STEP :: "+sDesc);2038 org.testng.Reporter.log("Exception :: "+e);2039 screenShot(sTestName);2040 org.testng.Reporter.log(" ");2041 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2042 Assert.fail();2043 }2044 }2045 2046 /*2047 * Stores the visible text of the object in Variable Name provided as argument.2048 * 2049 * Parameter 1 : test case name2050 * Parameter 2 : Stores the visible text of the object in Variable Name provided as parameter.2051 * 2052 * */2053 public static void store_Text(String sTestName, WebElement oEle, String sObjStr, String sVarName) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {2054 2055 String sDesc, sActVal = null; 2056 2057 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;2058 2059 try { 2060 sVarName = Utils.Helper.validateUserInput(sTestName, sVarName);2061 2062 sActVal = oEle.getText(); 2063 2064 if (sVarName.equals("")) {2065 sVarName = "Temp"; 2066 }2067 2068 Utils.setScriptParams(sTestName, sVarName, sActVal);2069 2070 2071 org.testng.Reporter.log("--------------------------------------------------");2072 org.testng.Reporter.log("Step ::"+sDesc + " :: Store '" + sActVal + "' of "+ sObjStr + " in Local Variable '" + sVarName + "'");2073 org.testng.Reporter.log(" ");2074 } catch(Exception e) {2075 2076 if (Utils.handleIntermediateIssue()) { store_Text(sTestName, oEle, sObjStr, sVarName); }2077 2078 org.testng.Reporter.log("----------------------------------------------");2079 org.testng.Reporter.log("STEP :: "+sDesc);2080 org.testng.Reporter.log("Exception :: "+e);2081 screenShot(sTestName);2082 org.testng.Reporter.log(" ");2083 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2084 Assert.fail();2085 }2086 }2087 /*2088 * Stores the visible text of the object in Variable Name provided as argument.2089 * 2090 * Parameter 1 : test case name2091 * Parameter 2 : Stores the visible text of the object in Variable Name provided as parameter.2092 * */2093 public static void store_Value(String sTestName, WebElement oEle, String sObjStr, String sVarName) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {2094 2095 String sDesc, sActVal = null; 2096 2097 sDesc = Logs.log(sTestName) + " of Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;2098 //Helper.checkReady(sTestName, oEle);2099 2100 try { 2101 sVarName = Utils.Helper.validateUserInput(sTestName, sVarName);2102 2103 sActVal = oEle.getText(); 2104 2105 if (sVarName.equals("")) {2106 sVarName = "Temp"; 2107 }2108 2109 Utils.setScriptParams(sTestName, sVarName, sActVal);2110 2111 2112 org.testng.Reporter.log("--------------------------------------------------");2113 org.testng.Reporter.log("Step ::"+sDesc + " :: Store '" + sActVal + sActVal + " in Local Variable '" + sVarName + "'");2114 org.testng.Reporter.log(" ");2115 } catch(Exception e) {2116 2117 if (Utils.handleIntermediateIssue()) { store_Value(sTestName, oEle, sObjStr, sVarName); }2118 2119 org.testng.Reporter.log("----------------------------------------------");2120 org.testng.Reporter.log("STEP :: "+sDesc);2121 org.testng.Reporter.log("Exception :: "+e);2122 screenShot(sTestName);2123 org.testng.Reporter.log(" ");2124 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2125 Assert.fail();2126 }2127 }2128 2129 @SuppressWarnings("unused")2130 public static void type(String sTestName, WebElement oEle, String sObjStr, String sVal) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {2131 String sDesc = "" ; boolean flag = true; 2132 2133 try { 2134 2135 sVal = Utils.Helper.validateUserInput(sTestName, sVal);2136 sDesc = Logs.log(sTestName) + " in Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " ) , Value = " + sVal ;2137 //Helper.checkReady(sTestName, oEle);2138 2139 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);2140 2141 try {2142 oEle.clear(); Thread.sleep(500L); 2143 }2144 catch (Exception e) {2145 flag = false;2146 oEle.sendKeys(sVal);2147 if(Utils.hEnvParams.get("Execution_On").equalsIgnoreCase("Physical"))2148 Android_Hybrid.native_HideKeyboard(sTestName);2149 2150 }2151 if(flag)2152 oEle.sendKeys(sVal);2153 if(Utils.hEnvParams.get("Execution_On").equalsIgnoreCase("Physical"))2154 Android_Hybrid.native_HideKeyboard(sTestName);2155 2156 org.testng.Reporter.log("--------------------------------------------------");2157 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");2158 org.testng.Reporter.log(" ");2159 2160 } catch(Exception e) {2161 2162 if (Utils.handleIntermediateIssue()) { type(sTestName, oEle, sObjStr, sVal); }2163 2164 org.testng.Reporter.log("----------------------------------------------");2165 org.testng.Reporter.log("STEP :: "+sDesc);2166 org.testng.Reporter.log("Exception :: "+e);2167 screenShot(sTestName);2168 org.testng.Reporter.log(" ");2169 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2170 Assert.fail();2171 }2172 }2173 @SuppressWarnings("unused")2174 public static void type_Advanced(String sTestName, WebElement oEle, String sObjStr, String sVal) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {2175 String sDesc = "" ; boolean flag = true; 2176 2177 try { 2178 sVal = Utils.Helper.validateUserInput(sTestName, sVal);2179 sDesc = Logs.log(sTestName) + " in Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " ) , Value = " + sVal ;2180 //Helper.checkReady(sTestName, oEle);2181 2182 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName); 2183 Helper.CheckPopUp_Object(sTestName, oEle, sObjStr);2184 if (Helper.CheckExist(lDriver,oEle).contains("True")) {2185 if (!oEle.getAttribute("value").equals("")){2186 oEle.clear();Thread.sleep(2000L);2187 } 2188 oEle.sendKeys(sVal); 2189 }2190 switch_To_Default(sTestName); 2191 2192 org.testng.Reporter.log("--------------------------------------------------");2193 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");2194 org.testng.Reporter.log(" ");2195 2196 } catch(Exception e) {2197 2198 if (Utils.handleIntermediateIssue()) { type_Advanced(sTestName, oEle, sObjStr, sVal); }2199 2200 org.testng.Reporter.log("----------------------------------------------");2201 org.testng.Reporter.log("STEP :: "+sDesc);2202 org.testng.Reporter.log("Exception :: "+e);2203 screenShot(sTestName);2204 org.testng.Reporter.log(" ");2205 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2206 Assert.fail();2207 }2208 }2209 /*2210 * It deletes all cookies of the browser.2211 */2212 public static void deleteCookies(String sTestName) throws HeadlessException, IOException, AWTException, InterruptedException {2213 2214 String sDesc; 2215 sDesc = Logs.log(sTestName)+" :: All Cookies Deleted";2216 2217 try { 2218 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);2219 2220 lDriver.manage().deleteAllCookies();2221 2222 org.testng.Reporter.log("--------------------------------------------------");2223 org.testng.Reporter.log("Step ::"+sDesc);2224 org.testng.Reporter.log(" ");2225 } catch(Exception e) {2226 2227 if (Utils.handleIntermediateIssue()) { deleteCookies(sTestName); }2228 2229 org.testng.Reporter.log("----------------------------------------------");2230 org.testng.Reporter.log("STEP :: "+sDesc);2231 org.testng.Reporter.log("Exception :: "+e);2232 screenShot(sTestName);2233 org.testng.Reporter.log(" ");2234 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2235 Assert.fail();2236 }2237 }2238 /*2239 * Deletes the cache of the browser.2240 * */2241 public static void deleteCache(String sTestName) throws HeadlessException, IOException, AWTException, InterruptedException {2242 2243 String sDesc, sBrowser, sTitle = "", vbPath; 2244 sDesc = Logs.log(sTestName) + " :: Cache Deleted";2245 2246 try { 2247 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);2248 sBrowser = Utils.h2TestName_TestParams.get(sTestName).get("exePlatform"); 2249 if(sBrowser.equalsIgnoreCase("Firefox"))2250 sTitle = lDriver.getTitle() +" - Mozilla Firefox";2251 else if(sBrowser.equalsIgnoreCase("IE"))2252 sTitle = lDriver.getTitle() +" - Internet Explorer";2253 2254 2255 vbPath = "\""+System.getProperty("user.dir").replace("\\", "/") +"/Packages/delcache.vbs\"";2256 2257 Runtime.getRuntime().exec( "cscript " +vbPath+ " \""+sTitle+ "\"");2258 2259 2260 org.testng.Reporter.log("--------------------------------------------------");2261 org.testng.Reporter.log("Step ::"+sDesc);2262 org.testng.Reporter.log(" ");2263 2264 } catch(Exception e) {2265 2266 if (Utils.handleIntermediateIssue()) {deleteCache(sTestName); }2267 2268 org.testng.Reporter.log("----------------------------------------------");2269 org.testng.Reporter.log("STEP :: "+sDesc);2270 org.testng.Reporter.log("Exception :: "+e);2271 screenShot(sTestName);2272 org.testng.Reporter.log(" ");2273 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2274 Assert.fail();2275 }2276 }2277 2278 /*2279 * Performs Double Click on the object given.2280 * 2281 * Parameter 1 : test case name2282 * parameter 2 : xPath2283 * Parameter 3 : xPath in string format2284 * 2285 * */ 2286 public static void doubleClick(String sTestName, WebElement oEle, String sObjStr) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {2287 2288 String sDesc; 2289 2290 sDesc = Logs.log(sTestName)+ " :: Double Click on Element: " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;2291 2292 try { 2293 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);2294 Actions action = new Actions(lDriver);2295 action.moveToElement(oEle).doubleClick().build().perform();2296 2297 2298 org.testng.Reporter.log("--------------------------------------------------");2299 org.testng.Reporter.log("Step ::"+sDesc);2300 org.testng.Reporter.log(" ");2301 2302 } catch (Exception e) {2303 2304 if (Utils.handleIntermediateIssue()) { doubleClick(sTestName,oEle,sObjStr); }2305 2306 org.testng.Reporter.log("----------------------------------------------");2307 org.testng.Reporter.log("STEP :: "+sDesc);2308 org.testng.Reporter.log("Exception :: "+e);2309 screenShot(sTestName);2310 org.testng.Reporter.log(" ");2311 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2312 Assert.fail();2313 }2314 }2315 2316 public static Object ahRunScript(String sTestCaseName,ITestContext testContext) throws Exception {2317 2318 return Utils.RunScript(sTestCaseName, testContext);2319 }2320 2321 public static Object ahRunScript(String sTestName,String sTestCaseName,ITestContext testContext) throws Exception {2322 2323 return ahRunScript( sTestCaseName, testContext);2324 }2325 2326 public static void wait(String sTestName, String secs) throws NumberFormatException, InterruptedException, HeadlessException, IOException, AWTException, InterruptedException, InvalidInputException {2327 2328 secs = Utils.Helper.validateUserInput(sTestName, secs);2329 String sDesc = Logs.log(sTestName)+" :: Waiting for: ("+secs+")seconds";2330 Thread.sleep(Long.valueOf(secs)*1000);2331 2332 org.testng.Reporter.log("--------------------------------------------------");2333 org.testng.Reporter.log("Step ::"+sDesc);2334 org.testng.Reporter.log(" ");2335 }2336 2337 public static void waitForElementPresent(String sTestName, WebElement oEle, String sObjStr, String WaitTimeSec) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {2338 2339 String sDesc = "" ;2340 2341 sDesc = Logs.log(sTestName)+" :: Waiting for Element : " +sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;2342 2343 try {2344 2345 WaitTimeSec = Utils.Helper.validateUserInput(sTestName, WaitTimeSec);2346 long sec = Long.parseLong(WaitTimeSec);2347 //Helper.checkReady(sTestName, oEle);2348 2349 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);2350 WebDriverWait wait = new WebDriverWait(lDriver, sec);2351 wait.until(ExpectedConditions.visibilityOf(oEle));2352 2353 2354 org.testng.Reporter.log("--------------------------------------------------");2355 org.testng.Reporter.log("Step ::"+sDesc+ " to be Present: ("+WaitTimeSec+")seconds");2356 org.testng.Reporter.log(" ");2357 2358 } catch(Exception e) {2359 2360 if (Utils.handleIntermediateIssue()) { waitForElementPresent(sTestName,oEle,sObjStr, WaitTimeSec); }2361 2362 org.testng.Reporter.log("----------------------------------------------");2363 org.testng.Reporter.log("STEP :: "+sDesc);2364 org.testng.Reporter.log("Exception :: "+e);2365 screenShot(sTestName);2366 org.testng.Reporter.log(" ");2367 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2368 Assert.fail();2369 }2370 }2371 public static boolean verify_SubStringInText(String sTestName, WebElement oEle, String sObjStr, String sExpText) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {2372 2373 String sDesc, sActVal = null, sExpVal; boolean bStatus = false;2374 2375 sDesc = Logs.log(sTestName)+ " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;2376 2377 try {2378 2379 sExpText = Utils.Helper.validateUserInput(sTestName, sExpText);2380 sExpVal = Reporter.filterUserInput(sExpText); 2381 //Helper.checkReady(sTestName, oEle);2382 2383 sActVal = oEle.getText();2384 sActVal = sActVal.replace("\n", " ");2385 bStatus = (sActVal.contains(sExpVal)); 2386 2387 2388 org.testng.Reporter.log("--------------------------------------------------");2389 org.testng.Reporter.log("STEP :: "+sDesc+ " :: Check the contents '" + sExpText + "'");2390 org.testng.Reporter.log("Expected Title :: "+sExpVal);2391 org.testng.Reporter.log("Actual Title :: "+sActVal);2392 org.testng.Reporter.log("Step Status ::"+bStatus);2393 org.testng.Reporter.log("expected text ::"+ sExpText);2394 screenShot(sTestName);2395 org.testng.Reporter.log(" ");2396 2397 } catch(Exception e) {2398 2399 if (Utils.handleIntermediateIssue()) { verify_SubStringInText(sTestName,oEle,sObjStr, sExpText); }2400 2401 org.testng.Reporter.log("----------------------------------------------");2402 org.testng.Reporter.log("STEP :: "+sDesc);2403 org.testng.Reporter.log("Exception :: "+e);2404 screenShot(sTestName);2405 org.testng.Reporter.log(" ");2406 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2407 Assert.fail();2408 }2409 return bStatus;2410 }2411 2412 public static void acceptAlert(String sTestName) throws HeadlessException, IOException, AWTException, InterruptedException {2413 2414 String sDesc = Logs.log(sTestName)+" :: Clicking on 'OK' of Popup";2415 2416 try {2417 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);2418 Alert alert = lDriver.switchTo().alert(); 2419 alert.accept();2420 2421 2422 org.testng.Reporter.log("--------------------------------------------------");2423 org.testng.Reporter.log("Step ::"+sDesc);2424 org.testng.Reporter.log(" ");2425 2426 } catch(Exception e) {2427 2428 if (Utils.handleIntermediateIssue()) { acceptAlert(sTestName); }2429 2430 org.testng.Reporter.log("----------------------------------------------");2431 org.testng.Reporter.log("STEP :: "+sDesc);2432 org.testng.Reporter.log("Exception :: "+e);2433 screenShot(sTestName);2434 org.testng.Reporter.log(" ");2435 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2436 Assert.fail();2437 }2438 }2439 /*2440 * Accepts the alert.2441 * Usage : Clicks on CANCEL of Alert.2442 * 2443 * Parameter 1 : test case name2444 * 2445 * */2446 public static void cancelAlert(String sTestName) throws HeadlessException, IOException, AWTException, InterruptedException {2447 2448 String sDesc = Logs.log(sTestName)+" :: Clicking on 'CANCEL' of Popup";2449 2450 try {2451 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);2452 Alert alert = lDriver.switchTo().alert(); 2453 alert.dismiss();2454 2455 2456 org.testng.Reporter.log("--------------------------------------------------");2457 org.testng.Reporter.log("Step ::"+sDesc);2458 org.testng.Reporter.log(" ");2459 2460 } catch(Exception e) {2461 2462 if (Utils.handleIntermediateIssue()) { cancelAlert(sTestName); }2463 2464 org.testng.Reporter.log("----------------------------------------------");2465 org.testng.Reporter.log("STEP :: "+sDesc);2466 org.testng.Reporter.log("Exception :: "+e);2467 screenShot(sTestName);2468 org.testng.Reporter.log(" ");2469 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2470 Assert.fail();2471 }2472 }2473 /*2474 * Usage : Navigates one page Forward.2475 * Argument Required :: Test case name[Mandatory].2476 * */2477 public static void goForward(String sTestName) throws HeadlessException, IOException, AWTException, InterruptedException {2478 2479 String sDesc = Logs.log(sTestName)+" :: Moving Forward One Page";2480 2481 try{2482 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);2483 lDriver.navigate().forward();2484 2485 2486 org.testng.Reporter.log("--------------------------------------------------");2487 org.testng.Reporter.log("Step ::"+sDesc);2488 org.testng.Reporter.log(" ");2489 2490 } catch(Exception e) {2491 2492 if (Utils.handleIntermediateIssue()) { goForward(sTestName); }2493 2494 org.testng.Reporter.log("----------------------------------------------");2495 org.testng.Reporter.log("STEP :: "+sDesc);2496 org.testng.Reporter.log("Exception :: "+e);2497 screenShot(sTestName);2498 org.testng.Reporter.log(" ");2499 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2500 Assert.fail();2501 }2502 }2503 /*2504 * Verifies the value of the attribute "title" of the given object.2505 * 2506 * Parameter 1 : test case name2507 * Parameter 2 : xPath2508 * Parameter 3 : xPath string2509 * Parameter 4 : User has to provide the text , the same is then checked whether it is equal to the value of "title" attribute of the object.2510 * 2511 * */ 2512 2513 public static boolean verify_ToolTip(String sTestName, WebElement oEle, String sObjStr, String sExpText) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {2514 2515 String sDesc, sActVal = null, sExpVal; boolean bStatus = false;2516 2517 sDesc = Logs.log(sTestName)+ " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;2518 2519 try {2520 2521 sExpText = Utils.Helper.validateUserInput(sTestName, sExpText);2522 sExpVal = Reporter.filterUserInput(sExpText);2523 //Helper.checkReady(sTestName, oEle); 2524 sActVal = oEle.getAttribute("title").replace("\n", " "); 2525 bStatus = sExpVal.equals(sActVal);2526 2527 2528 org.testng.Reporter.log("--------------------------------------------------");2529 org.testng.Reporter.log("STEP :: "+sDesc+ " :: Verifying ToolTip Text:'");2530 org.testng.Reporter.log("expected Value :: "+ sExpVal);2531 org.testng.Reporter.log("Actual Value :: "+ sActVal);2532 org.testng.Reporter.log("Step Status ::"+bStatus);2533 org.testng.Reporter.log("Expected text ::"+sExpText);2534 screenShot(sTestName);2535 org.testng.Reporter.log(" ");2536 2537 } catch(Exception e) {2538 2539 if (Utils.handleIntermediateIssue()) { verify_ToolTip(sTestName, oEle, sObjStr, sExpText); }2540 2541 org.testng.Reporter.log("----------------------------------------------");2542 org.testng.Reporter.log("STEP :: "+sDesc);2543 org.testng.Reporter.log("Exception :: "+e);2544 screenShot(sTestName);2545 org.testng.Reporter.log(" ");2546 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2547 Assert.fail();2548 }2549 return bStatus;2550 }2551 /*2552 * Verifies the value of the attribute in CSS of the object given.2553 * 2554 * 2555 * Parameter 1 : test case name2556 * Parameter 2 : xPath2557 * Parameter 3 : xPath string2558 * Parameter 4 : attribute value2559 * Parameter 5 : expected value2560 * e.g "background-color" in parameter 4 and its value "#f0f2f5" in parameter 5.2561 * 2562 * */ 2563 2564 public static boolean verifyIn_CSSValue(String sTestName, WebElement oEle, String sObjStr, String sAttribute,String sExpVal)throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {2565 2566 String sDesc, sActVal = null, sVal=sAttribute; boolean bStatus = false;2567 2568 sDesc = Logs.log(sTestName)+ " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;2569 2570 try {2571 sAttribute = Utils.Helper.validateUserInput(sTestName, sAttribute);2572 sExpVal = Utils.Helper.validateUserInput(sTestName, sExpVal);2573 2574 sAttribute = Reporter.filterUserInput(sAttribute);2575 //Helper.checkReady(sTestName, oEle);2576 2577 sActVal = oEle.getCssValue(sAttribute);2578 bStatus = sActVal.equals(sExpVal);2579 2580 2581 org.testng.Reporter.log("--------------------------------------------------");2582 org.testng.Reporter.log("STEP :: "+sDesc+ " :: Verifying Value in CSS:'" + sVal + "'");2583 org.testng.Reporter.log("expected Value :: "+ sExpVal);2584 org.testng.Reporter.log("Actual Value :: "+ sActVal); 2585 org.testng.Reporter.log("Step Status ::"+bStatus);2586 screenShot(sTestName);2587 org.testng.Reporter.log(" ");2588 2589 } catch(Exception e) {2590 2591 if (Utils.handleIntermediateIssue()) { verifyIn_CSSValue(sTestName, oEle, sObjStr,sVal,sExpVal); }2592 2593 org.testng.Reporter.log("----------------------------------------------");2594 org.testng.Reporter.log("STEP :: "+sDesc);2595 org.testng.Reporter.log("Exception :: "+e);2596 screenShot(sTestName);2597 org.testng.Reporter.log(" ");2598 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2599 Assert.fail();2600 }2601 return bStatus;2602 } 2603 /*2604 * Finds the value of the attribute in CSS of given object and stores in the Variable Name provided in argument.2605 * Usage : To store values of attributes like position,padding,background-color etc. 2606 * 2607 * Parameter 1 : test case name2608 * Parameter 2 : xPath2609 * Parameter 3 : xPath string2610 * Parameter 4 : attribute value2611 * Parameter 5 : variable value2612 * e.g. "position" in paramter 4 and variabe "temp" in parameter 5.2613 * 2614 * */2615 public static void store_CSSValue(String sTestName, WebElement oEle, String sObjStr,String sComputedVal,String sVarName) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException { 2616 2617 String sDesc, sActVal; 2618 sDesc = Logs.log(sTestName) + "GetCSS : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;2619 2620 try {2621 2622 sComputedVal = Utils.Helper.validateUserInput(sTestName, sComputedVal);2623 sVarName = Utils.Helper.validateUserInput(sTestName, sVarName);2624 2625 if (sVarName.equals("")) {2626 sVarName="Temp";2627 } 2628 sActVal = oEle.getCssValue(sComputedVal);2629 Utils.setScriptParams(sTestName, sVarName, sActVal);2630 2631 //Reporter.print(sTestName,sDesc + ", Type:("+sComputedVal+"), Got Value:("+sActVal+")");2632 org.testng.Reporter.log("--------------------------------------------------");2633 org.testng.Reporter.log("Step ::"+sDesc);2634 org.testng.Reporter.log("Type :: "+ sComputedVal);2635 org.testng.Reporter.log("Actual Value :: "+ sActVal);2636 org.testng.Reporter.log(" ");2637 2638 } catch(Exception e) {2639 2640 if (Utils.handleIntermediateIssue()) { store_CSSValue(sTestName,oEle,sObjStr,sComputedVal,sVarName); }2641 2642 org.testng.Reporter.log("----------------------------------------------");2643 org.testng.Reporter.log("STEP :: "+sDesc);2644 org.testng.Reporter.log("Exception :: "+e);2645 screenShot(sTestName);2646 org.testng.Reporter.log(" ");2647 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2648 Assert.fail();2649 }2650 }2651 /*2652 * Stores Current Title in Variable Name provided as argument.2653 * 2654 * Parameter 1 : test case name2655 * Parameter 2 : xPath2656 * Parameter 3 : xPath string2657 * Parameter 4 : attribute value2658 * Parameter 5 : User has to provide the Variable Name to store the the title of the current page. e.g. "Temp"2659 * 2660 * */2661 public static void store_Title(String sTestName, String sUserVal) throws HeadlessException, IOException, AWTException, InterruptedException { 2662 2663 String sDesc, sActVal, sVarName; 2664 sDesc = Logs.log(sTestName);2665 2666 try { 2667 sUserVal = Utils.Helper.validateUserInput(sTestName, sUserVal);2668 2669 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName); 2670 sVarName = (sUserVal.equals("")) ? "Temp" : sUserVal;2671 sActVal =lDriver.getTitle();2672 Utils.setScriptParams(sTestName, sVarName, sActVal);2673 2674 2675 org.testng.Reporter.log("--------------------------------------------------");2676 org.testng.Reporter.log("Step ::"+sDesc + " :: Store (Current Title -" + sActVal + ") in Local Variable '" + sVarName + "'");2677 org.testng.Reporter.log(" ");2678 2679 } catch(Exception e) {2680 2681 if (Utils.handleIntermediateIssue()) { store_Title(sTestName,sUserVal); }2682 2683 org.testng.Reporter.log("----------------------------------------------");2684 org.testng.Reporter.log("STEP :: "+sDesc);2685 org.testng.Reporter.log("Exception :: "+e);2686 screenShot(sTestName);2687 org.testng.Reporter.log(" ");2688 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2689 Assert.fail();2690 } 2691 }2692 /*2693 * Clicks on the Text provided as Argument.2694 * Usage : Clicking on an object by providing its visible Text.2695 * 2696 * Parameter 1 : test case name [mandatory]2697 * parameter 2 : Provide the text on which you want to click.[mandatory]2698 * */ 2699 public static void click_OnText(String sTestName, String sText) throws HeadlessException, IOException, AWTException, InterruptedException {2700 2701 String sDesc = Logs.log(sTestName)+" :: Click on Text: "+ sText;2702 boolean foundFlg = false;2703 2704 try {2705 2706 sText = Utils.Helper.validateUserInput(sTestName, sText);2707 2708 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName); 2709 @SuppressWarnings("unchecked")2710 List<WebElement> childEle = lDriver.findElements(By.tagName("*"));2711 for(WebElement oEle : childEle){ 2712 if(oEle.isDisplayed()) {2713 if (oEle.getAttribute("innerHTML").contains(sText)) {2714 oEle.click(); foundFlg = true; break;2715 }2716 }2717 }2718 sDesc=Logs.log(sTestName)+" :: Click on Text: "+ sText + ", found " + String.valueOf(foundFlg);2719 org.testng.Reporter.log("--------------------------------------------------");2720 org.testng.Reporter.log("Step ::"+sDesc);2721 org.testng.Reporter.log(" ");2722 2723 } catch(Exception e) {2724 2725 if (Utils.handleIntermediateIssue()) { click_OnText(sTestName, sText); }2726 2727 org.testng.Reporter.log("----------------------------------------------");2728 org.testng.Reporter.log("STEP :: "+sDesc);2729 org.testng.Reporter.log("Exception :: "+e);2730 screenShot(sTestName);2731 org.testng.Reporter.log(" ");2732 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2733 Assert.fail();2734 }2735 }2736 /*2737 * To send "enter" to an object.2738 * 2739 * Parameter 1 : test case name 2740 * */2741 2742 public static void enter(String sTestName, WebElement oEle, String sObjStr) throws HeadlessException, IOException, AWTException, InterruptedException {2743 String sDesc = "" ; 2744 2745 try {2746 2747 sDesc = Logs.log(sTestName) + " in Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )";2748 2749 oEle.sendKeys(Keys.ENTER);2750 2751 org.testng.Reporter.log("--------------------------------------------------");2752 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");2753 org.testng.Reporter.log(" ");2754 2755 } catch(Exception e) {2756 2757 if (Utils.handleIntermediateIssue()) { enter(sTestName, oEle, sObjStr); }2758 2759 org.testng.Reporter.log("----------------------------------------------");2760 org.testng.Reporter.log("STEP :: "+sDesc);2761 org.testng.Reporter.log("Exception :: "+e);2762 screenShot(sTestName);2763 org.testng.Reporter.log(" ");2764 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2765 Assert.fail();2766 }2767 }2768 /*2769 * Stores font color of the object in Variable Name given as argument2770 * 2771 * Parameter 1 : test case name2772 * Parameter 2 : xPath2773 * Parameter 3 : xPath string2774 * Parameter 4 : User has to provide the variable name in which font color of the object will be stored.2775 * 2776 * */2777 public static void store_FontColor(String sTestName, WebElement oEle, String sObjStr, String sVarName) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {2778 2779 String sDesc, sActVal; 2780 2781 sDesc = Logs.log(sTestName)+" :: Reterving Font color of Obj : "+sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;2782 2783 try { 2784 2785 sVarName = Utils.Helper.validateUserInput(sTestName, sVarName);2786 2787 sActVal = oEle.getCssValue("color");2788 String[] numbers = sActVal.replace("rgba(", "").replace(")", "").split(",");2789 int iR = Integer.parseInt(numbers[0].trim()); int iG = Integer.parseInt(numbers[1].trim()); int iB = Integer.parseInt(numbers[2].trim());2790 sActVal = String.format("#%02x%02x%02x", iR, iG, iB).toUpperCase();2791 2792 sVarName = (sVarName.equals("")) ? "Temp" : sVarName;2793 Utils.setScriptParams(sTestName, sVarName, sActVal);2794 2795 org.testng.Reporter.log("--------------------------------------------------");2796 org.testng.Reporter.log("Step ::"+sDesc + " :: Store '" + sActVal + "' of "+ sObjStr + " in Local Variable '" + sVarName + "'");2797 org.testng.Reporter.log(" ");2798 2799 } catch(Exception e) {2800 2801 if (Utils.handleIntermediateIssue()) { store_FontColor(sTestName,oEle,sObjStr,sVarName); }2802 2803 org.testng.Reporter.log("----------------------------------------------");2804 org.testng.Reporter.log("STEP :: "+sDesc);2805 org.testng.Reporter.log("Exception :: "+e);2806 screenShot(sTestName);2807 org.testng.Reporter.log(" ");2808 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2809 Assert.fail();2810 }2811 }2812 /*2813 * Verifies the text given as argument is present in text of object(id=errorDiv)2814 * 2815 * Parameter 1 : test case name2816 * Parameter 2 : User has to provide the text , the same is then checked whether it is present in object(id=errorDiv) or not.2817 * 2818 * */ 2819 2820 public static void verifyIn_Error(String sTestName, String sExpText) throws Exception { 2821 2822 String sDesc = "";2823 2824 try {2825 2826 sExpText = Utils.Helper.validateUserInput(sTestName, sExpText);2827 sDesc = Logs.log(sTestName) + " :: Validating error message( " + sExpText + " )";2828 2829 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);2830 WebElement oEle = (WebElement) lDriver.findElement(By.xpath("//*[@id='errorDiv']"));2831 verify_SubStringInText(sTestName, oEle, "errObj", sExpText);2832 2833 2834 org.testng.Reporter.log("--------------------------------------------------");2835 org.testng.Reporter.log("Step ::"+sDesc);2836 org.testng.Reporter.log(" ");2837 2838 } catch(Exception e) {2839 2840 if (Utils.handleIntermediateIssue()) { verifyIn_Error(sTestName,sExpText); }2841 2842 org.testng.Reporter.log("----------------------------------------------");2843 org.testng.Reporter.log("STEP :: "+sDesc);2844 org.testng.Reporter.log("Exception :: "+e);2845 screenShot(sTestName);2846 org.testng.Reporter.log(" ");2847 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2848 Assert.fail();2849 }2850 }2851 2852 /*2853 * Opens link in new window2854 * 2855 * Parameter 1 : test case name2856 * Parameter 2 : xPath2857 * parameter 3 : xpath in string format2858 * 2859 * */2860 2861 2862 public static void openIn_NewTab(String sTestName, WebElement oEle, String sObjStr) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException { 2863 2864 String sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;2865 2866 try{2867 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);2868 Utils.setScriptParams(sTestName, "Parent_Brwsr", lDriver.getWindowHandle());2869 Actions newTab = new Actions(lDriver);2870 newTab.moveToElement(oEle); 2871 newTab.perform();2872 newTab.keyDown(Keys.CONTROL).click(oEle).build().perform();2873 2874 2875 2876 org.testng.Reporter.log("--------------------------------------------------");2877 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");2878 org.testng.Reporter.log(" ");2879 2880 for(String winHandle : lDriver.getWindowHandles()){2881 lDriver.switchTo().window(winHandle); 2882 } 2883 Utils.setScriptParams(sTestName, "Child_Brwsr", lDriver.getWindowHandle());2884 2885 } catch(Exception e) {2886 2887 if (Utils.handleIntermediateIssue()) { openIn_NewTab(sTestName, oEle, sObjStr); }2888 2889 org.testng.Reporter.log("----------------------------------------------");2890 org.testng.Reporter.log("STEP :: "+sDesc);2891 org.testng.Reporter.log("Exception :: "+e);2892 screenShot(sTestName);2893 org.testng.Reporter.log(" ");2894 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2895 Assert.fail();2896 }2897 }2898 /*2899 * Focuses on object2900 * 2901 * Parameter 1 : test case name2902 * Parameter 2 : xPath2903 * parameter 3 : xpath in string format2904 * 2905 * */ 2906 2907 public static void focus(String sTestName, WebElement oEle, String sObjStr) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException { 2908 2909 String sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;2910 2911 try{2912 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName); 2913 if ("input".equals(oEle.getTagName())) {2914 oEle.sendKeys("");2915 } else {2916 new Actions(lDriver).moveToElement(oEle).perform();2917 }2918 2919 2920 org.testng.Reporter.log("--------------------------------------------------");2921 org.testng.Reporter.log("Step ::"+sDesc + " :: Focussed on Obj : " + sObjStr + ")");2922 org.testng.Reporter.log(" ");2923 2924 } catch(Exception e) {2925 2926 if (Utils.handleIntermediateIssue()) { focus(sTestName,oEle,sObjStr); }2927 2928 org.testng.Reporter.log("----------------------------------------------");2929 org.testng.Reporter.log("STEP :: "+sDesc);2930 org.testng.Reporter.log("Exception :: "+e);2931 screenShot(sTestName);2932 org.testng.Reporter.log(" ");2933 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2934 Assert.fail();2935 }2936 }2937 /*2938 * Checks if the value is empty or not.2939 * Can be used where user want to validate the value of a stored variable during execution.2940 * User can provide the variable name (i.e. Local/Test), the same can be verified whether it is empty or not. e.g. Local{UserName}2941 * Note:2942 * If user want to stop the test execution against a validation failure, append *EXIT_ON_FAIL* at end of argument.2943 * For negative validation, append *NOT* at end of argument. E.g. <Arg_By_User>*NOT*2944 * Append *EXIT_ON_FAIL**NOT* for both cases to work simultaneously.2945 *2946 * Parameter 1 : Test case name[Mandatory]2947 * Parameter 2 : value to check[Mandatory]2948 * */2949 2950 public static boolean is_Empty(String sTestName, String sVal) throws HeadlessException, IOException, AWTException, InterruptedException {2951 2952 String sDesc = "", sExpVal; boolean bStatus = false;2953 2954 try { 2955 sVal = Utils.Helper.validateUserInput(sTestName, sVal);2956 sDesc = Logs.log(sTestName) + " :: Value - " + sVal;2957 sExpVal = Reporter.filterUserInput(sVal);2958 2959 bStatus = sExpVal.isEmpty();2960 Reporter.print(sTestName, sVal, sDesc, "NA","NA", bStatus);2961// org.testng.Reporter.log("--------------------------------------------------");2962// org.testng.Reporter.log("Step ::"+sDesc);2963// org.testng.Reporter.log(" ");2964 2965 } catch(Exception e) {2966 2967 if (Utils.handleIntermediateIssue()) { is_Empty(sTestName, sVal); }2968 2969 org.testng.Reporter.log("----------------------------------------------");2970 org.testng.Reporter.log("STEP :: "+sDesc);2971 org.testng.Reporter.log("Exception :: "+e);2972 org.testng.Reporter.log(" ");2973 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);2974 Assert.fail();2975 }2976 return bStatus;2977 }2978 2979 /*2980 * Hover the object2981 * 2982 * Parameter 1 : test case name2983 * Parameter 2 : xPath2984 * parameter 3 : xpath in string format2985 * 2986 * */2987 public static void mouseOver(String sTestName, WebElement oEle, String sObjStr) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException { 2988 2989 String sDesc ; 2990 2991 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;2992 2993 try {2994 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);2995 Actions newTab = new Actions(lDriver);2996 newTab.moveToElement(oEle); 2997 newTab.perform();2998 2999 org.testng.Reporter.log("--------------------------------------------------");3000 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");3001 org.testng.Reporter.log(" ");3002 3003 3004 } catch(Exception e) {3005 3006 if (Utils.handleIntermediateIssue()) { mouseOver(sTestName, oEle, sObjStr);; }3007 3008 org.testng.Reporter.log("----------------------------------------------");3009 org.testng.Reporter.log("STEP :: "+sDesc);3010 org.testng.Reporter.log("Exception :: "+e);3011 screenShot(sTestName);3012 org.testng.Reporter.log(" ");3013 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);3014 Assert.fail();3015 }3016 }3017 /*3018 * Clicks on the Object.3019 * 3020 * Parameter 1 : test case name3021 * Parameter 2 : xPath3022 * parameter 3 : xpath in string format3023 * 3024 * */3025 public static void mouseClick(String sTestName, WebElement oEle, String sObjStr) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException { 3026 String sDesc = "";3027 3028 3029 sDesc = Logs.log(sTestName) + " on Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )";3030 try {3031 AppiumDriver lDriver =(AppiumDriver)Utils.getObjectDriver(sTestName);3032 3033 3034 Actions newTab = new Actions(lDriver);3035 newTab.moveToElement(oEle); 3036 newTab.perform();3037 newTab.click(oEle).build().perform();3038 3039 3040 org.testng.Reporter.log("--------------------------------------------------");3041 org.testng.Reporter.log("Step ::"+sDesc + " :: Performed");3042 org.testng.Reporter.log(" "); 3043 }3044 catch (Exception e) {3045 oEle.click();3046 }3047 3048 }3049 // takes screenshot 3050 public static void screen_Capture(String sTestName , String sUsrVal) throws HeadlessException, IOException, AWTException, InterruptedException { 3051 3052 String sDesc = "" ; 3053 3054 try {3055 sUsrVal = Utils.Helper.validateUserInput(sTestName, sUsrVal);3056 sDesc = Logs.log(sTestName) + " - " + sUsrVal ;3057 3058 org.testng.Reporter.log("--------------------------------------------------");3059 org.testng.Reporter.log("STEP :: "+sDesc+ " :: Verifying ToolTip Text:'");3060 screenShot(sTestName);3061 org.testng.Reporter.log(" ");3062 3063 } catch(Exception e) {3064 3065 if (Utils.handleIntermediateIssue()) { screen_Capture(sTestName, sUsrVal); }3066 3067 org.testng.Reporter.log("----------------------------------------------");3068 org.testng.Reporter.log("STEP :: "+sDesc);3069 org.testng.Reporter.log("Exception :: "+e);3070 screenShot(sTestName);3071 org.testng.Reporter.log(" ");3072 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);3073 Assert.fail();3074 }3075 }3076 /*3077 * To Store the cell data of specified row and column in given variable name.3078 * 3079 * Parameter 1 : test case name3080 * Parameter 2 : xPath3081 * parameter 3 : xPath in string format3082 * Parameter 4 : Provide row number and column number separated by Double colon "::" 3083 * Parameter 5 : Variable name 3084 * e.g. "1::2" in parameter 4 and "user1" in parameter 5.3085 * 3086 * Both RowNumber and Column Number can be set "ALL" to store all Rows and All Columns values. 3087 * e.g. "1::ALL" in parameter 4 Stores all columns values of first row and the variable "temp1" is stored in the parameter 5.3088 * 3089 * */3090 3091 public static void get_Cell_Data(String sTestName, WebElement oEle, String sObjStr, String sRowCol,String sVarName) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {3092 3093 String sDesc = "", sActVal ="", sColumn = "", sRow="" , flagTh = "false",sVal=sRowCol; 3094 int sColumnNmbr, sRowNmbr,i=1;3095 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;3096 3097 try { 3098 3099 sRowCol = Utils.Helper.validateUserInput(sTestName, sRowCol);3100 sVarName = Utils.Helper.validateUserInput(sTestName, sVarName);3101 sRowCol = Reporter.filterUserInput(sRowCol);3102 if (sRowCol.contains("::")) {3103 sColumn = sRowCol.split("::")[1];3104 sRow = sRowCol.split("::")[0];3105 }3106 else {3107 //Reporter.print(sTestName, sVal + "*EXIT_ON_FAIL*", sDesc +" : Please provide input correctly", "True", "False", false);3108 org.testng.Reporter.log("--------------------------------------------------");3109 org.testng.Reporter.log("STEP :: "+sDesc+" : Please provide input correctly");3110 org.testng.Reporter.log("Actual Value :: "+ sActVal);3111 org.testng.Reporter.log("Step Status :: false");3112 screenShot(sTestName);3113 org.testng.Reporter.log(" ");3114 }3115 if(sVarName.equals(""))3116 {3117 sVarName="Temp";3118 }3119 if(sColumn.equalsIgnoreCase("ALL")) 3120 sColumnNmbr = -1;3121 else3122 sColumnNmbr = Integer.parseInt(sColumn);3123 if(sRow.equalsIgnoreCase("ALL")) {3124 sRowNmbr = -1 ;3125 } else 3126 sRowNmbr = Integer.parseInt(sRow);3127 3128 List<WebElement> rows = oEle.findElements(By.tagName("tr"));3129 3130 for(WebElement row : rows) {3131 List<WebElement> cols = null;3132 String htmlSource = row.getAttribute("innerHTML");3133 if (htmlSource.contains("<th") ) {3134 if (flagTh.equalsIgnoreCase("true")) {3135 continue;3136 }3137 else {3138 cols = row.findElements(By.tagName("th"));3139 flagTh = "true";3140 }3141 3142 }3143 else {3144 cols = row.findElements(By.tagName("td"));3145 }3146 if (sColumnNmbr==-1 && sRowNmbr==-1) { //All rows All Columns3147 sActVal = sActVal + "\nRow No." + i + ":";3148 for(int j=0;j<cols.size();j++)3149 sActVal = sActVal + cols.get(j).getText() +"|"; 3150 } 3151 else {3152 if(sColumnNmbr==-1 && sRowNmbr!=-1) { //Row Number but All Columns3153 if(i==sRowNmbr) {3154 sActVal = sActVal + "Row No." + i + ":";3155 for(int j=0;j<cols.size();j++)3156 sActVal = sActVal + cols.get(j).getText() +"|"; 3157 break;3158 }3159 }3160 else {3161 if(sRowNmbr==-1 && sColumnNmbr!=-1) //All rows But Column Number3162 sActVal = sActVal + cols.get(sColumnNmbr-1).getText() +"|";3163 else if(i==sRowNmbr) { //Row Number Column Number3164 sActVal = cols.get(sColumnNmbr-1).getText();3165 break;3166 }3167 }3168 }3169 i++;3170 }3171 3172 Utils.setScriptParams(sTestName, sVarName, sActVal);3173 Reporter.print(sTestName, sDesc + " :: Store Cell Data of Row: '" + sRow + "' and Column: '" + sColumn + "' in Local Variable '" + sVarName + "', Data is: '" + sActVal + "'");3174 org.testng.Reporter.log("--------------------------------------------------");3175 org.testng.Reporter.log("STEP :: "+sDesc+" :: Store Cell Data of Row: '" + sRow + "' and Column: '" + sColumn + "' in Local Variable '" + sVarName +"'");3176 org.testng.Reporter.log("Actual Value :: "+ sActVal);3177 org.testng.Reporter.log(" ");3178 3179 } catch(Exception e) {3180 3181 if (Utils.handleIntermediateIssue()) { get_Cell_Data(sTestName, oEle, sObjStr, sVal,sVarName);}3182 3183 org.testng.Reporter.log("----------------------------------------------");3184 org.testng.Reporter.log("STEP :: "+sDesc);3185 org.testng.Reporter.log("Exception :: "+e);3186 screenShot(sTestName);3187 org.testng.Reporter.log(" ");3188 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);3189 Assert.fail();3190 3191 }3192 }3193 /*3194 * To Store the cell data of specified column where other column's value matches with the expected value.3195 * 3196 * Parameter 1 : test case name3197 * Parameter 2 : xPath3198 * parameter 3 : xPath in string format3199 * Parameter 4 : Provide Column number to be compared and its expected value seperated by "=" , then required Column number 3200 * Parameter 5 : Variable name 3201 * e.g. "2=user1" in Parameter 4 and "3=user2" in Parameter 5.3202 * 3203 * */3204 public static void get_RowWith_CellData(String sTestName, WebElement oEle, String sObjStr,String sCol,String sVarName) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {3205 3206 String sDesc, sActVal ="", sUsrVal = "", sResult = "", flagTh = "false",sVal=sCol; int sRequiredColumnNmbr = 0, sColumnNmbr = 0;3207 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;3208 3209 try {3210 sCol = Utils.Helper.validateUserInput(sTestName, sCol);3211 sVarName = Utils.Helper.validateUserInput(sTestName, sVarName);3212 sCol = Reporter.filterUserInput(sCol);3213 3214 if (sCol.contains("=")) {3215 sColumnNmbr = Integer.parseInt(sCol.split("=")[0]);3216 sUsrVal = sCol.split("=")[1];3217 sRequiredColumnNmbr = Integer.parseInt(sVarName.split("=")[0]);3218 sVarName=sVarName.split("=")[1];3219 } 3220 else {3221 //Reporter.print(sTestName, sVal + "*EXIT_ON_FAIL*", sDesc +"Plese provide input correctly", "True", "False", false);3222 org.testng.Reporter.log("--------------------------------------------------");3223 org.testng.Reporter.log("STEP :: "+sDesc+"Plese provide input correctly");3224 org.testng.Reporter.log("Actual Value :: "+ sActVal);3225 org.testng.Reporter.log("Step Status :: false");3226 org.testng.Reporter.log(" ");3227 }3228 List<WebElement> rows = oEle.findElements(By.tagName("tr"));3229 3230 for(WebElement row : rows) {3231 List<WebElement> cols = null;3232 String htmlSource = row.getAttribute("innerHTML");3233 if (htmlSource.contains("<th") ) {3234 if (flagTh.equalsIgnoreCase("true")) {3235 continue;3236 }3237 else {3238 cols = row.findElements(By.tagName("th"));3239 flagTh = "true";3240 }3241 3242 }3243 else {3244 cols = row.findElements(By.tagName("td"));3245 }3246 sActVal = cols.get(sColumnNmbr-1).getText();3247 if(sActVal.equalsIgnoreCase(sUsrVal)) {3248 sResult = cols.get(sRequiredColumnNmbr-1).getText();3249 break;3250 }3251 3252 }3253 3254 Utils.setScriptParams(sTestName, sVarName, sResult);3255 3256 org.testng.Reporter.log("--------------------------------------------------");3257 org.testng.Reporter.log("Step ::"+sDesc + " :: Store Value of Column: '"+ sRequiredColumnNmbr + "' where Column '" + sColumnNmbr + "' has Value: '" + sUsrVal + "' in Local Variable '" + sVarName + "' Data is: '" + sResult + "'");3258 org.testng.Reporter.log(" ");3259 3260 } catch(Exception e) {3261 3262 if (Utils.handleIntermediateIssue()) { get_RowWith_CellData(sTestName, oEle, sObjStr, sVal,sVarName);}3263 3264 org.testng.Reporter.log("----------------------------------------------");3265 org.testng.Reporter.log("STEP :: "+sDesc);3266 org.testng.Reporter.log("Exception :: "+e);3267 screenShot(sTestName);3268 org.testng.Reporter.log(" ");3269 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);3270 Assert.fail();3271 3272 }3273 3274 }3275 /*3276 * Verifies the cell data of specified row and column.3277 * 3278 * Parameter 1 : test case name3279 * Parameter 2 : xPath3280 * parameter 3 : xPath in string format3281 * Parameter 4 : provide row number and column number separated by Double colon "::" 3282 * Parameter 5 : Variable name 3283 * e.g. "1::2" in Parameter 4 and "user1" in Parameter 5 which Verifies cell data of second Column of first row matches with "user1" or not.3284 *3285 * Both RowNumber and Column Number can be set "ALL" to store all Rows and All Columns values. 3286 * e.g. "1::ALL" in Parameter 4 Stores all columns values of first row and the variable "temp1" is stored in the Parameter 5.3287 * 3288 * */3289 3290 3291 public static void verify_Cell_Data(String sTestName, WebElement oEle, String sObjStr,String sRowCol,String sExpVal) throws HeadlessException, IOException, AWTException, ClassNotFoundException, InterruptedException {3292 3293 String sDesc = null,sVal=sRowCol, sActVal ="", sColumn = null, sRow="", flagTh = "false"; boolean bStatus = false; int sColumnNmbr = 0, sRowNmbr,i=1;3294 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;3295 3296 try { 3297 3298 sRowCol = Utils.Helper.validateUserInput(sTestName, sRowCol);3299 sExpVal=Utils.Helper.validateUserInput(sTestName, sExpVal);3300 sRowCol = Reporter.filterUserInput(sRowCol);3301 3302 //Helper.checkReady(sTestName, oEle);3303 sRow = sExpVal.split("::")[0];3304 if (sRowCol.contains("::")) {3305 sColumn = sRowCol.split("::")[1];3306 sRow = sRowCol.split("::")[0];3307 }3308 else {3309 org.testng.Reporter.log("--------------------------------------------------");3310 org.testng.Reporter.log("STEP :: "+sDesc+" : Please provide input correctly");3311 org.testng.Reporter.log("Actual Value :: "+ sActVal);3312 org.testng.Reporter.log("Step Status :: false");3313 org.testng.Reporter.log(" ");3314 }3315 3316 if(sColumn.equalsIgnoreCase("ALL")) 3317 sColumnNmbr = -1;3318 else3319 sColumnNmbr = Integer.parseInt(sColumn);3320 if(sRow.equalsIgnoreCase("ALL")) {3321 sRowNmbr = -1 ;3322 } else 3323 sRowNmbr = Integer.parseInt(sRow);3324 3325 List<WebElement> rows = oEle.findElements(By.tagName("tr"));3326 for(WebElement row : rows) {3327 List<WebElement> cols = null;3328 String htmlSource = row.getAttribute("innerHTML");3329 if (htmlSource.contains("<th") ) {3330 if (flagTh.equalsIgnoreCase("true")) {3331 continue;3332 }3333 else {3334 cols = row.findElements(By.tagName("th"));3335 flagTh = "true";3336 }3337 3338 }3339 else {3340 cols = row.findElements(By.tagName("td"));3341 }3342 if (sColumnNmbr==-1 && sRowNmbr==-1) {3343 for(int j=0;j<cols.size();j++) {3344 sActVal = sActVal +cols.get(j).getText() + "|";3345 if(sActVal.contains(sExpVal)) {3346 bStatus = true;3347 break;3348 }3349 }3350 } 3351 else {3352 if(sColumnNmbr==-1 && sRowNmbr!=-1) {3353 if(i==sRowNmbr) {3354 for(int j=0;j<cols.size();j++) {3355 sActVal = sActVal +cols.get(j).getText()+ "|";3356 if(sActVal.contains(sExpVal)) {3357 bStatus = true;3358 break;3359 }3360 }3361 }3362 }3363 else {3364 if(sRowNmbr==-1 && sColumnNmbr!=-1) { 3365 sActVal = sActVal + cols.get(sColumnNmbr-1).getText()+ "|";3366 if(sActVal.contains(sExpVal)) {3367 bStatus = true;3368 break;3369 }3370 }3371 else if(i==sRowNmbr) {3372 sActVal = cols.get(sColumnNmbr-1).getText();3373 if(sActVal.equalsIgnoreCase(sExpVal)) {3374 bStatus = true;3375 break;3376 }3377 }3378 }3379 }3380 i++;3381 3382 }3383 3384 org.testng.Reporter.log("--------------------------------------------------");3385 org.testng.Reporter.log("STEP :: "+sDesc+" : Please provide input correctly");3386 org.testng.Reporter.log("Expected Value :: "+ sExpVal);3387 org.testng.Reporter.log("Actual Value :: "+ sActVal);3388 org.testng.Reporter.log("Step Status :: "+bStatus);3389 screenShot(sTestName);3390 org.testng.Reporter.log(" ");3391 3392 } catch(Exception e) {3393 3394 if (Utils.handleIntermediateIssue()) { verify_Cell_Data(sTestName,oEle,sObjStr, sVal,sExpVal); }3395 3396 org.testng.Reporter.log("----------------------------------------------");3397 org.testng.Reporter.log("STEP :: "+sDesc);3398 org.testng.Reporter.log("Exception :: "+e);3399 screenShot(sTestName);3400 org.testng.Reporter.log(" ");3401 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);3402 Assert.fail();3403 3404 }3405 }3406 /*3407 * To verify the cell data of specified column where other column's value matches with the expected value.3408 * 3409 * Parameter 1 : test case name3410 * Parameter 2 : xPath3411 * parameter 3 : xPath in string format3412 * Parameter 4 : provide Column number to be compared and its expected value separated by "=" , then required Column number3413 * Parameter 5 : expected value to be verified3414 * e.g. "3=London" in Parameter 4 and "4=country" in Parameter 5.3415 * 3416 * */ 3417 3418 public static void verify_RowWith_CellData(String sTestName, WebElement oEle, String sObjStr, String sCol,String sExpVal) throws HeadlessException, IOException, AWTException, ClassNotFoundException, InterruptedException {3419 3420 String sDesc = "", sActVal ="",sVal=sCol, sResult = "", sColumnVal = "", flagTh = "false"; boolean bStatus = false; int sRequiredColumnNmbr = 0, sColumnNmbr = 0;3421 sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )" ;3422 3423 try {3424 3425 sCol = Utils.Helper.validateUserInput(sTestName, sCol);3426 sExpVal = Utils.Helper.validateUserInput(sTestName, sExpVal);3427 sCol = Reporter.filterUserInput(sCol);3428 3429 if (sCol.contains("=")) {3430 sColumnNmbr = Integer.parseInt(sCol.split("=")[0]);3431 sColumnVal = sCol.split("=")[1];3432 sRequiredColumnNmbr = Integer.parseInt(sExpVal.split("=")[0]);3433 sExpVal = sExpVal.split("=")[1];3434 } 3435 else {3436 Reporter.print(sTestName, sVal + "*EXIT_ON_FAIL*", sDesc +"Plese provide input correctly", "True", "False", false);3437 }3438 3439 List<WebElement> rows = oEle.findElements(By.tagName("tr"));3440 3441 for(WebElement row : rows) {3442 List<WebElement> cols = null;3443 String htmlSource = row.getAttribute("innerHTML");3444 if (htmlSource.contains("<th") ) {3445 if (flagTh.equalsIgnoreCase("true")) {3446 continue;3447 }3448 else {3449 cols = row.findElements(By.tagName("th"));3450 flagTh = "true";3451 }3452 3453 }3454 else {3455 cols = row.findElements(By.tagName("td"));3456 }3457 sActVal = cols.get(sColumnNmbr-1).getText();3458 if(sActVal.equalsIgnoreCase(sColumnVal)) {3459 3460 sResult = cols.get(sRequiredColumnNmbr-1).getText();3461 if(sResult.equalsIgnoreCase(sExpVal))3462 bStatus = true;3463 break;3464 }3465 }3466 3467 org.testng.Reporter.log("--------------------------------------------------");3468 org.testng.Reporter.log("STEP :: "+sDesc+" : Please provide input correctly");3469 org.testng.Reporter.log("Expected Value :: "+ sExpVal);3470 org.testng.Reporter.log("Actual Value :: "+ sActVal);3471 org.testng.Reporter.log("Step Status :: "+bStatus);3472 screenShot(sTestName);3473 org.testng.Reporter.log(" ");3474 3475 } catch(Exception e) {3476 3477 if (Utils.handleIntermediateIssue()) { verify_RowWith_CellData(sTestName, oEle, sObjStr, sVal,sExpVal);}3478 3479 org.testng.Reporter.log("----------------------------------------------");3480 org.testng.Reporter.log("STEP :: "+sDesc);3481 org.testng.Reporter.log("Exception :: "+e);3482 screenShot(sTestName);3483 org.testng.Reporter.log(" ");3484 Assert.assertFalse(false, "EXCEPTION AT STEP :: "+sDesc);3485 Assert.fail();3486 } 3487 3488 } 3489 3490 3491 3492 public static void closeApp(String sTestName) throws IOException, InterruptedException, HeadlessException, AWTException {3493 String sDesc = Logs.log(sTestName);3494 3495 try {3496 ((AppiumDriver)Utils.getObjectDriver(sTestName)).close();3497 Reporter.print(sTestName,sDesc + " :: CLOSE PERFORMED");3498 3499 } catch(Exception e)3500 {3501 if (Utils.handleIntermediateIssue()) { closeApp(sTestName);}3502 3503 3504 org.testng.Reporter.log("--------------------------------------------------");3505 org.testng.Reporter.log("STEP :: "+sDesc+" :: PROBLEM IN CLOSING");3506 org.testng.Reporter.log(" ");3507 }3508 }3509 /*3510 * User can type into an already typed input box without erasing the previous typed data if needed 3511 * 3512 * Parameter 1 : test case name3513 * parameter 2 : xPaath3514 * Parameter 3 : xPath in string format3515 * Parameter 4 : User has to provide the text that needs to be sent to the Web Element3516 * 3517 * */ 3518 3519 public static void type_WithoutClear(String sTestName, WebElement oEle, String sObjStr, String sVal) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {3520 String sDesc = Logs.log(sTestName);3521 try {3522 sVal = Utils.Helper.validateUserInput(sTestName, sVal);3523 oEle.sendKeys(sVal);3524 3525 org.testng.Reporter.log("--------------------------------------------------");3526 org.testng.Reporter.log("STEP :: "+sDesc+" :: Performed");3527 org.testng.Reporter.log(" ");3528 } 3529 catch(Exception e) {3530 if (Utils.handleIntermediateIssue()) { 3531 type_WithoutClear(sTestName, oEle, sObjStr, sVal); }3532 Reporter.printError(sTestName, e, sDesc);3533 }3534 }3535 3536 public static void select_By_Index(String sTestName, WebElement oEle, String sObjStr, String sOption) throws HeadlessException, IOException, AWTException, InterruptedException, ClassNotFoundException {3537 3538 String sDesc = Logs.log(sTestName) + " Object : " + sObjStr + " -> ( " + Utils.Helper.getBy(sObjStr) + " )";3539 3540 try { 3541 sOption = Utils.Helper.validateUserInput(sTestName, sOption);3542 3543 if(oEle.getTagName().toString().equalsIgnoreCase("select")){3544 Select oSelect = new Select(oEle);3545 oSelect.selectByIndex(Integer.parseInt(sOption)-1); 3546 3547 3548 org.testng.Reporter.log("--------------------------------------------------");3549 org.testng.Reporter.log("STEP :: "+sDesc+" :: Performed");3550 org.testng.Reporter.log(" ");3551 }3552 else3553 Reporter.print(sTestName, sDesc + " :: Error : This Method Works only for Html : 'Select' tag");3554 3555 } catch(Exception e) {3556 3557 if (Utils.handleIntermediateIssue()) { select_By_Index(sTestName, oEle, sObjStr, sOption); }3558 Reporter.printError(sTestName, e, sDesc);3559 }3560 }3561 // takes screenshot3562 public static void screenShot(String sTestName) {3563 WebDriver lDriver =(WebDriver)Utils.getObjectDriver(sTestName);3564 File srcFile=((TakesScreenshot)lDriver).getScreenshotAs(OutputType.FILE);3565 String timestamp= new SimpleDateFormat("yyyyMMdd_HHmmss").format(Calendar.getInstance().getTime());3566 File destFile= new File(System.getProperty("user.dir") + "/com.automatics.packages/com/automatics/packages/screenshots/"+sTestName+"_"+timestamp+".png");3567 try {3568 FileUtils.copyFile(srcFile, destFile);3569 } catch (IOException e) {3570 e.printStackTrace();3571 }3572 org.testng.Reporter.log("SCREENSHOT :: <a href='"+destFile+"'> <img_src='"+destFile+"' height='100', width='100' />image_link</a>");3573 }3574 3575 3576 private static class Helper {3577 3578 3579 static boolean IsKeyboardPresent () throws Exception {3580 String checkKeyboardCommand = "adb shell dumpsys input_method";3581 boolean presentFlg = false;3582 3583 try {3584 Process process = Runtime.getRuntime().exec(checkKeyboardCommand);3585 BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));3586 ...
Source:TestNG.java
23import org.openqa.selenium.WebDriver;4import org.openqa.selenium.chrome.ChromeDriver;5import org.testng.Assert;6import org.testng.Reporter;7import org.testng.annotations.AfterClass;8import org.testng.annotations.AfterMethod;9import org.testng.annotations.AfterSuite;10import org.testng.annotations.AfterTest;11import org.testng.annotations.BeforeClass;12import org.testng.annotations.BeforeMethod;13import org.testng.annotations.BeforeSuite;14import org.testng.annotations.BeforeTest;15import org.testng.annotations.DataProvider;16import org.testng.annotations.Optional;17import org.testng.annotations.Parameters;18import org.testng.annotations.Test;19import org.testng.asserts.SoftAssert;2021public class TestNG {22//Annotaion 23/*24 @BeforeSuite25 public void test2() {26 Reporter.log("test2");27 }28 29 @AfterSuite30 public void test3() {31 Reporter.log("test3");32 }33 34 @BeforeClass35 public void test4() {36 Reporter.log("test4");37 }38 39 @AfterClass40 public void test5() {41 Reporter.log("test5");42 }43 44 @BeforeTest45 public void test6() {46 Reporter.log("test6");47 }48 49 @AfterMethod50 public void test7() {51 Reporter.log("test7");52 }53 54 @AfterTest55 public void test8() {56 Reporter.log("test8");57 } 58 59 @BeforeMethod60 public void test9() {61 Reporter.log("test9");62 }63 @Test64 public void test10() {65 Reporter.log("AllTest",true);66 }67 */68 69//Data Provider 70 /*@DataProvider71 public Object[][] test() {72 Object[][] data=new Object[2][2];73 data[0][0]="UserA";74 data[0][1]= 123;75 76 data[1][0]="UserB";77 data[1][1]= 456;78 return data;79 80 }81 @Test(dataProvider="test")82 public void test1(String un,int pw){83 Reporter.log("create user:"+un+"pw:"+pw,true);84 }85 */86 87//Groups88/*@BeforeMethod(alwaysRun=true)89 public void test2() {90 Reporter.log("test2",true);91 }92 93@Test(groups= {"a"})94 public void test3() {95 Reporter.log("test3",true);96 }97 98@Test(groups= {"b","c"})99 public void test4() {100 Reporter.log("test4",true);101 }102 103@Test(groups= {"b","a"})104 public void test5() {105 Reporter.log("test5",true);106 }107 108@Test()109 public void test6() {110 Reporter.log("test6");111 }*/112//----------------------------------------------------------------------------------- 113//SOftAssert and assert 114/* 115@Test116 public void testLogin() {117 WebDriver driver = new ChromeDriver();118 driver.get("http://demo.actitime.com");119 String actTitle = driver.getTitle();120 // Reporter.log(actTitle, true);121 String expTitle = "actiTIME - login";122 SoftAssert s = new SoftAssert();123 s.assertEquals(actTitle, expTitle);124 driver.close();125 s.assertAll();// dont write any statements after this126127 }128129 @Test130 public void testLogin1() {131 WebDriver driver = new ChromeDriver();132 driver.get("http://demo.actitime.com");133 String actTitle = driver.getTitle();134 String expTitle = "actiTIME - Login";135 Assert.assertEquals(actTitle, expTitle);136 driver.close();137 }138*/139//----------------------------------------------------------------------------------140 /*@Parameters({"city","pincode"})141 142 @Test143 public void testA(@Optional("Delhi")String c,@Optional("market")String a) {144 Reporter.log(c + a, true);145 }146 */147148 149 /*@Parameters({"city","pincode"})150 @Test151 public void testA(String c,String a) {152 Reporter.log(c+a, true);153 }*/154 155 156//------------------------------------------------------------------------- 157 158 @Test()159 public void testA() {160 Reporter.log("create user",true);161 162}163 164 @Test(dependsOnMethods= {"testA","testC"})165 public void testB() {166 Reporter.log("delete user",true);167 }168 @Test()169 public void testC() {170 Reporter.log("edit user",true);171 172}
...
Source:BasicExtentReport.java
...11import com.aventstack.extentreports.ExtentTest;12import com.aventstack.extentreports.Status;13import com.aventstack.extentreports.markuputils.ExtentColor;14import com.aventstack.extentreports.markuputils.MarkupHelper;15import com.aventstack.extentreports.reporter.ExtentHtmlReporter;16import com.aventstack.extentreports.reporter.configuration.ChartLocation;17import com.aventstack.extentreports.reporter.configuration.Theme;18public class BasicExtentReport {19 // builds a new report using the html template20 public ExtentHtmlReporter htmlReporter;21 public ExtentReports extent;22 // helps to generate the logs in test report.23 public ExtentTest test;24 @Parameters({ "OS", "browser" })25 @BeforeTest26 public void startReport(String OS, String browser) {27 // initialize the HtmlReporter28 htmlReporter = new ExtentHtmlReporter(System.getProperty("user.dir") + "/test-output/testReport.html");29 // initialize ExtentReports and attach the HtmlReporter30 extent = new ExtentReports();31 extent.attachReporter(htmlReporter);32 // To add system or environment info by using the setSystemInfo method.33 extent.setSystemInfo("OS", OS);34 extent.setSystemInfo("Browser", browser);35 // configuration items to change the look and feel36 // add content, manage tests etc37 htmlReporter.config().setChartVisibilityOnOpen(true);38 htmlReporter.config().setDocumentTitle("Extent Report Demo");39 htmlReporter.config().setReportName("Test Report");40 htmlReporter.config().setTestViewChartLocation(ChartLocation.TOP);41 htmlReporter.config().setTheme(Theme.STANDARD);42 htmlReporter.config().setTimeStampFormat("EEEE, MMMM dd, yyyy, hh:mm a '('zzz')'");43 }44 @AfterMethod45 public void getResult(ITestResult result) {46 if (result.getStatus() == ITestResult.FAILURE) {47 test.log(Status.FAIL, MarkupHelper.createLabel(result.getName() + " FAILED ", ExtentColor.RED));48 test.fail(result.getThrowable());49 } else if (result.getStatus() == ITestResult.SUCCESS) {50 test.log(Status.PASS, MarkupHelper.createLabel(result.getName() + " PASSED ", ExtentColor.GREEN));51 } else {52 test.log(Status.SKIP, MarkupHelper.createLabel(result.getName() + " SKIPPED ", ExtentColor.ORANGE));53 test.skip(result.getThrowable());54 }55 }56 @AfterTest...
Source:New3Test.java
2import org.testng.annotations.Test;3import org.testng.annotations.BeforeMethod;4import org.testng.annotations.AfterMethod;5import org.testng.annotations.BeforeClass;6import org.testng.Reporter;7import org.testng.annotations.AfterClass;8import org.testng.annotations.BeforeTest;9import org.testng.annotations.AfterTest;10import org.testng.annotations.BeforeSuite;11import org.testng.annotations.AfterSuite;12public class New3Test {13 @Test(priority=0)14 public void CreateCustomer() {15 Reporter.log("create customer",true);16 }17 @Test(priority=1)18 public void EditCustomer() {19 Reporter.log("edit customer",true);20 }21 @Test(priority=2)22 public void DeleteCustomer() {23 Reporter.log("delete customer",true);24 }25 @BeforeMethod26 public void beforeMethod() {27 Reporter.log("login",true);28 }29 @AfterMethod30 public void afterMethod() {31 Reporter.log("logout",true);32 }33 @BeforeClass34 public void beforeClass() {35 Reporter.log("launch browser",true);36 }37 @AfterClass38 public void afterClass() {39 Reporter.log("close browser",true);40 }41 @BeforeTest42 public void beforeTest() {43 Reporter.log("before tesr",true);44 }45 @AfterTest46 public void afterTest() {47 Reporter.log("after test",true);48 }49 @BeforeSuite50 public void beforeSuite() {51 Reporter.log("before suite",true);52 }53 @AfterSuite54 public void afterSuite() {55 Reporter.log("after suite",true);56 }57}...
Source:AnnotationsDemo.java
1package com.edureka.testng;2import org.testng.Reporter;3import org.testng.annotations.AfterClass;4import org.testng.annotations.AfterMethod;5import org.testng.annotations.AfterSuite;6import org.testng.annotations.AfterTest;7import org.testng.annotations.BeforeClass;8import org.testng.annotations.BeforeMethod;9import org.testng.annotations.BeforeSuite;10import org.testng.annotations.BeforeTest;11import org.testng.annotations.Test;12public class AnnotationsDemo {13 14 @BeforeSuite15 public void beforeSuiteMethod()16 {17 Reporter.log("@BeforeSuite",true);18 }19 20 @BeforeTest21 public void beforeTestMethod()22 {23 Reporter.log("@BeforeTest",true);24 }25 26 @BeforeClass27 public void beforeClass()28 {29 Reporter.log("@BeforeClass",true);30 }31 32 @BeforeMethod33 public void beforeMethod()34 {35 Reporter.log("@BeforeMethod",true);36 }37 38 @Test39 public void test1()40 {41 Reporter.log("Test Block 1",true);42 }43 44 @Test45 public void test2()46 {47 Reporter.log("Test Block 2",true);48 }49 50 51 @AfterMethod52 public void afterMethod()53 {54 Reporter.log("@AfterMethod",true);55 }56 57 @AfterClass58 public void afterClass()59 {60 Reporter.log("@AfterClass",true);61 }62 63 64 @AfterTest65 public void afterTestMethod()66 {67 Reporter.log("@AfterTest",true);68 }69 70 @AfterSuite71 public void afterSuiteMethod()72 {73 Reporter.log("@AfterSuite",true);74 }75 76 77 }...
Source:TestNG12.java
2import org.testng.annotations.Test;3import org.testng.annotations.BeforeMethod;4import org.testng.annotations.AfterMethod;5import org.testng.annotations.BeforeClass;6import org.testng.Reporter;7import org.testng.annotations.AfterClass;8import org.testng.annotations.BeforeTest;9import org.testng.annotations.AfterTest;10import org.testng.annotations.BeforeSuite;11import org.testng.annotations.AfterSuite;12public class TestNG12 {13 @Test14 public void TestScript1() 15 {16 Reporter.log("test script 1",true);17 }18 19 @BeforeMethod20 public void beforeMethod()21 {22 Reporter.log("before method",true); 23 }24 @AfterMethod25 public void afterMethod()26 {27 Reporter.log("after method",true);28 }29 @BeforeClass30 public void beforeClass()31 {32 Reporter.log("before class",true);33 }34 @AfterClass35 public void afterClass()36 {37 Reporter.log("after class",true);38 }39 @BeforeTest40 public void beforeTest()41 {42 Reporter.log("before test",true);43 }44 45 @AfterTest46 public void afterTest()47 {48 Reporter.log("after test",true);49 }50 @BeforeSuite51 public void beforeSuite()52 {53 Reporter.log("before suite",true);54 }55 @AfterSuite56 public void afterSuite()57 {58 Reporter.log("after suite",true);59 }60}...
Source:Test3.java
1package demo;23import org.testng.Reporter;4import org.testng.annotations.AfterClass;5import org.testng.annotations.AfterMethod;6import org.testng.annotations.AfterSuite;7import org.testng.annotations.AfterTest;8import org.testng.annotations.BeforeClass;9import org.testng.annotations.BeforeMethod;10import org.testng.annotations.BeforeSuite;11import org.testng.annotations.BeforeTest;12import org.testng.annotations.Test;1314public class Test3 {15 @BeforeSuite16 public void BS() {17 Reporter.log("Beforesuite",true);18 }19 20 @AfterSuite21 public void AS() {22 Reporter.log("Aftersuite",true);23 }24 25 @BeforeClass26 public void BC() {27 Reporter.log("Beforeclass",true);28 }29 30 @AfterClass31 public void AC() {32 Reporter.log("Afterclass",true);33 34 }35 36 @BeforeTest37 public void BT() {38 Reporter.log("BeforeTest",true);39 }40 41 @AfterTest42 public void AT() {43 Reporter.log("AfterTest",true);44 }45 46 @BeforeMethod47 public void BM() {48 Reporter.log("Beforemethod",true);49 }50 51 @AfterMethod52 public void AM() {53 Reporter.log("Aftermethod",true);54 }55 56 @Test57 public void test() {58 Reporter.log("Testmethod",true);59 }6061}
...
Source:BaseTest.java
1package testNGReporter;23import org.testng.Reporter;4import org.testng.annotations.AfterClass;5import org.testng.annotations.AfterMethod;6import org.testng.annotations.AfterSuite;7import org.testng.annotations.AfterTest;8import org.testng.annotations.BeforeClass;9import org.testng.annotations.BeforeMethod;10import org.testng.annotations.BeforeSuite;11import org.testng.annotations.BeforeTest;1213public class BaseTest {14@BeforeSuite15public void m1()16{17 Reporter.log("@BeforeSuite",true);18}19@BeforeTest20public void m2()21{22 Reporter.log("@BeforeTest",true);23}24@BeforeClass25public void m3()26{27 Reporter.log("@BeforeClass",true);28}29@BeforeMethod30public void m4()31{32 Reporter.log("@BeforeMethod",true);33}34@AfterMethod35public void m5()36{37 Reporter.log("@AfterMehtod",true);38}39@AfterClass40public void m6()41{42 Reporter.log("@AfterClass",true);43}44@AfterTest45public void m7()46{47 Reporter.log("@AfterTest",true);48}49@AfterSuite50public void m8()51{52 Reporter.log("@AfterSuite",true);53}545556}
...
Reporter
Using AI Code Generation
1import org.testng.Reporter;2import org.testng.annotations.Test;3public class TestReporter {4public void testReporter(){5Reporter.log("This is log message");6Reporter.log("This is log message", true);7Reporter.log("This is log message", false);8Reporter.log("This is log message", 1);9Reporter.log("This is log message", 2);10Reporter.log("This is log message", 3);11Reporter.log("This is log message", 4);12Reporter.log("This is log message", 5);13Reporter.log("This is log message", 6);14Reporter.log("This is log message", 7);15Reporter.log("This is log message", 8);16Reporter.log("This is log message", 9);17Reporter.log("This is log message", 10);18Reporter.log("This is log message", 11);19Reporter.log("This is log message", 12);20Reporter.log("This is log message", 13);21Reporter.log("This is log message", 14);22Reporter.log("This is log message", 15);23Reporter.log("This is log message", 16);24Reporter.log("This is log message", 17);25Reporter.log("This is log message", 18);26Reporter.log("This is log message", 19);27Reporter.log("This is log message", 20);28Reporter.log("This is log message", 21);29Reporter.log("This is log message", 22);30Reporter.log("This is log message", 23);31Reporter.log("This is log message", 24);32Reporter.log("This is log message", 25);33Reporter.log("This is log message", 26);34Reporter.log("This is log message", 27);35Reporter.log("This is log message", 28);36Reporter.log("This is log message", 29);37Reporter.log("This is log message", 30);38Reporter.log("This is log message", 31);39Reporter.log("This is log message", 32);40Reporter.log("This is log message", 33);41Reporter.log("This is log message", 34);42Reporter.log("This is log message", 35);43Reporter.log("This is log message", 36);44Reporter.log("This is log message", 37);45Reporter.log("This is log message", 38);46Reporter.log("This is log message", 39);47Reporter.log("This is log message", 40);48Reporter.log("This is log
Reporter
Using AI Code Generation
1import org.testng.Reporter;2import org.testng.Assert;3Reporter.log("This is my first log");4Reporter.log("This is my second log");5Reporter.log("This is my third log");6Assert.assertEquals(12, 13);7Reporter.log("This is my fourth log");8Reporter.log() method is used to print the message in the report. It is also used to print the message in the console. It is also used to print the message in the log file. It is also used to print the message in the report. It is also used to print the message in the console. It is also used to print the message in the log file. It is also used to print the message in the report. It is also used to print the message in the console. It is also used to print the message in the log file. It is also used to print the message in the report. It is also used to print the message in the console. It is also used to print the message in the log file. It is also used to print the message in the report. It is also used to print the message in the console. It is also used to print the message in the log file. It is also used to print the message in the report. It is also used to print the message in the console. It is also used to print the message in the log file. It is also used to print the message in the report. It is also used to print the message in the console. It is also used to print the message in the log file. It is also used to print the message in the report. It is also used to print the message in the console. It is also used to print the message in the log file. It is also used to print the message in the report. It is also used to print the message in the console. It is also used to print the message in the log file. It is also used to print the message in
Reporter
Using AI Code Generation
1public class TestNG {2 public static void main(String[] args) {3 Reporter.log("This is my first log", true);4 Reporter.log("This is my second log", false);5 Reporter.log("This is my third log", true);6 }7}8Reporter.log() method is used to log a message in the test report. The method takes two parameters:9Reporter.log() method is overloaded and can be used to log a message with a status. The method takes three parameters:10Reporter.log() method is overloaded and can be used to log a message with a status and a screenshot. The method takes four parameters:11Reporter.log() method is overloaded and can be used to log a message with a screenshot. The method takes three parameters:12public class TestNG {13 public static void main(String[] args) {14 Reporter.log("This is my first log", true);15 Reporter.log("This is my second log", false);16 Reporter.log("This is my third log", true);17 Reporter.log("This is my fourth log", true);18 Reporter.log("This is my fifth log", true);19 Reporter.log("This is my sixth log", true);20 Reporter.log("This is my seventh log", true);21 Reporter.log("This is my eighth log", true);22 Reporter.log("This is my ninth log", true);23 Reporter.log("This is my tenth log", true);24 Reporter.log("This is my eleventh log", true);25 Reporter.log("This is my twelfth log", true);26 Reporter.log("This is my thirteenth log", true);27 Reporter.log("This is my fourteenth log", true);28 Reporter.log("This is my fifteenth log", true);29 Reporter.log("This is my sixteenth log", true);
Reporter
Using AI Code Generation
1import org.testng.Reporter;2import org.testng.annotations.Test;3public class TestNGClass {4public void testMethod1() {5Reporter.log("This is a log from testMethod1");6}7public void testMethod2() {8Reporter.log("This is a log from testMethod2");9}10}11import org.testng.Reporter;12import org.testng.annotations.Test;13public class TestNGClass {14public void testMethod1() {15Reporter.log("This is a log from testMethod1");16}17public void testMethod2() {18Reporter.log("This is a log from testMethod2");19}20}
Reporter
Using AI Code Generation
1import org.testng.Reporter;2public class TestNGReporterDemo {3 public static void main(String[] args) {4 Reporter.log("This is a testng reporter log message", true);5 }6}7Reporter.log() method accepts two parameters:8Example 2: How to use Reporter.log() method with a class?9package com.javatpoint;10import org.testng.Reporter;11public class TestNGReporterDemo {12 public static void main(String[] args) {13 Reporter.log("This is a testng reporter log message", true);14 Reporter.log("This is a testng reporter log message", true);15 Reporter.log("This is a testng reporter log message", true);16 Reporter.log("This is a testng reporter log message", true);17 Reporter.log("This is a testng reporter log message", true);18 }19}20Example 3: How to use Reporter.log() method with a method?21package com.javatpoint;22import org.testng.Reporter;23public class TestNGReporterDemo {24 public static void main(String[] args) {25 test();26 }27 public static void test() {28 Reporter.log("This is
1long difference = (sDt4.getTime() - sDt3.getTime()) / 1000;2System.out.println(difference);3
1DateTimeFormatterBuilder dtfb = new DateTimeFormatterBuilder();2dtfb.append(DateTimeFormatter.ISO_LOCAL_DATE);3dtfb.appendLiteral(' ');4dtfb.append(DateTimeFormatter.ISO_LOCAL_TIME);5DateTimeFormatter dtf = dtfb.toFormatter();6ZoneId shanghai = ZoneId.of("Asia/Shanghai");78String str3 = "1927-12-31 23:54:07"; 9String str4 = "1927-12-31 23:54:08"; 1011ZonedDateTime zdt3 = LocalDateTime.parse(str3, dtf).atZone(shanghai);12ZonedDateTime zdt4 = LocalDateTime.parse(str4, dtf).atZone(shanghai);1314Duration durationAtEarlierOffset = Duration.between(zdt3.withEarlierOffsetAtOverlap(), zdt4.withEarlierOffsetAtOverlap());1516Duration durationAtLaterOffset = Duration.between(zdt3.withLaterOffsetAtOverlap(), zdt4.withLaterOffsetAtOverlap());17
TestNG is a Java-based open-source framework for test automation that includes various test types, such as unit testing, functional testing, E2E testing, etc. TestNG is in many ways similar to JUnit and NUnit. But in contrast to its competitors, its extensive features make it a lot more reliable framework. One of the major reasons for its popularity is its ability to structure tests and improve the scripts' readability and maintainability. Another reason can be the important characteristics like the convenience of using multiple annotations, reliance, and priority that make this framework popular among developers and testers for test design. You can refer to the TestNG tutorial to learn why you should choose the TestNG framework.
You can push your abilities to do automated testing using TestNG and advance your career by earning a TestNG certification. Check out our TestNG certification.
Watch this complete tutorial to learn how you can leverage the capabilities of the TestNG framework for Selenium automation testing.
Get 100 minutes of automation test minutes FREE!!