How to use clear method of org.testng.Reporter class

Best Testng code snippet using org.testng.Reporter.clear

Source:MerchantRegistration.java Github

copy

Full Screen

...197 String notes = null;198 try {199 if(driver.findElement(By.xpath("//*[@id=\"legend\"]/legend/b")).getText().contains("Merchant Registration Form"))200 {201 driver.findElement(By.id("userName")).clear();202 driver.findElement(By.id("userName")).sendKeys(oData.invalidNumericUsername());203 String userNameText = driver.findElement(By.id("userName")).getAttribute("value");204 driver.findElement(By.id("firstName")).sendKeys(Keys.SHIFT);205 if (userNameText.length() > 5 && userNameText.contains(oData.invalidNumericUsername())) 206 {207 if (driver.findElement(By.className("tooltip-inner")).getText().contains(oData.invalidNumericUsernameMessage())) 208 {209 Reporter.log("Test passed for invalid numeric username : " + oData.invalidNumericUsernameMessage());210 System.out.println("Test passed for invalid numeric username : " + oData.invalidNumericUsernameMessage());211 212 notes = "Test passed for invalid numeric username";213 214 Thread.sleep(3000);215 } 216 else 217 {218 Reporter.log("Test failed for invalid numeric username");219 220 221 org.testng.Assert.fail();org.testng.Assert.fail();222 }223 } 224 else 225 {226 Reporter.log("Test failed for invalid numeric username");227 228 229 org.testng.Assert.fail();org.testng.Assert.fail();230 } 231 232 }233 else234 {235 Reporter.log("Test failed for invalid numeric username");236 237 238 org.testng.Assert.fail();org.testng.Assert.fail();239 }240 241 } catch (Exception e) {242 Reporter.log("Test failed for invalid numeric username");243 244 245 org.testng.Assert.fail();org.testng.Assert.fail();246 }247 248}249 250 251 @Test(priority = 5)252public void inValidNumericShopName() {253 String result = "";254 String exception = null;255 String notes = null;256 try {257 if(driver.findElement(By.xpath("//*[@id=\"legend\"]/legend/b")).getText().contains("Merchant Registration Form"))258 {259 driver.findElement(By.id("userName")).clear();260 driver.findElement(By.id("firstName")).clear();261 driver.findElement(By.id("lastName")).clear();262 driver.findElement(By.id("shopName")).clear();263 264 driver.findElement(By.id("userName")).sendKeys(oData.validUsername());265 Thread.sleep(2000);266 driver.findElement(By.id("firstName")).sendKeys(oData.validFirstName());267 Thread.sleep(2000);268 driver.findElement(By.id("lastName")).sendKeys(oData.validLastName());269 Thread.sleep(2000);270 driver.findElement(By.id("shopName")).sendKeys(oData.invalidNumericUsername());271 Thread.sleep(2000);272 driver.findElement(By.id("password")).sendKeys(Keys.SHIFT);273 if (driver.findElement(By.className("tooltip-inner")).getText().contains(oData.invalidNumericUsernameMessage())) 274 {275 Reporter.log("Test passed for invalid numeric shop name : " + oData.invalidNumericUsernameMessage());276 System.out.println("Test passed for invalid numeric shop name : " + oData.invalidNumericUsernameMessage());277 278 notes = "Test passed for invalid email";279 280 Thread.sleep(3000);281 } 282 else 283 {284 Reporter.log("Test failed for invalid numeric shop name");285 286 287 org.testng.Assert.fail();org.testng.Assert.fail();288 }289 }290 else291 {292 Reporter.log("Test failed for invalid numeric shop name");293 294 295 org.testng.Assert.fail();org.testng.Assert.fail();296 }297 298 } catch (Exception e) {299 Reporter.log("Test failed for invalid numeric shop name");300 301 302 org.testng.Assert.fail();org.testng.Assert.fail();303 }304 305}306 307 308 @Test(priority = 6)309public void inValidPasswordlength() {310 String result = "";311 String exception = null;312 String notes = null;313 try {314 if(driver.findElement(By.xpath("//*[@id=\"legend\"]/legend/b")).getText().contains("Merchant Registration Form"))315 {316 driver.findElement(By.id("userName")).clear();317 driver.findElement(By.id("firstName")).clear();318 driver.findElement(By.id("lastName")).clear();319 driver.findElement(By.id("shopName")).clear();320 driver.findElement(By.id("password")).clear();321 driver.findElement(By.id("userName")).sendKeys(oData.validUsername());322 Thread.sleep(2000);323 driver.findElement(By.id("firstName")).sendKeys(oData.validFirstName());324 Thread.sleep(2000);325 driver.findElement(By.id("lastName")).sendKeys(oData.validLastName());326 Thread.sleep(2000);327 driver.findElement(By.id("shopName")).sendKeys(oData.validShopName());328 Thread.sleep(2000);329 driver.findElement(By.id("password")).sendKeys(oData.invalidPasswordLength());330 Thread.sleep(2000);331 String passwordText = driver.findElement(By.id("password")).getAttribute("value");332 driver.findElement(By.id("rePassword")).sendKeys(Keys.SHIFT);333 if (passwordText.length() < 6) 334 {335 if (driver.findElement(By.className("tooltip-inner")).getText().contains(oData.invalidPasswordLengthMessage())) 336 {337 Reporter.log("Test passed for invalid Password length : " + oData.invalidPasswordLengthMessage());338 System.out.println("Test passed for invalid Password length : " + oData.invalidPasswordLengthMessage());339 340 notes = "Test passed for invalid email";341 342 Thread.sleep(3000);343 } 344 else 345 {346 Reporter.log("Test failed for invalid Password length");347 348 349 org.testng.Assert.fail();org.testng.Assert.fail();350 }351 } 352 else 353 {354 Reporter.log("Test failed for invalid Password length");355 356 357 org.testng.Assert.fail();org.testng.Assert.fail();358 } 359 360 }361 else362 {363 Reporter.log("Test failed for invalid Password length");364 365 366 org.testng.Assert.fail();org.testng.Assert.fail();367 }368 369 } catch (Exception e) {370 Reporter.log("Test failed for invalid Password length");371 372 373 org.testng.Assert.fail();org.testng.Assert.fail();374 }375 }376 377 378 @Test(priority = 7)379 public void inValidPasswordCombination() {380 String result = "";381 String exception = null;382 String notes = null;383 try {384 if(driver.findElement(By.xpath("//*[@id=\"legend\"]/legend/b")).getText().contains("Merchant Registration Form"))385 {386 driver.findElement(By.id("userName")).clear();387 driver.findElement(By.id("firstName")).clear();388 driver.findElement(By.id("lastName")).clear();389 driver.findElement(By.id("shopName")).clear();390 driver.findElement(By.id("password")).clear();391 driver.findElement(By.id("userName")).sendKeys(oData.validUsername());392 Thread.sleep(2000);393 driver.findElement(By.id("firstName")).sendKeys(oData.validFirstName());394 Thread.sleep(2000);395 driver.findElement(By.id("lastName")).sendKeys(oData.validLastName());396 Thread.sleep(2000);397 driver.findElement(By.id("shopName")).sendKeys(oData.validShopName());398 Thread.sleep(2000);399 driver.findElement(By.id("password")).sendKeys(oData.invalidPasswordCombination());400 Thread.sleep(2000);401 String passwordText = driver.findElement(By.id("password")).getAttribute("value");402 driver.findElement(By.id("rePassword")).sendKeys(Keys.SHIFT);403 if (passwordText.length() > 6 && passwordText.contains(oData.invalidPasswordCombination())) 404 {405 if (driver.findElement(By.className("tooltip-inner")).getText().contains(oData.invalidPasswordCombinationMessage())) 406 {407 Reporter.log("Test passed for invalid Password Combination : " + oData.invalidPasswordCombinationMessage());408 System.out.println("Test passed for invalid Password Combination : " + oData.invalidPasswordCombinationMessage());409 410 notes = "Test passed for invalid Password Combination";411 412 Thread.sleep(3000);413 } 414 else 415 {416 Reporter.log("Test failed for invalid Password Combination");417 418 419 org.testng.Assert.fail();420 }421 } 422 else 423 {424 Reporter.log("Test failed for invalid Password Combination");425 426 427 org.testng.Assert.fail();428 } 429 430 }431 else432 {433 Reporter.log("Test failed for invalid Password Combination");434 435 436 org.testng.Assert.fail();437 }438 439 } catch (Exception e) {440 Reporter.log("Test failed for invalid Password Combination");441 442 443 org.testng.Assert.fail();444 }445 446}447 448 @Test(priority = 8)449 public void retypePasswordNoMatch() 450 {451 String result = "";452 String exception = null;453 String notes = null;454 try {455 if(driver.findElement(By.xpath("//*[@id=\"legend\"]/legend/b")).getText().contains("Merchant Registration Form"))456 {457 driver.findElement(By.id("userName")).clear();458 driver.findElement(By.id("firstName")).clear();459 driver.findElement(By.id("lastName")).clear();460 driver.findElement(By.id("shopName")).clear();461 driver.findElement(By.id("password")).clear();462 driver.findElement(By.id("rePassword")).clear();463 driver.findElement(By.id("userName")).sendKeys(oData.validUsername());464 Thread.sleep(2000);465 driver.findElement(By.id("firstName")).sendKeys(oData.validFirstName());466 Thread.sleep(2000);467 driver.findElement(By.id("lastName")).sendKeys(oData.validLastName());468 Thread.sleep(2000);469 driver.findElement(By.id("shopName")).sendKeys(oData.validShopName());470 Thread.sleep(2000);471 driver.findElement(By.id("password")).sendKeys(oData.validPassword());472 Thread.sleep(2000);473 driver.findElement(By.id("rePassword")).sendKeys(oData.retypePasswordNoMatch());474 Thread.sleep(2000);475 String passwordText = driver.findElement(By.id("rePassword")).getAttribute("value");476 driver.findElement(By.id("email")).sendKeys(Keys.SHIFT);477 if (passwordText.length() > 6 && passwordText.contains(oData.retypePasswordNoMatch())) 478 {479 if (driver.findElement(By.className("tooltip-inner")).getText().contains(oData.retypePasswordNoMatchMessage())) 480 {481 Reporter.log("Test passed for Retype password didn't match : " + oData.retypePasswordNoMatchMessage());482 System.out.println("Test passed for Retype password didn't match : " + oData.retypePasswordNoMatchMessage());483 484 notes = "Test passed for Retype password didn't match";485 486 Thread.sleep(3000);487 } 488 else 489 {490 Reporter.log("Test passed for Retype password didn't match");491 492 493 org.testng.Assert.fail();494 }495 } 496 else 497 {498 Reporter.log("Test passed for Retype password didn't match");499 500 501 org.testng.Assert.fail();502 } 503 504 }505 else506 {507 Reporter.log("Test passed for Retype password didn't match");508 509 510 org.testng.Assert.fail();511 }512 513 } catch (Exception e) {514 Reporter.log("Test passed for Retype password didn't match");515 516 517 org.testng.Assert.fail();518 }519 520 }521 522 @Test(priority = 9)523 public void invalidEmail() {524 String result = "";525 String exception = null;526 String notes = null;527 try {528 529 if(driver.findElement(By.xpath("//*[@id=\"legend\"]/legend/b")).getText().contains("Merchant Registration Form"))530 {531 driver.findElement(By.id("userName")).clear();532 driver.findElement(By.id("firstName")).clear();533 driver.findElement(By.id("lastName")).clear();534 driver.findElement(By.id("shopName")).clear();535 driver.findElement(By.id("password")).clear();536 driver.findElement(By.id("rePassword")).clear();537 driver.findElement(By.id("email")).clear();538 driver.findElement(By.id("userName")).sendKeys(oData.validUsername());539 Thread.sleep(2000);540 driver.findElement(By.id("firstName")).sendKeys(oData.validFirstName());541 Thread.sleep(2000);542 driver.findElement(By.id("lastName")).sendKeys(oData.validLastName());543 Thread.sleep(2000);544 driver.findElement(By.id("shopName")).sendKeys(oData.validShopName());545 Thread.sleep(2000);546 driver.findElement(By.id("password")).sendKeys(oData.validPassword());547 Thread.sleep(2000);548 driver.findElement(By.id("rePassword")).sendKeys(oData.validReTypePassword());549 Thread.sleep(2000);550 driver.findElement(By.id("email")).sendKeys(oData.invalidEmail());551 Thread.sleep(2000);552 driver.findElement(By.id("email")).sendKeys(Keys.TAB);553 Thread.sleep(2000);554 555 if (driver.findElement(By.className("tooltip-inner")).getText().contains(oData.invalidEmailMsg())) 556 {557 Reporter.log("Test passed for Invalid Email : " + oData.invalidEmailMsg());558 System.out.println("Test passed for Invalid Email : " + oData.invalidEmailMsg());559 560 notes = "Test passed for invalid data";561 562 Thread.sleep(3000);563 } 564 else 565 {566 Reporter.log("Test failed for Invalid Email");567 568 569 org.testng.Assert.fail();570 }571 }572 else573 {574 Reporter.log("Test failed for Invalid Email");575 576 577 org.testng.Assert.fail();578 }579 580 } catch (Exception e) {581 Reporter.log("Test failed for Invalid Email");582 583 584 org.testng.Assert.fail();585 }586 }587 588 @Test(priority = 10)589 public void invalidMobile() {590 String result = "";591 String exception = null;592 String notes = null;593 try {594 if(driver.findElement(By.xpath("//*[@id=\"legend\"]/legend/b")).getText().contains("Merchant Registration Form"))595 {596 driver.findElement(By.id("userName")).clear();597 driver.findElement(By.id("firstName")).clear();598 driver.findElement(By.id("lastName")).clear();599 driver.findElement(By.id("shopName")).clear();600 driver.findElement(By.id("password")).clear();601 driver.findElement(By.id("rePassword")).clear();602 driver.findElement(By.id("email")).clear();603 driver.findElement(By.id("phone")).clear();604 driver.findElement(By.id("userName")).sendKeys(oData.validUsername());605 Thread.sleep(2000);606 driver.findElement(By.id("firstName")).sendKeys(oData.validFirstName());607 Thread.sleep(2000);608 driver.findElement(By.id("lastName")).sendKeys(oData.validLastName());609 Thread.sleep(2000);610 driver.findElement(By.id("shopName")).sendKeys(oData.validShopName());611 Thread.sleep(2000);612 driver.findElement(By.id("password")).sendKeys(oData.validPassword());613 Thread.sleep(2000);614 driver.findElement(By.id("rePassword")).sendKeys(oData.validReTypePassword());615 Thread.sleep(2000);616 driver.findElement(By.id("email")).sendKeys(oData.validEmail());617 Thread.sleep(2000);618 WebElement dd = driver.findElement(By.id("country-dropdown"));619 Select ele = new Select(dd);620 ele.selectByVisibleText("India ( +91 )");621 driver.findElement(By.id("phone")).sendKeys(oData.invalidPhoneNoLength());622 Thread.sleep(2000);623 driver.findElement(By.id("phone")).sendKeys(Keys.TAB);624 Thread.sleep(2000);625 if (driver.findElement(By.className("tooltip-inner")).getText().contains(oData.invalidPhoneNoLengthMessage())) 626 {627 Reporter.log("Test passed for Invalid Phone No. : " + oData.invalidPhoneNoLengthMessage());628 System.out.println("Test passed for Invalid Phone No. : " + oData.invalidPhoneNoLengthMessage());629 630 notes = "Test passed for Invalid Phone No.";631 632 Thread.sleep(3000);633 } 634 else 635 {636 Reporter.log("Test passed for Invalid Phone No. : " + oData.invalidPhoneNoLengthMessage());637 System.out.println("Test passed for Invalid Phone No. : " + oData.invalidPhoneNoLengthMessage());638 639 notes = "Test passed for Invalid Phone No.";640 641 Thread.sleep(3000);642 }643 }644 else645 {646 Reporter.log("Test passed for Invalid Phone No. : " + oData.invalidPhoneNoLengthMessage());647 System.out.println("Test passed for Invalid Phone No. : " + oData.invalidPhoneNoLengthMessage());648 649 notes = "Test passed for Invalid Phone No.";650 651 Thread.sleep(3000);652 }653 654 } catch (Exception e) {655 Reporter.log("Test passed for Invalid Phone No. : " + oData.invalidPhoneNoLengthMessage());656 System.out.println("Test passed for Invalid Phone No. : " + oData.invalidPhoneNoLengthMessage());657 658 notes = "Test passed for Invalid Phone No.";659 660 }661 }662 663 664 @Test(priority = 11)665 public void invalidPincode() {666 String result = "";667 String exception = null;668 String notes = null;669 try {670 if(driver.findElement(By.xpath("//*[@id=\"legend\"]/legend/b")).getText().contains("Merchant Registration Form"))671 {672 driver.findElement(By.id("userName")).clear();673 driver.findElement(By.id("firstName")).clear();674 driver.findElement(By.id("lastName")).clear();675 driver.findElement(By.id("shopName")).clear();676 driver.findElement(By.id("password")).clear();677 driver.findElement(By.id("rePassword")).clear();678 driver.findElement(By.id("email")).clear();679 driver.findElement(By.id("phone")).clear();680 driver.findElement(By.id("pincode")).clear();681 driver.findElement(By.id("userName")).sendKeys(oData.validUsername());682 Thread.sleep(2000);683 driver.findElement(By.id("firstName")).sendKeys(oData.validFirstName());684 Thread.sleep(2000);685 driver.findElement(By.id("lastName")).sendKeys(oData.validLastName());686 Thread.sleep(2000);687 driver.findElement(By.id("shopName")).sendKeys(oData.validShopName());688 Thread.sleep(2000);689 driver.findElement(By.id("password")).sendKeys(oData.validPassword());690 Thread.sleep(2000);691 driver.findElement(By.id("rePassword")).sendKeys(oData.validReTypePassword());692 Thread.sleep(2000);693 driver.findElement(By.id("email")).sendKeys(oData.validEmail());694 Thread.sleep(2000);695 WebElement dd = driver.findElement(By.id("country-dropdown"));696 Select ele = new Select(dd);697 ele.selectByVisibleText("India ( +91 )");698 driver.findElement(By.id("phone")).sendKeys(oData.validMobileNo());699 Thread.sleep(2000);700 WebElement ddlCollection = driver.findElement(By.id("collection-dropdown"));701 Select ele1 = new Select(ddlCollection);702 ele1.selectByVisibleText("Handicrafts & Fashion");703 704 Thread.sleep(2000);705 WebElement ddlSegment = driver.findElement(By.id("segment-dropdown"));706 Select ele2 = new Select(ddlSegment);707 ele2.selectByVisibleText("Accessories");708 Thread.sleep(2000);709 driver.findElement(By.id("pincode")).sendKeys(oData.invalidPincode());710 Thread.sleep(2000);711 driver.findElement(By.id("pincode")).sendKeys(Keys.TAB);712 Thread.sleep(2000);713 if (driver.findElement(By.className("tooltip-inner")).getText().contains(oData.invalidPincodeMessage())) 714 {715 Reporter.log("Test passed for Invalid Pincode : " + (oData.invalidPincodeMessage()));716 System.out.println("Test passed for Invalid Pincode : " + (oData.invalidPincodeMessage()));717 718 notes = "Test passed for Invalid Pincode";719 720 Thread.sleep(3000);721 } 722 else 723 {724 Reporter.log("Test failed for Invalid Pincode ");725 726 727 org.testng.Assert.fail();728 }729 }730 else731 {732 Reporter.log("Test failed for Invalid Pincode ");733 734 735 org.testng.Assert.fail();736 }737 738 } catch (Exception e) {739 Reporter.log("Test failed for Invalid Pincode ");740 741 742 org.testng.Assert.fail();743 System.out.println(e);744 }745 }746 747 @Test(priority = 12)748 public void validData() {749 String result = "";750 String exception = null;751 String notes = null;752 try {753 if(driver.findElement(By.xpath("//*[@id=\"legend\"]/legend/b")).getText().contains("Merchant Registration Form"))754 {755 driver.findElement(By.id("userName")).clear();756 driver.findElement(By.id("firstName")).clear();757 driver.findElement(By.id("lastName")).clear();758 driver.findElement(By.id("shopName")).clear();759 driver.findElement(By.id("password")).clear();760 driver.findElement(By.id("rePassword")).clear();761 driver.findElement(By.id("email")).clear();762 driver.findElement(By.id("phone")).clear();763 driver.findElement(By.id("pincode")).clear();764 driver.findElement(By.id("userName")).sendKeys(oData.validUsername());765 Thread.sleep(3000);766 driver.findElement(By.id("firstName")).sendKeys(oData.validFirstName());767 Thread.sleep(3000);768 driver.findElement(By.id("lastName")).sendKeys(oData.validLastName());769 Thread.sleep(3000);770 driver.findElement(By.id("shopName")).sendKeys(oData.validShopName());771 Thread.sleep(3000);772 driver.findElement(By.id("password")).sendKeys(oData.validPassword());773 Thread.sleep(3000);774 driver.findElement(By.id("rePassword")).sendKeys(oData.validReTypePassword());775 Thread.sleep(3000);776 driver.findElement(By.id("email")).sendKeys(oData.validEmail());777 Thread.sleep(3000);...

Full Screen

Full Screen

Source:Change_Profile_Info.java Github

copy

Full Screen

...108 String result ="";109 String exception = null;110 try {111 if(driver.findElement(By.xpath("/html/body/div[3]/div[3]/div/div[2]/div[2]/div[1]/ul/li[1]/a")).getText().equals("Information")) {112 driver.findElement(By.id("first_name")).clear();113 Thread.sleep(1000);114 driver.findElement(By.id("last_name")).clear();115 Thread.sleep(1000);116 driver.findElement(By.id("first_name")).sendKeys(data.empty());117 Thread.sleep(3000);118 driver.findElement(By.id("last_name")).sendKeys(data.empty());119 Thread.sleep(3000);120 121 122 driver.findElement(By.id("submitBasicInfo")).sendKeys(Keys.ENTER);123 Thread.sleep(2000);124 //Tooltip condition here125 int size = driver.findElements(By.className("tooltipster-base")).size();126 Reporter.log("Tooltip size " + size);127 for(int i=0; i<size; i++) {128 if(driver.findElements(By.className("tooltipster-base")).get(i).getText().equals(data.field_required())) {129 Reporter.log("Test Passed: field required message found at tooltip " + i);130 Thread.sleep(3000);131 132 133 }134 else {135 Reporter.log("Test failed: Field required message not found at tooltip " + i);136 Thread.sleep(3000);137 138 139 org.testng.Assert.fail();140 break;141 }142 } 143 144 }145 else {146 Reporter.log("Test failed: Information tab not found");147 148 149 org.testng.Assert.fail();150 }151 152 153 } catch (Exception e) {154 exception=e.getMessage();155 156 157 org.testng.Assert.fail();158 } 159 }160 161 @Test(priority = 3, retryAnalyzer = Retry_Analyzer.class)162 public void empty_fname() {163 String result = "";164 String exception = null;165 try {166 if(driver.findElement(By.xpath("/html/body/div[3]/div[3]/div/div[2]/div[2]/div[1]/ul/li[1]/a")).getText().equals("Information")) {167 driver.findElement(By.id("first_name")).clear();168 Thread.sleep(1000);169 driver.findElement(By.id("last_name")).clear();170 Thread.sleep(1000);171 driver.findElement(By.id("first_name")).sendKeys(data.empty());172 Thread.sleep(3000);173 driver.findElement(By.id("last_name")).sendKeys(data.lname());174 Thread.sleep(3000);175 driver.findElement(By.id("submitBasicInfo")).sendKeys(Keys.ENTER);176 Thread.sleep(2000);177 //Tooltip condition here178 int size = driver.findElements(By.className("tooltipster-base")).size();179 Reporter.log("Tooltip size " + size);180 for(int i=0; i<size; i++) {181 if(driver.findElements(By.className("tooltipster-base")).get(i).getText().equals(data.field_required())) {182 Reporter.log("Test Passed: field required message found at tooltip " + i);183 Thread.sleep(3000);184 185 186 }187 else {188 Reporter.log("Test failed: Field required message not found at tooltip " + i);189 Thread.sleep(3000);190 191 192 org.testng.Assert.fail();193 break;194 }195 } 196 197 }198 else {199 Reporter.log("Test failed: Information tab not found");200 201 202 org.testng.Assert.fail();203 }204 205 } catch (Exception e) {206 exception=e.getMessage();207 208 209 org.testng.Assert.fail();210 }211 }212 213 @Test(priority = 4, retryAnalyzer = Retry_Analyzer.class)214 public void lname_empty() {215 String result = "";216 String exception = null;217 try {218 if(driver.findElement(By.xpath("/html/body/div[3]/div[3]/div/div[2]/div[2]/div[1]/ul/li[1]/a")).getText().equals("Information")) {219 driver.findElement(By.id("first_name")).clear();220 Thread.sleep(1000);221 driver.findElement(By.id("last_name")).clear();222 Thread.sleep(1000);223 driver.findElement(By.id("first_name")).sendKeys(data.fname());224 Thread.sleep(3000);225 driver.findElement(By.id("last_name")).sendKeys(data.empty());226 Thread.sleep(3000);227 driver.findElement(By.id("submitBasicInfo")).sendKeys(Keys.ENTER);228 Thread.sleep(2000);229 //Tooltip condition here230 int size = driver.findElements(By.className("tooltipster-base")).size();231 Reporter.log("Tooltip size " + size);232 for(int i=0; i<size; i++) {233 if(driver.findElements(By.className("tooltipster-base")).get(i).getText().equals(data.field_required())) {234 Reporter.log("Test Passed: field required message found at tooltip " + i);235 236 237 Thread.sleep(3000);238 }239 else {240 Reporter.log("Test failed: Field required message not found at tooltip " + i);241 Thread.sleep(3000);242 243 244 org.testng.Assert.fail();245 break;246 }247 } 248 249 }250 else {251 Reporter.log("Test failed: Information tab not found");252 253 254 org.testng.Assert.fail();255 }256 257 } catch (Exception e) {258 exception=e.getMessage();259 260 261 org.testng.Assert.fail();262 }263 }264 265 @Test(priority = 5, retryAnalyzer = Retry_Analyzer.class)266 public void all_filled_details() {267 String result = "";268 String exception = null;269 try {270 if(driver.findElement(By.xpath("/html/body/div[3]/div[3]/div/div[2]/div[2]/div[1]/ul/li[1]/a")).getText().equals("Information")) {271 driver.findElement(By.id("first_name")).clear();272 Thread.sleep(1000);273 driver.findElement(By.id("last_name")).clear();274 Thread.sleep(1000);275 driver.findElement(By.id("first_name")).sendKeys(data.fname());276 Thread.sleep(3000);277 driver.findElement(By.id("last_name")).sendKeys(data.lname());278 Thread.sleep(3000); 279 driver.findElement(By.id("submitBasicInfo")).sendKeys(Keys.ENTER);280 Thread.sleep(2000);281 if(driver.getPageSource().contains(data.profile_update_message())) {282 Reporter.log("Test passed: Profile Updated.");283 Thread.sleep(3000);284 285 286 }287 else {...

Full Screen

Full Screen

Source:ExtentReportsExample2.java Github

copy

Full Screen

...81 public void verifyLogin() throws Exception {82 logger = extent.createTest("To verify Login feature");83 84 85 driver.findElement(By.name("Email")).clear();86 driver.findElement(By.name("Email")).sendKeys("admin@yourstore.com");87 driver.findElement(By.name("Password")).clear();88 driver.findElement(By.name("Password")).sendKeys("admin");89 driver.findElement(By.xpath("//button[@type='submit']")).click();90 91 Thread.sleep(4000);92 93 }94 95 @Test(priority=2)96 public void verifyLogout() {97 logger = extent.createTest("To verify Logout feature");98 driver.findElement(By.xpath("")).click();99 100 //Assert.assertTrue(false); //failed test case101 ...

Full Screen

Full Screen

Source:Base.java Github

copy

Full Screen

...104 e.printStackTrace();105 }106 }107 108 ss_paths.clear();109 }110 111 else if (result.getStatus() == ITestResult.SKIP){112 childTest.skip(result.getThrowable());113 114 Iterator<String> itr = ss_paths.iterator();115 while(itr.hasNext()){116 try {117 childTest.addScreenCaptureFromPath(itr.next());118 } catch (IOException e) {119 e.printStackTrace();120 }121 }122 123 ss_paths.clear();124 }125 else{126 childTest.pass("Test passed");127 Iterator<String> itr = ss_paths.iterator();128 while(itr.hasNext()){129 try {130 childTest.addScreenCaptureFromPath(itr.next());131 } catch (IOException e) {132 e.printStackTrace();133 }134 }135 ss_paths.clear();136 }137 }138 139 /* @AfterClass140 public void afterClass() {141 142 }143 144 @AfterTest145 public void afterTest() {146 147 }*/148 149 @AfterSuite...

Full Screen

Full Screen

Source:TestNGActiTimeHeader.java Github

copy

Full Screen

...159 actiTimeHeader.clickOnLogout();160 }161 162 @AfterClass163 public void clearObjects(){164 System.out.println("ClearObjects");165 166 actiTimeHeader = null;167 loginPage = null;168 169 }170 171 @AfterTest172 public void afterClass() {173 System.out.println("ClosedBrowser");174 driver.quit();175 driver = null;176 177 System.gc(); ...

Full Screen

Full Screen

Source:ChatTest.java Github

copy

Full Screen

...87 Duration timeout = Duration.ofSeconds(10);88 WebDriverWait wait = new WebDriverWait(driver, timeout);89 90 wait.until(ExpectedConditions.visibilityOf(nameField));91 nameField.clear();92 nameField.sendKeys(name);93 94 wait.until(ExpectedConditions.visibilityOf(emailField));95 Reporter.log("entering email "+email, true);96 emailField.clear();97 emailField.sendKeys(email); 98 wait.until(ExpectedConditions.visibilityOf(messageField));99 messageField.clear();100 messageField.sendKeys(message);101 102 Reporter.log("submitting...", true);103 wait.until(ExpectedConditions.visibilityOf(submitButton));104 submitButton.click();105 106 WebElement sendAgainButton = driver.findElement(By.xpath("//button[text()=' Send Again ']"));107// wait.until(ExpectedConditions.visibilityOf(sendAgainButton));108 Thread.sleep(500);109 if(sendAgainButton.isDisplayed()==true)110 {111 Reporter.log("message sent", true);112 }113 else...

Full Screen

Full Screen

Source:ParallelTest.java Github

copy

Full Screen

...74 try {75 test = extent.createTest("Test Case 2", "PASSED test case");76 77 test.log(Status.INFO, "test rohan");78 driver.findElement(By.id("txtUserID")).clear();79 String makerusername=prop.getProperty("makerusername");80 81 String makerpassword=prop.getProperty("makerpassword");82 83 84 driver.findElement(By.id("txtUserID")).sendKeys(makerusername);85 test.log(Status.INFO, "makerusername is "+makerusername);86 driver.findElement(By.id("txtPassword")).clear();87 driver.findElement(By.id("txtPassword")).sendKeys(makerpassword);88 test.log(Status.INFO, "makerpassword is "+makerpassword);89 driver.findElement(By.id("btnLogin")).click();90 driver.findElement(By.linkText("Merchant Onboarding")).click();91 test.log(Status.INFO, "Merchant Onboarding link clicked");92 driver.findElement(By.linkText("Add Merchant Profile VP")).click();93 test.log(Status.INFO, "Add Merchant Profile VP link clicked");94 }catch(Exception e) {95 System.out.println("TestCase failed");96 screenshot(driver,"test2dummy");97 test.log(Status.FAIL, "test2 failed.");98 }99 100 ...

Full Screen

Full Screen

Source:SavepageTest.java Github

copy

Full Screen

...35 36 37 FirstPage lp = new FirstPage( driver);38 lp.skipm().click();39 Reporter.log("Step 1 clear/n");40 SecondPage sp = new SecondPage(driver);41 sp.tappinghotshots().click();42 Reporter.log("Step 2 clear/n");43 Thread.sleep(4000);44 ThirdPage tp = new ThirdPage(driver);45 WebDriverWait wait = new WebDriverWait(driver, 20);46 wait.until(ExpectedConditions.visibilityOf(tp.skipm()));47 tp.skipm().click();48 Reporter.log("Step 3 clear/n");49 }50 51 @AfterTest52 public void teardown()53 {54 driver.closeApp();55;56 }57}...

Full Screen

Full Screen

clear

Using AI Code Generation

copy

Full Screen

1import org.testng.Reporter;2public class TestNGReporter {3 public static void main(String[] args) {4 Reporter.log("This is a log message");5 Reporter.log("This is another log message");6 Reporter.clear();7 Reporter.log("This is a log message");8 Reporter.log("This is another log message");9 }10}11Reporter.log(String message, boolean setAppend) method12public static void log(String message, boolean setAppend)13import org.testng.Reporter;14public class TestNGReporter {15 public static void main(String[] args) {16 Reporter.log("This is a log message", true);17 Reporter.log("This is another log message", true);18 Reporter.log("This is a log message", false);19 Reporter.log("This is another log message", false);20 }21}22Reporter.getCurrentTestResult() method23public static ITestResult getCurrentTestResult()24import org.testng.Reporter;25import org.testng.ITestResult;26public class TestNGReporter {27 public static void main(String[] args) {28 Reporter.log("This is a log message", true);29 Reporter.log("This is another log message", true);

Full Screen

Full Screen

clear

Using AI Code Generation

copy

Full Screen

1Reporter.clear();2Reporter.log("This is a log");3Reporter.log("This is another log");4Reporter.clear();5Reporter.log("This is a log");6Reporter.log("This is another log");7Reporter.clear();8Reporter.log("This is a log");9Reporter.log("This is another log");10Reporter.clear();11Reporter.log("This is a log");12Reporter.log("This is another log");13Reporter.clear();14Reporter.log("This is a log");15Reporter.log("This is another log");16Reporter.clear();17Reporter.log("This is a log");18Reporter.log("This is another log");19Reporter.clear();20Reporter.log("This is a log");21Reporter.log("This is another log");22Reporter.clear();23Reporter.log("This is a log");24Reporter.log("This is another log");25Reporter.clear();26Reporter.log("This is a log");27Reporter.log("This is another log");28Reporter.clear();29Reporter.log("This is a log");30Reporter.log("This is another log");31Reporter.clear();32Reporter.log("This is a log");33Reporter.log("This is another log");34Reporter.clear();35Reporter.log("This is a log");36Reporter.log("This is another log");37Reporter.clear();38Reporter.log("This is a log");39Reporter.log("This is another log");

Full Screen

Full Screen

clear

Using AI Code Generation

copy

Full Screen

1Reporter.clear();2Reporter.log("Hello TestNG!");3Reporter.log("Hello TestNG!", true);4Reporter.log("Hello TestNG!", false);5Reporter.log("Hello TestNG!", true);6Reporter.log("Hello TestNG!", false);7Reporter.log("Hello TestNG!", true);8Reporter.log("Hello TestNG!", false);9Reporter.log("Hello TestNG!", true);10Reporter.log("Hello TestNG!", false);11Reporter.log("Hello TestNG!", true);12Reporter.log("Hello TestNG!", false);13Reporter.log("Hello TestNG!", true);14Reporter.log("Hello TestNG!", false);15Reporter.log("Hello TestNG!", true);16Reporter.log("Hello TestNG!", false);17Reporter.log("Hello TestNG!",

Full Screen

Full Screen

clear

Using AI Code Generation

copy

Full Screen

1import org.testng.Reporter;2import org.testng.annotations.Test;3public class TestNGClearLogs {4 public void testClearLogs() {5 Reporter.log("This is a log message");6 Reporter.log("This is another log message");7 Reporter.clear();8 Reporter.log("This is a log message after clearing the logs");9 }10}

Full Screen

Full Screen

clear

Using AI Code Generation

copy

Full Screen

1public void testMethod() {2Reporter.log("Test method started");3Reporter.log("Test method in progress");4Reporter.clear();5Reporter.log("Test method completed");6}7public void testMethod() {8Reporter.log("Test method started");9Reporter.log("Test method in progress");10Reporter.clear();11Reporter.log("Test method completed");12}13public void testMethod() {14Reporter.log("Test method started");15Reporter.log("Test method in progress");16Reporter.clear();17Reporter.log("Test method completed");18}19public void testMethod() {20Reporter.log("Test method started");21Reporter.log("Test method in progress");22Reporter.clear();23Reporter.log("Test method completed");24}25public void testMethod() {26Reporter.log("Test method started");27Reporter.log("Test method in progress");28Reporter.clear();29Reporter.log("Test method completed");30}31public void testMethod() {32Reporter.log("Test method started");33Reporter.log("Test method in progress");34Reporter.clear();35Reporter.log("Test method completed");36}37public void testMethod() {38Reporter.log("Test method started");39Reporter.log("Test method in progress");40Reporter.clear();41Reporter.log("Test method completed");42}43public void testMethod() {44Reporter.log("Test method started");45Reporter.log("Test method in progress");46Reporter.clear();47Reporter.log("Test method completed");48}49public void testMethod() {50Reporter.log("Test method started");51Reporter.log("Test method in progress");52Reporter.clear();53Reporter.log("Test method completed

Full Screen

Full Screen

TestNG tutorial

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.

Chapters

  1. JUnit 5 vs. TestNG: Compare and explore the core differences between JUnit 5 and TestNG from the Selenium WebDriver viewpoint.
  2. Installing TestNG in Eclipse: Start installing the TestNG Plugin and learn how to set up TestNG in Eclipse to begin constructing a framework for your test project.
  3. Create TestNG Project in Eclipse: Get started with creating a TestNG project and write your first TestNG test script.
  4. Automation using TestNG: Dive into how to install TestNG in this Selenium TestNG tutorial, the fundamentals of developing an automation script for Selenium automation testing.
  5. Parallel Test Execution in TestNG: Here are some essential elements of parallel testing with TestNG in this Selenium TestNG tutorial.
  6. Creating TestNG XML File: Here is a step-by-step tutorial on creating a TestNG XML file to learn why and how it is created and discover how to run the TestNG XML file being executed in parallel.
  7. Automation with Selenium, Cucumber & TestNG: Explore for an in-depth tutorial on automation using Selenium, Cucumber, and TestNG, as TestNG offers simpler settings and more features.
  8. JUnit Selenium Tests using TestNG: Start running your regular and parallel tests by looking at how to run test cases in Selenium using JUnit and TestNG without having to rewrite the tests.
  9. Group Test Cases in TestNG: Along with the explanation and demonstration using relevant TestNG group examples, learn how to group test cases in TestNG.
  10. Prioritizing Tests in TestNG: Get started with how to prioritize test cases in TestNG for Selenium automation testing.
  11. Assertions in TestNG: Examine what TestNG assertions are, the various types of TestNG assertions, and situations that relate to Selenium automated testing.
  12. DataProviders in TestNG: Deep dive into learning more about TestNG's DataProvider and how to effectively use it in our test scripts for Selenium test automation.
  13. Parameterization in TestNG: Here are the several parameterization strategies used in TestNG tests and how to apply them in Selenium automation scripts.
  14. TestNG Listeners in Selenium WebDriver: Understand the various TestNG listeners to utilize them effectively for your next plan when working with TestNG and Selenium automation.
  15. TestNG Annotations: Learn more about the execution order and annotation attributes, and refer to the prerequisites required to set up TestNG.
  16. TestNG Reporter Log in Selenium: Find out how to use the TestNG Reporter Log and learn how to eliminate the need for external software with TestNG Reporter Class to boost productivity.
  17. TestNG Reports in Jenkins: Discover how to generate TestNG reports in Jenkins if you want to know how to create, install, and share TestNG reports in Jenkins.

Certification

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.

YouTube

Watch this complete tutorial to learn how you can leverage the capabilities of the TestNG framework for Selenium automation testing.

Run Testng automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful