How to use NoSuchElementException class of org.openqa.selenium package

Best Selenium code snippet using org.openqa.selenium.NoSuchElementException

NoSuchElementException org.openqa.selenium.NoSuchElementException

NoSuchElementException is a WebDriver Exception occurs when the given element locator is not able to find the webpage element on the current page context.

Example

Lets assume, we are trying to access an element with name foo though the element is not found in current page DOM then it throws NoSuchElementException

copy
1// Waiting 30 seconds for an element to be present on the page, checking 2 // for its presence once every 5 seconds. 3 Wait<WebDriver> wait = new FluentWait<WebDriver>(driver) 4 .withTimeout(30, SECONDS) 5 .pollingEvery(5, SECONDS) 6 .ignoring(NoSuchElementException.class); 7 8 WebElement foo = wait.until(new Function<WebDriver, WebElement>() { 9 public WebElement apply(WebDriver driver) { 10 return driver.findElement(By.id("foo")); 11 } 12 });

Solutions

  • verify for the locator
  • try to access the element using devtool console for the given locator
  • use FluentWait to define max wait time for element appear on page.
  • Handle in try catch block

Code Snippets

Here are code snippets that can help you understand more how developers are using

Source:Page_DetailedApplicationForm.java Github

copy

Full Screen

...25 {26 //DB Format: 2017-02-22 00:00:00.00027 try {28 element =driver.findElement(properties.selectLocator("Step1_DateOfBirthCalendar"));29 } catch (org.openqa.selenium.NoSuchElementException e) {30 e.printStackTrace();31 }32 return element;33 34 }35 36 public static Select displayDOBMonthDropDown() throws Exception37 {38 try {39 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_SelectMonthDropdown"))));40 } catch (org.openqa.selenium.NoSuchElementException e) {41 e.printStackTrace();42 }43 return dropdown; 44 }45 46 public static Select displayDOBYearDropDown() throws Exception47 {48 try {49 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_SelectYearDropdown"))));50 } catch (org.openqa.selenium.NoSuchElementException e) {51 e.printStackTrace();52 }53 return dropdown; 54 }55 56 public static WebElement displayDaysOfMonthInDoB() throws Exception57 {58 try {59// WEBDRIVERWAIT WAIT = NEW WEBDRIVERWAIT(DRIVER, 30);60// wait.until(ExpectedConditions.visibilityOfElementLocated(properties.selectLocator("Step1_DayOfMonth")));61// element = driver.findElement(properties.selectLocator("Step1_DayOfDateOfBirth"));62 element = driver.findElement(By.xpath(".//a[contains(text(),'"+dayInDob+"')]"));63 } catch (org.openqa.selenium.NoSuchElementException e) {64 e.printStackTrace();65 }66 return element;67 }68 69 public static String getBirthMonthFromProvidedDOB(String mon) throws Exception70 {71 switch (mon) {72 case "Jan":73 numericMonth = 1;74 break;75 case "Feb":76 numericMonth = 2;77 case "Mar":78 numericMonth = 3;79 break;80 case "Apr":81 numericMonth = 4;82 break;83 case "May":84 numericMonth = 5;85 break;86 case "Jun":87 numericMonth = 6;88 break;89 case "Jul":90 numericMonth = 7;91 break;92 case "Aug":93 numericMonth = 8;94 break;95 case "Sep":96 numericMonth = 9;97 break;98 case "Oct":99 numericMonth = 10;100 break;101 case "Nov":102 numericMonth = 11;103 break;104 case "Dec":105 numericMonth = 12;106 break;107 default:108 break;109 }110 return Integer.toString(numericMonth);111 }112 113 /*114 public static String getProvideDateOfBirth() throws Exception115 {116 117 dob = displayDOBYearDropDown().getFirstSelectedOption().getText()+"-0"118 +getBirthMonthFromProvidedDOB(displayDOBMonthDropDown().getFirstSelectedOption().getText())119 +displayDaysOfMonth().getText();120 return dob;121 }*/122 /* 123 List<WebElement> allDates=driver.findElements(By.xpath("//table[@class='ui-datepicker-calendar']//td"));124 125 for(WebElement ele:allDates)126 {127 128 String date=ele.getText();129 130 if(date.equalsIgnoreCase("28"))131 {132 ele.click();133 break;134 }135 136 }137 return element;138 */139 public static WebElement displayPlaceOfBirthInputField() throws Exception140 {141 try {142 element = driver.findElement(properties.selectLocator("Step1_PlaceOfBirth"));143 } catch (org.openqa.selenium.NoSuchElementException e) {144 e.printStackTrace();145 }146 return element; 147 }148 149 public static WebElement displayAgeInputField() throws Exception150 {151 try {152 element = driver.findElement(properties.selectLocator("Step1_Age"));153 } catch (org.openqa.selenium.NoSuchElementException e) {154 e.printStackTrace();155 }156 return element; 157 }158 159 public static WebElement displayBloodGroupInputField() throws Exception160 {161 try {162 element = driver.findElement(properties.selectLocator("Step1_BloodGroup"));163 } catch (org.openqa.selenium.NoSuchElementException e) {164 e.printStackTrace();165 }166 return element; 167 }168 169 public static Select displayGenderDropDown() throws Exception170 {171 try {172 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_Gender"))));173 } catch (org.openqa.selenium.NoSuchElementException e) {174 e.printStackTrace();175 }176 return dropdown;177 }178 179 public static WebElement displayAadhaarNumberInputField() throws Exception180 {181 try {182 element = driver.findElement(properties.selectLocator("Step1_AadharNumber"));183 } catch (org.openqa.selenium.NoSuchElementException e) {184 e.printStackTrace();185 }186 return element; 187 }188 189 public static WebElement displayCitizenshipInputField() throws Exception190 {191 try {192 element = driver.findElement(properties.selectLocator("Step1_Citizenship"));193 } catch (org.openqa.selenium.NoSuchElementException e) {194 e.printStackTrace();195 }196 return element; 197 }198 199 public static WebElement displayNationalityInputField() throws Exception200 {201 try {202 element = driver.findElement(properties.selectLocator("Step1_Nationality"));203 } catch (org.openqa.selenium.NoSuchElementException e) {204 e.printStackTrace();205 }206 return element; 207 }208 209 public static WebElement displayPassportNumberInputField() throws Exception210 {211 try {212 element = driver.findElement(properties.selectLocator("Step1_PassportNum"));213 } catch (org.openqa.selenium.NoSuchElementException e) {214 e.printStackTrace();215 }216 return element; 217 }218 219 public static WebElement displayPlaceOfIssueInputField() throws Exception220 {221 try {222 element = driver.findElement(properties.selectLocator("Step1_PlaceOfIssue"));223 } catch (org.openqa.selenium.NoSuchElementException e) {224 e.printStackTrace();225 }226 return element; 227 }228 229 public static WebElement displayDateOfIssueInputField() throws Exception230 {231 //DB Format: 2017-02-22 00:00:00.000232 try {233 element =driver.findElement(properties.selectLocator("Step1_DateOfIssueCalendar"));234 } catch (org.openqa.selenium.NoSuchElementException e) {235 e.printStackTrace();236 }237 return element;238 239 }240 241 public static Select displayDateOfIssueMonthDropDown() throws Exception242 {243 try {244 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_SelectMonthDropdown"))));245 } catch (org.openqa.selenium.NoSuchElementException e) {246 e.printStackTrace();247 }248 return dropdown; 249 }250 251 public static Select displayDateOfIssueYearDropDown() throws Exception252 {253 try {254 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_SelectYearDropdown"))));255 } catch (org.openqa.selenium.NoSuchElementException e) {256 e.printStackTrace();257 }258 return dropdown; 259 }260 261 public static WebElement displayDaysOfMonthInDateOfIssue() throws Exception262 {263 try {264// WebDriverWait wait = new WebDriverWait(driver, 30);265// wait.until(ExpectedConditions.visibilityOfElementLocated(properties.selectLocator("Step1_DayOfMonth")));266 element = driver.findElement(By.xpath(".//a[contains(text(),'"+dayInDateOfIssue+"')]"));267 } catch (org.openqa.selenium.NoSuchElementException e) {268 e.printStackTrace();269 }270 return element;271 }272 273 public static String getMonthFromProvidedDateOfIssue(String mon) throws Exception274 {275 switch (mon) {276 case "Jan":277 numericMonth = 1;278 break;279 case "Feb":280 numericMonth = 2;281 case "Mar":282 numericMonth = 3;283 break;284 case "Apr":285 numericMonth = 4;286 break;287 case "May":288 numericMonth = 5;289 break;290 case "Jun":291 numericMonth = 6;292 break;293 case "Jul":294 numericMonth = 7;295 break;296 case "Aug":297 numericMonth = 8;298 break;299 case "Sep":300 numericMonth = 9;301 break;302 case "Oct":303 numericMonth = 10;304 break;305 case "Nov":306 numericMonth = 11;307 break;308 case "Dec":309 numericMonth = 12;310 break;311 default:312 break;313 }314 return Integer.toString(numericMonth);315 } 316 317 318 public static WebElement displayExpiryDateInputField() throws Exception319 {320 //DB Format: 2017-02-22 00:00:00.000321 try {322 element =driver.findElement(properties.selectLocator("Step1_ExpiryDateCalendar"));323 } catch (org.openqa.selenium.NoSuchElementException e) {324 e.printStackTrace();325 }326 return element;327 328 }329 330 public static Select displayExpiryDateMonthDropDown() throws Exception331 {332 try {333 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_SelectMonthDropdown"))));334 } catch (org.openqa.selenium.NoSuchElementException e) {335 e.printStackTrace();336 }337 return dropdown; 338 }339 340 public static Select displayExpiryDateYearDropDown() throws Exception341 {342 try {343 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_SelectYearDropdown"))));344 } catch (org.openqa.selenium.NoSuchElementException e) {345 e.printStackTrace();346 }347 return dropdown; 348 }349 350 public static WebElement displayDaysOfMonthInExpiryDate() throws Exception351 {352 try {353// WebDriverWait wait = new WebDriverWait(driver, 30);354// wait.until(ExpectedConditions.visibilityOfElementLocated(properties.selectLocator("Step1_DayOfMonth")));355 element = driver.findElement(By.xpath(".//a[contains(text(),'"+dayInExpiryDate+"')]"));356 } catch (org.openqa.selenium.NoSuchElementException e) {357 e.printStackTrace();358 }359 return element;360 }361 362 public static String getMonthFromProvidedExpiryDate(String mon) throws Exception363 {364 switch (mon) {365 case "Jan":366 numericMonth = 1;367 break;368 case "Feb":369 numericMonth = 2;370 case "Mar":371 numericMonth = 3;372 break;373 case "Apr":374 numericMonth = 4;375 break;376 case "May":377 numericMonth = 5;378 break;379 case "Jun":380 numericMonth = 6;381 break;382 case "Jul":383 numericMonth = 7;384 break;385 case "Aug":386 numericMonth = 8;387 break;388 case "Sep":389 numericMonth = 9;390 break;391 case "Oct":392 numericMonth = 10;393 break;394 case "Nov":395 numericMonth = 11;396 break;397 case "Dec":398 numericMonth = 12;399 break;400 default:401 break;402 }403 return Integer.toString(numericMonth);404 } 405 406 public static WebElement displayReligionInputField() throws Exception407 {408 try {409 element = (driver.findElement((properties.selectLocator("Step1_Religion"))));410 } catch (org.openqa.selenium.NoSuchElementException e) {411 e.printStackTrace();412 }413 return element; 414 }415 416 public static Select displayCasteDropDown() throws Exception417 {418 try {419 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_Caste"))));420 } catch (org.openqa.selenium.NoSuchElementException e) {421 e.printStackTrace();422 }423 return dropdown; 424 }425 426 public static WebElement displayOtherCasteInputField() throws Exception427 {428 try {429 element = (driver.findElement((properties.selectLocator("Step1_OtherCaste"))));430 } catch (org.openqa.selenium.NoSuchElementException e) {431 e.printStackTrace();432 }433 return element; 434 }435 436 public static Select displayDomicileDropDown() throws Exception437 {438 try {439 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_Domicile"))));440 } catch (org.openqa.selenium.NoSuchElementException e) {441 e.printStackTrace();442 }443 return dropdown; 444 }445 446 public static WebElement displayOtherDomicileInputField() throws Exception447 {448 try {449 element = (driver.findElement((properties.selectLocator("Step1_OtherDomicile"))));450 } catch (org.openqa.selenium.NoSuchElementException e) {451 e.printStackTrace();452 }453 return element; 454 }455 456 public static Select displayCommunityDropDown() throws Exception457 {458 try {459 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_Community"))));460 } catch (org.openqa.selenium.NoSuchElementException e) {461 e.printStackTrace();462 }463 return dropdown; 464 }465 466 public static WebElement displayOtherCommunityInputField() throws Exception467 {468 try {469 element = (driver.findElement((properties.selectLocator("Step1_OtherCommunity"))));470 } catch (org.openqa.selenium.NoSuchElementException e) {471 e.printStackTrace();472 }473 return element; 474 }475 476 public static WebElement displayPresentAddressInputFieldStep1() throws Exception477 {478 try {479 element = driver.findElement(properties.selectLocator("Step1_MainAddress"));480 } catch (org.openqa.selenium.NoSuchElementException e) {481 e.printStackTrace();482 }483 return element; 484 }485 486 public static Select displayPresentAddrCountryDropDown() throws Exception487 {488 try {489 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_PresentCountry"))));490 } catch (org.openqa.selenium.NoSuchElementException e) {491 e.printStackTrace();492 }493 return dropdown; 494 }495 496 public static Select displayPresentAddrStateDropDown() throws Exception497 {498 try {499 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_PresentState"))));500 } catch (org.openqa.selenium.NoSuchElementException e) {501 e.printStackTrace();502 }503 return dropdown; 504 }505 506 public static Select displayPresentAddrCityDropDown() throws Exception507 {508 try {509 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_PresentCity"))));510 } catch (org.openqa.selenium.NoSuchElementException e) {511 e.printStackTrace();512 }513 return dropdown; 514 }515 516 public static WebElement displayPresentAddrPincodeInputField() throws Exception517 {518 try {519 element = driver.findElement((properties.selectLocator("Step1_PresentPincode")));520 } catch (org.openqa.selenium.NoSuchElementException e) {521 e.printStackTrace();522 }523 return element; 524 }525 526 public static WebElement displayPresentAddrContactNumberInputField() throws Exception527 {528 try {529 element = driver.findElement(properties.selectLocator("Step1_PresentAddrContactNumber"));530 } catch (org.openqa.selenium.NoSuchElementException e) {531 e.printStackTrace();532 }533 return element; 534 }535 536 public static WebElement displaySameAddressCheckboxStep() throws Exception537 {538 try {539 element = driver.findElement(properties.selectLocator("Step1_SameAddressCheckbox"));540 } catch (org.openqa.selenium.NoSuchElementException e) {541 e.printStackTrace();542 }543 return element; 544 }545 546 public static WebElement displayPermanentAddressInputFieldStep1() throws Exception547 {548 try {549 element = driver.findElement(properties.selectLocator("Step1_PermanentAddress"));550 } catch (org.openqa.selenium.NoSuchElementException e) {551 e.printStackTrace();552 }553 return element; 554 }555 556 public static Select displayPermanentAddrCountryDropDown() throws Exception557 {558 try {559 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_PermanentCountry"))));560 } catch (org.openqa.selenium.NoSuchElementException e) {561 e.printStackTrace();562 }563 return dropdown; 564 }565 566 public static Select displayPermanentAddrStateDropDown() throws Exception567 {568 try {569 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_PermanentState"))));570 } catch (org.openqa.selenium.NoSuchElementException e) {571 e.printStackTrace();572 }573 return dropdown; 574 }575 576 public static Select displayPermanentAddrCityDropDown() throws Exception577 {578 try {579 dropdown = new Select(driver.findElement((properties.selectLocator("Step1_PermanentCity"))));580 } catch (org.openqa.selenium.NoSuchElementException e) {581 e.printStackTrace();582 }583 return dropdown; 584 }585 586 public static WebElement displayPermanentAddrPincodeInputField() throws Exception587 {588 try {589 element = driver.findElement((properties.selectLocator("Step1_PermanentPincode")));590 } catch (org.openqa.selenium.NoSuchElementException e) {591 e.printStackTrace();592 }593 return element; 594 }595 596 public static WebElement displayPermanentAddrContactNumberInputField() throws Exception597 {598 try {599 element = driver.findElement(properties.selectLocator("Step1_PermanentAddrContactNumber"));600 } catch (org.openqa.selenium.NoSuchElementException e) {601 e.printStackTrace();602 }603 return element; 604 }605 606 public static WebElement displayAlternateAddress1InputField() throws Exception607 {608 try {609 element = driver.findElement(properties.selectLocator("Step1_AlternateAddress1"));610 } catch (org.openqa.selenium.NoSuchElementException e) {611 e.printStackTrace();612 }613 return element; 614 }615 616 public static WebElement displayAlternateAddress2InputField() throws Exception617 {618 try {619 element = driver.findElement(properties.selectLocator("Step1_AlternateAddress2"));620 } catch (org.openqa.selenium.NoSuchElementException e) {621 e.printStackTrace();622 }623 return element; 624 }625 626 public static WebElement displayAlternateContactNumberInputField() throws Exception627 {628 try {629 element = driver.findElement(properties.selectLocator("Step1_AlternateContact"));630 } catch (org.openqa.selenium.NoSuchElementException e) {631 e.printStackTrace();632 }633 return element; 634 }635 636 public static WebElement displayNextButtonStep1() throws Exception637 {638 try {639 element = driver.findElement(properties.selectLocator("Step1_NextButton"));640 } catch (org.openqa.selenium.NoSuchElementException e) {641 e.printStackTrace();642 }643 return element; 644 }645 646 /********************* STEP 2 *************************/647 648 public static WebElement displayFathersNameInputField() throws Exception649 {650 try {651 element = driver.findElement(properties.selectLocator("Step2_FathersName"));652 } catch (org.openqa.selenium.NoSuchElementException e) {653 e.printStackTrace();654 }655 return element; 656 }657 658 public static WebElement displayFathersQualificationInputField() throws Exception659 {660 try {661 element = driver.findElement(properties.selectLocator("Step2_FathersQualification"));662 } catch (org.openqa.selenium.NoSuchElementException e) {663 e.printStackTrace();664 }665 return element; 666 }667 668 public static WebElement displayFathersOccupationInputField() throws Exception669 {670 try {671 element = driver.findElement(properties.selectLocator("Step2_FathersOccupation"));672 } catch (org.openqa.selenium.NoSuchElementException e) {673 e.printStackTrace();674 }675 return element; 676 }677 678 public static WebElement displayAnnualIncomeInputField() throws Exception679 {680 try {681 element = driver.findElement(properties.selectLocator("Step2_FathersAnnualIncome"));682 } catch (org.openqa.selenium.NoSuchElementException e) {683 e.printStackTrace();684 }685 return element; 686 }687 688 public static WebElement displayFathersEmailInputField() throws Exception689 {690 try {691 element = driver.findElement(properties.selectLocator("Step2_FathersEmail"));692 } catch (org.openqa.selenium.NoSuchElementException e) {693 e.printStackTrace();694 }695 return element; 696 }697 698 public static WebElement displayFathersMobileInputField() throws Exception699 {700 try {701 element = driver.findElement(properties.selectLocator("Step2_FathersMobile"));702 } catch (org.openqa.selenium.NoSuchElementException e) {703 e.printStackTrace();704 }705 return element; 706 }707 708 public static WebElement displayMothersNameInputField() throws Exception709 {710 try {711 element = driver.findElement(properties.selectLocator("Step2_MothersName"));712 } catch (org.openqa.selenium.NoSuchElementException e) {713 e.printStackTrace();714 }715 return element; 716 }717 718 public static WebElement displayMothersQualificationInputField() throws Exception719 {720 try {721 element = driver.findElement(properties.selectLocator("Step2_MothersQualification"));722 } catch (org.openqa.selenium.NoSuchElementException e) {723 e.printStackTrace();724 }725 return element; 726 }727 728 public static WebElement displayMothersOccupationInputField() throws Exception729 {730 try {731 element = driver.findElement(properties.selectLocator("Step2_MothersOccupation"));732 } catch (org.openqa.selenium.NoSuchElementException e) {733 e.printStackTrace();734 }735 return element; 736 }737 738 public static WebElement displayMothersEmailInputField() throws Exception739 {740 try {741 element = driver.findElement(properties.selectLocator("Step2_MothersEmail"));742 } catch (org.openqa.selenium.NoSuchElementException e) {743 e.printStackTrace();744 }745 return element; 746 }747 748 public static WebElement displayMothersMobileInputField() throws Exception749 {750 try {751 element = driver.findElement(properties.selectLocator("Step2_MothersMobile"));752 } catch (org.openqa.selenium.NoSuchElementException e) {753 e.printStackTrace();754 }755 return element; 756 }757 758 public static WebElement displayGuardiansNameInputField() throws Exception759 {760 try {761 element = driver.findElement(properties.selectLocator("Step2_GuardianName"));762 } catch (org.openqa.selenium.NoSuchElementException e) {763 e.printStackTrace();764 }765 return element; 766 }767 768 public static WebElement displayGuardiansAddress1InputField() throws Exception769 {770 try {771 element = driver.findElement(properties.selectLocator("Step2_GuardianAddress1"));772 } catch (org.openqa.selenium.NoSuchElementException e) {773 e.printStackTrace();774 }775 return element; 776 }777 778 public static WebElement displayGuardiansAddress2InputField() throws Exception779 {780 try {781 element = driver.findElement(properties.selectLocator("Step2_GuardianAddress2"));782 } catch (org.openqa.selenium.NoSuchElementException e) {783 e.printStackTrace();784 }785 return element; 786 }787 788 public static WebElement displayGuardiansAddress3InputField() throws Exception789 {790 try {791 element = driver.findElement(properties.selectLocator("Step2_GuardianAddress3"));792 } catch (org.openqa.selenium.NoSuchElementException e) {793 e.printStackTrace();794 }795 return element; 796 }797 798 public static WebElement displayGuardianAddrPincodeInputField() throws Exception799 {800 try {801 element = driver.findElement(properties.selectLocator("Step2_GuardianAddrPincode"));802 } catch (org.openqa.selenium.NoSuchElementException e) {803 e.printStackTrace();804 }805 return element; 806 }807 808 public static WebElement displayGuardianRelationInputField() throws Exception809 {810 try {811 element = driver.findElement(properties.selectLocator("Step2_GuardianRelation"));812 } catch (org.openqa.selenium.NoSuchElementException e) {813 e.printStackTrace();814 }815 return element; 816 }817 818 public static WebElement displayGuardiansContactNumberInputField() throws Exception819 {820 try {821 element = driver.findElement(properties.selectLocator("Step2_GuardianContactNumber"));822 } catch (org.openqa.selenium.NoSuchElementException e) {823 e.printStackTrace();824 }825 return element; 826 }827 828 829 830 public static WebElement displayNextButtonStep2() throws Exception831 {832 try {833 element = driver.findElement(properties.selectLocator("Step2_NextButton"));834 } catch (org.openqa.selenium.NoSuchElementException e) {835 e.printStackTrace();836 }837 return element; 838 }839 840 /********************* STEP 3 *************************/841 842 public static Select displaySelectCourseDropDown() throws Exception843 {844 try {845 dropdown = new Select(driver.findElement((properties.selectLocator("Step3_SelectCourse"))));846 } catch (org.openqa.selenium.NoSuchElementException e) {847 e.printStackTrace();848 }849 return dropdown; 850 }851 852 //Temp method853 public static WebElement displaySelectCourseDropDown1() throws Exception854 {855 try {856 element =driver.findElement((properties.selectLocator("Step3_SelectCourse")));857 } catch (org.openqa.selenium.NoSuchElementException e) {858 e.printStackTrace();859 }860 return element; 861 }862 863 public static WebElement displaySSCSchoolNameInputField() throws Exception864 { 865 try {866 element = driver.findElement(properties.selectLocator("Step3_SSCSchoolName"));867 } catch (org.openqa.selenium.NoSuchElementException e) {868 e.printStackTrace();869 }870 return element; 871 }872 873 public static Select displaySelectSSCBoardDropDown() throws Exception874 {875 try {876 dropdown = new Select(driver.findElement((properties.selectLocator("Step3_SSCBoard"))));877 } catch (org.openqa.selenium.NoSuchElementException e) {878 e.printStackTrace();879 }880 return dropdown; 881 }882 883 public static Select displaySelectSSCYoPDropDown() throws Exception884 {885 try {886 dropdown = new Select(driver.findElement((properties.selectLocator("Step3_SSCYoP"))));887 } catch (org.openqa.selenium.NoSuchElementException e) {888 e.printStackTrace();889 }890 return dropdown; 891 }892 893 public static WebElement displaySSCRegNumberInputField() throws Exception894 { 895 try {896 element = driver.findElement(properties.selectLocator("Step3_RegNumberSSC"));897 } catch (org.openqa.selenium.NoSuchElementException e) {898 e.printStackTrace();899 }900 return element; 901 }902 903 public static Select displaySSCModeOfStudyDropDown() throws Exception904 {905 try {906 dropdown = new Select(driver.findElement((properties.selectLocator("Step3_ModeOfStudySSC"))));907 } catch (org.openqa.selenium.NoSuchElementException e) {908 e.printStackTrace();909 }910 return dropdown; 911 }912 913 public static WebElement displayOtherSSCModeOfStudyInputField() throws Exception914 {915 try {916 element = (driver.findElement((properties.selectLocator("Step3_OtherModeOfStudySSC"))));917 } catch (org.openqa.selenium.NoSuchElementException e) {918 e.printStackTrace();919 }920 return element; 921 }922 923 public static WebElement displaySSCPercentageInputField() throws Exception924 { 925 try {926 element = driver.findElement(properties.selectLocator("Step3_SSCPercentage"));927 } catch (org.openqa.selenium.NoSuchElementException e) {928 e.printStackTrace();929 }930 return element; 931 }932 933 public static WebElement displayHSCSchoolNameInputField() throws Exception934 { 935 try {936 element = driver.findElement(properties.selectLocator("Step3_HSCSchoolName"));937 } catch (org.openqa.selenium.NoSuchElementException e) {938 e.printStackTrace();939 }940 return element; 941 }942 943 public static Select displaySelectHSCBoardDropDown() throws Exception944 {945 try {946 dropdown = new Select(driver.findElement((properties.selectLocator("Step3_HSCBoard"))));947 } catch (org.openqa.selenium.NoSuchElementException e) {948 e.printStackTrace();949 }950 return dropdown; 951 }952 953 public static WebElement showHideHSCDetailsSection() throws Exception954 {955 try {956 WebDriverWait wait = new WebDriverWait(driver, 30);957 wait.until(ExpectedConditions.visibilityOfElementLocated(properties.selectLocator("Step3_HSCYesResultStatus")));958 element = driver.findElement((properties.selectLocator("Step3_HSCYesResultStatus")));959 } catch (org.openqa.selenium.NoSuchElementException e) {960 e.printStackTrace();961 }962 return element; 963 }964 965 public static boolean displayHSCDetailsSection() throws Exception966 {967 visibleFlag=false;968 969 showHideHSCDetailsSection().click();970 Thread.sleep(1000);971 if(driver.findElement(properties.selectLocator("Step3_HSCDetailsSection")).isDisplayed())972 {973 visibleFlag = true;974 return visibleFlag;975 }976 else977 return visibleFlag;978 }979 980 public static Select displayModeOfStudyHSCDropDown() throws Exception981 {982 try {983 dropdown = new Select(driver.findElement((properties.selectLocator("Step3_ModeOfStudyHSC"))));984 } catch (org.openqa.selenium.NoSuchElementException e) {985 e.printStackTrace();986 }987 return dropdown; 988 }989 990 public static WebElement displayOtherHSCModeOfStudyInputField() throws Exception991 {992 try {993 element = (driver.findElement((properties.selectLocator("Step3_OtherModeOfStudyHSC"))));994 } catch (org.openqa.selenium.NoSuchElementException e) {995 e.printStackTrace();996 }997 return element; 998 }999 1000 public static Select displayHSCYearOfPassingDropDown() throws Exception1001 {1002 try {1003 dropdown = new Select(driver.findElement((properties.selectLocator("Step3_HSCYoP"))));1004 } catch (org.openqa.selenium.NoSuchElementException e) {1005 e.printStackTrace();1006 }1007 return dropdown; 1008 }1009 1010 public static WebElement displayHSCPercentageGradeRadioButton() throws Exception1011 { 1012 try {1013 element = driver.findElement((properties.selectLocator("Step3_EvaluationTypeHSC_Percent")));1014 //Grade Can be provided. Just change locator accordingly1015 } catch (org.openqa.selenium.NoSuchElementException e) {1016 e.printStackTrace();1017 }1018 return element;1019 }1020 1021 public static WebElement displayHSCPercentageInputField() throws Exception1022 { 1023 1024 try {1025 element = driver.findElement((properties.selectLocator("Step3_HSCPercentage")));1026 } catch (org.openqa.selenium.NoSuchElementException e) {1027 e.printStackTrace();1028 }1029 return element;1030 }1031 1032 public static WebElement displayHSCRegNumberInputField() throws Exception1033 { 1034 try {1035 element = driver.findElement((properties.selectLocator("Step3_RegNumberHSC")));1036 } catch (org.openqa.selenium.NoSuchElementException e) {1037 e.printStackTrace();1038 }1039 return element;1040 }1041 1042 public static void addMoreSubjectsHSC(int n) throws Exception1043 {1044 for (int i = 1; i <= n; i++) 1045 {1046 Thread.sleep(1000);1047 driver.findElement(properties.selectLocator("Step3_AddMoreSubjectsButton")).click();1048 }1049 }1050 public static void displaySubMarkPercentageInputFields(int n) throws Exception1051 {1052 addMoreSubjectsHSC(n-1);1053 for (int i = 1; i < n+1; i++) 1054 {1055 hscSubjects.add(driver.findElement((By.id("XIISub"+i))));1056 hscSubjects.add(driver.findElement((By.id("XIIMaxSub"+i+"Mark"))));1057 hscSubjects.add(driver.findElement((By.id("XIISub"+i+"MarksGrade"))));1058 hscSubjects.add(driver.findElement((By.id("XIISub"+i+"Per"))));1059 }1060// System.out.println("Just for check: "+ Arrays.toString(webElements.toArray()));1061 }1062 1063 public static WebElement displayEntranceExamSection() throws Exception1064 { 1065 try {1066 element = driver.findElement(properties.selectLocator("Step2_EntranceExamSection"));1067 } catch (org.openqa.selenium.NoSuchElementException e) {1068 e.printStackTrace();1069 }1070 return element; 1071 }1072 1073 public static void addMoreEntranceExams(int n) throws Exception1074 {1075 for (int i = 1; i <= n; i++) 1076 {1077 driver.findElement(properties.selectLocator("Step3_AddMoreEntranceExamButton")).click();1078 }1079 }1080 1081 public static void displayEntranceExamDetailsInputFields(int n) throws Exception1082 {1083 addMoreEntranceExams(n-1);1084 for (int i = 1; i < n+1; i++) 1085 {1086 hscSubjects.add(driver.findElement((By.id("entranceExam"+i))));1087 hscSubjects.add(driver.findElement((By.id("entranceExamMark"+i))));1088 }1089// System.out.println("Just for check: "+ Arrays.toString(webElements.toArray()));1090 }1091 1092 1093 public static WebElement showHideDiplomaDetailsSection() throws Exception1094 {1095 try {1096 WebDriverWait wait = new WebDriverWait(driver, 30);1097 wait.until(ExpectedConditions.visibilityOfElementLocated(properties.selectLocator("Step3_DiplomaDetailsShowYes")));1098 element = driver.findElement((properties.selectLocator("Step3_DiplomaDetailsShowYes")));1099 } catch (org.openqa.selenium.NoSuchElementException e) {1100 e.printStackTrace();1101 }1102 return element; 1103 }1104 1105 public static boolean displayDiplomaDetailsSection() throws Exception1106 {1107 visibleFlag=false;1108 1109 showHideDiplomaDetailsSection().click();1110 Thread.sleep(1000);1111 if(driver.findElement(properties.selectLocator("Step3_DiplomaDetailsSection")).isDisplayed())1112 {1113 visibleFlag = true;1114 return visibleFlag;1115 }1116 else1117 return visibleFlag;1118 }1119 1120 public static WebElement selectGradDiplomaType() throws Exception1121 { 1122 try {1123 element = driver.findElement(properties.selectLocator("Step3_DiplomaDetailsGradOption")); //Change locator for diploma option1124 } catch (org.openqa.selenium.NoSuchElementException e) {1125 e.printStackTrace();1126 }1127 return element; 1128 }1129 1130 public static WebElement displayDegreeDiplomaNameInputField() throws Exception1131 { 1132 try {1133 element = driver.findElement(properties.selectLocator("Step3_DiplomaName")); 1134 } catch (org.openqa.selenium.NoSuchElementException e) {1135 e.printStackTrace();1136 }1137 return element; 1138 }1139 1140 public static WebElement displayDegreeDiplomaAoSInputField() throws Exception1141 { 1142 try {1143 element = driver.findElement(properties.selectLocator("Step3_DiplomaAOS")); 1144 } catch (org.openqa.selenium.NoSuchElementException e) {1145 e.printStackTrace();1146 }1147 return element; 1148 }1149 1150 public static WebElement displayDegreeDiplomaCollegeNameInputField() throws Exception1151 { 1152 try {1153 element = driver.findElement(properties.selectLocator("Step3_DiplomaCollegeName")); 1154 } catch (org.openqa.selenium.NoSuchElementException e) {1155 e.printStackTrace();1156 }1157 return element; 1158 }1159 1160 public static WebElement displayDegreeDiplomaUniversityNameInputField() throws Exception1161 { 1162 try {1163 element = driver.findElement(properties.selectLocator("Step3_DiplomaUniversityName")); 1164 } catch (org.openqa.selenium.NoSuchElementException e) {1165 e.printStackTrace();1166 }1167 return element; 1168 }1169 1170 public static Select displayDegreeDiplomaExamTypeDropDown() throws Exception1171 {1172 try {1173 dropdown = new Select(driver.findElement((properties.selectLocator("Step3_DiplomaExamType"))));1174 } catch (org.openqa.selenium.NoSuchElementException e) {1175 e.printStackTrace();1176 }1177 return dropdown; 1178 }1179 1180 public static Select displayDegreeDiplomaYoCDropDown() throws Exception1181 {1182 try {1183 dropdown = new Select(driver.findElement((properties.selectLocator("Step3_DiplomaYoC"))));1184 } catch (org.openqa.selenium.NoSuchElementException e) {1185 e.printStackTrace();1186 }1187 return dropdown; 1188 }1189 1190 public static Select displayDegreeDiplomaModeOfStudyDropDown() throws Exception1191 {1192 try {1193 dropdown = new Select(driver.findElement((properties.selectLocator("Step3_ModeOfStudyDiploma"))));1194 } catch (org.openqa.selenium.NoSuchElementException e) {1195 e.printStackTrace();1196 }1197 return dropdown; 1198 }1199 1200 public static WebElement displayOtherDegreeDiplomaModeOfStudyInputField() throws Exception1201 {1202 try {1203 element = (driver.findElement((properties.selectLocator("Step3_OtherModeOfStudyDiploma"))));1204 } catch (org.openqa.selenium.NoSuchElementException e) {1205 e.printStackTrace();1206 }1207 return element; 1208 }1209 1210 public static void addMoreGraduationYears(int n) throws Exception1211 {1212 for (int i = 1; i <= n; i++) 1213 {1214 driver.findElement(properties.selectLocator("Step3_AddMoreYearsButton")).click();1215 }1216 }1217 1218 public static void displayGraduationYearwiseMarksInputFields(int n) throws Exception1219 {1220 1221 addMoreGraduationYears(n-1);1222 1223 for (int i = 1; i < n+1; i++) 1224 {1225 hscSubjects.add(driver.findElement((By.id("degreeDiplomaYrSub"+i))));1226 hscSubjects.add(driver.findElement((By.id("degreeDiplomaYrSub"+i+"MaxMark"))));1227 hscSubjects.add(driver.findElement((By.id("degreeDiplomaYrSub"+i+"MarksGrade"))));1228 hscSubjects.add(driver.findElement((By.id("degreeDiplomaYrSub"+i+"Per"))));1229 }1230// System.out.println("Just for check: "+ Arrays.toString(webElements.toArray()));1231 }1232 1233 public static WebElement displayAttachment1Button() throws Exception1234 { 1235 try {1236 element = driver.findElement(properties.selectLocator("Step3_Attachment1"));1237 } catch (org.openqa.selenium.NoSuchElementException e) {1238 e.printStackTrace();1239 }1240 return element; 1241 }1242 1243 public static WebElement displayAttachment2Button() throws Exception1244 { 1245 try {1246 element = driver.findElement(properties.selectLocator("Step3_Attachment2"));1247 } catch (org.openqa.selenium.NoSuchElementException e) {1248 e.printStackTrace();1249 }1250 return element; 1251 }1252 1253 public static WebElement displayAttachment3Button() throws Exception1254 { 1255 try {1256 element = driver.findElement(properties.selectLocator("Step3_Attachment3"));1257 } catch (org.openqa.selenium.NoSuchElementException e) {1258 e.printStackTrace();1259 }1260 return element; 1261 }1262 1263 public static WebElement displayAttachment4Button() throws Exception1264 { 1265 try {1266 element = driver.findElement(properties.selectLocator("Step3_Attachment4"));1267 } catch (org.openqa.selenium.NoSuchElementException e) {1268 e.printStackTrace();1269 }1270 return element; 1271 }1272 1273 public static WebElement displayAttachment5Button() throws Exception1274 { 1275 try {1276 element = driver.findElement(properties.selectLocator("Step3_Attachment5"));1277 } catch (org.openqa.selenium.NoSuchElementException e) {1278 e.printStackTrace();1279 }1280 return element; 1281 }1282 1283 public static WebElement displayAttachment6Button() throws Exception1284 { 1285 try {1286 element = driver.findElement(properties.selectLocator("Step3_Attachment6"));1287 } catch (org.openqa.selenium.NoSuchElementException e) {1288 e.printStackTrace();1289 }1290 return element; 1291 }1292 1293 public static WebElement displayAttachment7Button() throws Exception1294 { 1295 try {1296 element = driver.findElement(properties.selectLocator("Step3_Attachment7"));1297 } catch (org.openqa.selenium.NoSuchElementException e) {1298 e.printStackTrace();1299 }1300 return element; 1301 }1302 1303 public static WebElement displayAttachment8Button() throws Exception1304 { 1305 try {1306 element = driver.findElement(properties.selectLocator("Step3_Attachment8"));1307 } catch (org.openqa.selenium.NoSuchElementException e) {1308 e.printStackTrace();1309 }1310 return element; 1311 }1312 1313 public static WebElement displayAttachment9Button() throws Exception1314 { 1315 try {1316 element = driver.findElement(properties.selectLocator("Step3_Attachment9"));1317 } catch (org.openqa.selenium.NoSuchElementException e) {1318 e.printStackTrace();1319 }1320 return element; 1321 }1322 1323 public static WebElement displayAttachment10Button() throws Exception1324 { 1325 try {1326 element = driver.findElement(properties.selectLocator("Step3_Attachment10"));1327 } catch (org.openqa.selenium.NoSuchElementException e) {1328 e.printStackTrace();1329 }1330 return element; 1331 }1332 1333 public static WebElement displayNextButtonStep3() throws Exception1334 {1335 try {1336 element = driver.findElement(properties.selectLocator("Step3_NextButton"));1337 } catch (org.openqa.selenium.NoSuchElementException e) {1338 e.printStackTrace();1339 }1340 return element; 1341 }1342 1343/********************* STEP 4 *************************/1344 1345 public static Select displayEntityDropdown() throws Exception1346 {1347 try {1348 dropdown = new Select(driver.findElement((properties.selectLocator("Step4_PaymentCourse"))));1349 } catch (org.openqa.selenium.NoSuchElementException e) {1350 e.printStackTrace();1351 }1352 return dropdown; 1353 }1354 1355 //temp method1356 public static WebElement displayEntityDropdown1() throws Exception1357 { 1358 try {1359 element = driver.findElement(properties.selectLocator("Step4_PaymentCourse"));1360 } catch (org.openqa.selenium.NoSuchElementException e) {1361 e.printStackTrace();1362 }1363 return element; 1364 }1365 1366 public static Select displayPaymentTypeDropdown() throws Exception1367 {1368 try {1369 dropdown = new Select(driver.findElement((properties.selectLocator("Step4_PaymentType"))));1370 } catch (org.openqa.selenium.NoSuchElementException e) {1371 e.printStackTrace();1372 }1373 return dropdown; 1374 }1375 1376 public static WebElement displayPaymentAmountField() throws Exception1377 { 1378 try {1379 element = driver.findElement(properties.selectLocator("Step4_PaymentAmount"));1380 } catch (org.openqa.selenium.NoSuchElementException e) {1381 e.printStackTrace();1382 }1383 return element; 1384 }1385 1386 public static WebElement displaySubmitButtonStep4() throws Exception1387 { 1388 try {1389 WebDriverWait wait = new WebDriverWait(driver, 30);1390 wait.until(ExpectedConditions.visibilityOfElementLocated(properties.selectLocator("Step4_SubmitButtonStep4")));1391 element = driver.findElement(properties.selectLocator("Step4_SubmitButtonStep4"));1392 } catch (org.openqa.selenium.NoSuchElementException e) {1393 e.printStackTrace();1394 }1395 return element; 1396 }1397}...

Full Screen

Full Screen

Source:recentlist_screen.java Github

copy

Full Screen

...53 // assert (driver.findElement(back).isDisplayed());54 Thread.sleep(2000);55 driver.findElement(back).click();56 return true;57 } catch (org.openqa.selenium.NoSuchElementException e) {58 return false;59 }60 }61 62 /* assert back button */63 public boolean isBackButtonDisplayed() {64 try {65 // assert (driver.findElement(back).isDisplayed());66 driver.findElement(Back).click();67 return true;68 } catch (org.openqa.selenium.NoSuchElementException e) {69 return false;70 }71 }72 73 /* assert back button */74 public boolean IsAddFriendsButtonDisplayed() throws InterruptedException {75 try {76 // assert (driver.findElement(AddFriends).isDisplayed());77 Thread.sleep(5000);78 driver.findElement(AddFriends).click();79 return true;80 } catch (org.openqa.selenium.NoSuchElementException e) {81 return false;82 }83 }84 85 /* assert admin text*/86 public boolean IsadmintextDisplayed() {87 try {88 // assert (driver.findElement(admintext).isDisplayed());89 // driver.findElement(admintext).click();90 return true;91 } catch (org.openqa.selenium.NoSuchElementException e) {92 return false;93 }94 }95 96 /* assert leave channel button */97 public boolean IsleavechannelButtonDisplayed() {98 try {99 // assert (driver.findElement(leaveChannelbutton).isDisplayed());100 // driver.findElement(leaveChannelbutton).click();101 return true;102 } catch (org.openqa.selenium.NoSuchElementException e) {103 return false;104 }105 }106 107 /* assert admin badge */108 @SuppressWarnings("unchecked")109 public boolean IsadminBadgeDisplayed() throws InterruptedException {110 try {111 // assert (driver.findElement(adminBadge).isDisplayed());112 Thread.sleep(2000);113 List <WebElement> admin = driver.findElements(adminBadge);114 System.out.println(admin.size());115 admin.get(0).click();116 return true;117 } catch (org.openqa.selenium.NoSuchElementException e) {118 return false;119 }120 }121 122 public boolean navigateToPrivateCanvas() {123 try {124 driver.findElement(swipePrivate).click();125 return true;126 } catch (org.openqa.selenium.NoSuchElementException e) {127 return false;128 }129 }130 public boolean IsSwipePreviousDisplayed() {131 try {132 driver.findElement(SwipePrevious).click();133 return true;134 } catch (org.openqa.selenium.NoSuchElementException e) {135 return false;136 }137 }138 139 /* verify noGiftsText button */140 public boolean IsnoGiftsTextDisplayed() {141 try {142 driver.findElement(By.name("noGiftsText")).click();143 return true;144 } catch (org.openqa.selenium.NoSuchElementException e) {145 return false;146 }147 }148 149 150 /* verify noGiftsText button */151 public boolean IsNoPublicItemTextDisplayed() throws InterruptedException {152 try {153 Thread.sleep(2000);154 driver.findElement(By.name("No public Item found")).click();155 return true;156 } catch (org.openqa.selenium.NoSuchElementException e) {157 return false;158 }159 }160 161 /* verify noGiftsText button */162 public boolean IsNoprivateItemTextDisplayed() throws InterruptedException {163 try {164 Thread.sleep(2000);165 driver.findElement(By.name("No private Item found")).click();166 return true;167 } catch (org.openqa.selenium.NoSuchElementException e) {168 return false;169 }170 }171 172 /* assert back button */173 public boolean IsbackarrowButtonDisplayed() {174 try {175 // assert (driver.findElement(backbutton).isDisplayed());176 driver.findElement(backbutton).click();177 return true;178 } catch (org.openqa.selenium.NoSuchElementException e) {179 return false;180 }181 }182 183 /* assert back button */184 public boolean IsmoreButtonDisplayed() {185 try {186 // assert (driver.findElement(morebutton).isDisplayed());187 driver.findElement(morebutton).click();188 return true;189 } catch (org.openqa.selenium.NoSuchElementException e) {190 return false;191 }192 }193 194 /* assert back button */195 public boolean navigatetoChannelInfopage() {196 try {197 // assert (driver.findElement(channelinfobutton).isDisplayed());198 driver.findElement(channelinfobutton).click();199 return true;200 } catch (org.openqa.selenium.NoSuchElementException e) {201 return false;202 }203 }204 205 /* assert Done button */206 public boolean IsDoneButtonDisplayed() throws InterruptedException {207 try {208 assert (driver.findElement(Donebutton).isDisplayed());209 driver.findElement(Donebutton).click();210 Thread.sleep(1000);211 return true;212 } catch (org.openqa.selenium.NoSuchElementException e) {213 return false;214 }215 }216 217 /* assert Invite Text */218 public boolean IsInvitetextDisplayed() {219 try {220 return driver.findElement(invite).isDisplayed();221 222 } catch (org.openqa.selenium.NoSuchElementException e) {223 return false;224 }225 }226 /* assert back button */227 public boolean IsImportfbfriendsDisplayed() {228 try {229 // assert (driver.findElement(importfriendsButton).isDisplayed());230 driver.findElement(importfriendsButton).click();231 return true;232 } catch (org.openqa.selenium.NoSuchElementException e) {233 return false;234 }235 }236 /* assert back button */237 public boolean EnterChannelName(String channelname) {238 try {239 // assert (driver.findElement(channelName).isDisplayed());240 driver.findElement(channelName).sendKeys(channelname);241 return true;242 } catch (org.openqa.selenium.NoSuchElementException e) {243 return false;244 }245 }246 @SuppressWarnings("unchecked")247 public boolean SelectContatcstoAddIntoChannel() {248 try {249// assert (driver.findElement(contactsList).isDisplayed());250 assert (driver.findElement(friendstext).isDisplayed());251 List<WebElement> contacts = driver.findElements(contactsList);252 contacts.get(0).click();253 contacts.get(1).click();254 return true;255 } catch (org.openqa.selenium.NoSuchElementException e) {256 return false;257 }258 }259 260 @SuppressWarnings("unchecked")261 public boolean AddContatcsIntoChannel() {262 try {263 // assert (driver.findElement(contactsList).isDisplayed());264 // assert (driver.findElement(friendstext).isDisplayed());265 List<WebElement> contacts = driver.findElements(contactsList);266 contacts.get(3).click();267 return true;268 } catch (org.openqa.selenium.NoSuchElementException e) {269 return false;270 }271 }272 273 274 /* assert back button */275 public boolean verfiyCreateChannelTitle(String channelname) {276 try {277 return driver.findElement(createChannel).isDisplayed();278 279 } catch (org.openqa.selenium.NoSuchElementException e) {280 return false;281 }282 }283 /* assert back button */284 public boolean clickOnNextButton() {285 try {286 // assert (driver.findElement(nextButton).isDisplayed());287 driver.findElement(nextButton).click();288 return true;289 } catch (org.openqa.selenium.NoSuchElementException e) {290 return false;291 }292 }293 @SuppressWarnings("unchecked")294 public boolean setchannelPicture() throws InterruptedException {295 try {296 driver.findElement(defaultGroup).click();297 List<WebElement> ActionSheetList = driver.findElements(ActionList);298 ActionSheetList.get(1).click();299 if (isOkayButtonDisplayed()) {300 driver.findElement(OKalert).click();301 Thread.sleep(3000);302 driver.findElement(captureButton).click();303 Thread.sleep(3000);304 driver.findElement(UsePhoto).click();305 Thread.sleep(10000);306 return true;307 } else {308 Thread.sleep(3000);309 driver.findElement(captureButton).click();310 Thread.sleep(3000);311 driver.findElement(UsePhoto).click();312 Thread.sleep(10000);313 return true;314 }315 } catch (org.openqa.selenium.NoSuchElementException e) {316 return false;317 }318 }319 @SuppressWarnings("unchecked")320 public boolean setchannelCoverPicture() throws InterruptedException {321 try {322 List<WebElement> edit=driver.findElements(editButton);323 edit.get(0).click();324 List<WebElement> ActionSheetList = driver.findElements(ActionList);325 ActionSheetList.get(1).click();326 if (isOkayButtonDisplayed()) {327 driver.findElement(OKalert).click();328 Thread.sleep(3000);329 driver.findElement(captureButton).click();330 Thread.sleep(3000);331 driver.findElement(UsePhoto).click();332 Thread.sleep(1000);333 driver.findElement(Donebutton).click();334 Thread.sleep(10000);335 336 return true;337 } else {338 Thread.sleep(3000);339 driver.findElement(captureButton).click();340 Thread.sleep(3000);341 driver.findElement(UsePhoto).click();342 Thread.sleep(1000);343 driver.findElement(Donebutton).click();344 Thread.sleep(10000);345 346 return true;347 }348 } catch (org.openqa.selenium.NoSuchElementException e) {349 return false;350 }351 }352 353 354 /* assert OK Button */355 public boolean isOkayButtonDisplayed() {356 try {357 return driver.findElement(OKButton).isDisplayed();358 } catch (org.openqa.selenium.NoSuchElementException e) {359 return false;360 }361 }362 @SuppressWarnings("unchecked")363 public boolean ClickOnRecentItemInList() throws InterruptedException {364 try {365 Thread.sleep(2000);366 System.out.println(driver.findElement(recentlist).getSize());367 List<WebElement> recent = driver.findElements(recentlist);368 recent.get(0).click();369 return true;370 } catch (org.openqa.selenium.NoSuchElementException e) {371 return false;372 }373 }374 375 /* assert Tab Bar */376 public boolean isTabBarDisplayed() {377 try {378 return driver.findElement(TabBar).isDisplayed();379 } catch (org.openqa.selenium.NoSuchElementException e) {380 return false;381 }382 }383 384 385 /* assert Tab Bar */386 @SuppressWarnings("unchecked")387 public boolean clickonRecentTab() {388 try {389 List<WebElement> tabbar = driver.findElements(TabBar);390 tabbar.get(1).click();391 return true;392 } catch (org.openqa.selenium.NoSuchElementException e) {393 return false;394 }395 }396 397 public boolean IsplusbuttonDisplayed() {398 try {399 // assert (driver.findElement(plusbutton).isDisplayed());400 driver.findElement(plusbutton).click();401 return true;402 } catch (org.openqa.selenium.NoSuchElementException e) {403 return false;404 }405 }406 public boolean clickonAddFriendsButton() {407 try {408 // assert (driver.findElement(AddFriends).isDisplayed());409 driver.findElement(AddFriends).click();410 return true;411 } catch (org.openqa.selenium.NoSuchElementException e) {412 return false;413 }414 }415 public boolean clickonCreateChannelButton() throws InterruptedException {416 try {417 // assert (driver.findElement(createChannel).isDisplayed());418 driver.findElement(createChannel).click();419 Thread.sleep(2000);420 return true;421 } catch (org.openqa.selenium.NoSuchElementException e) {422 return false;423 }424 }425}...

Full Screen

Full Screen

Source:Page_AddNewLead.java Github

copy

Full Screen

...13 public static WebElement displayFirstNameInputField() throws Exception14 {15 try {16 element = driver.findElement(properties.selectLocator("AddLead_firstName"));17 } catch (org.openqa.selenium.NoSuchElementException e) {18 e.printStackTrace();19 }20 return element;21 }22 23 public static WebElement displayLastNameInputField() throws Exception24 {25 try {26 element = driver.findElement(properties.selectLocator("AddLead_lastName"));27 } catch (org.openqa.selenium.NoSuchElementException e) {28 e.printStackTrace();29 }30 return element;31 }32 33 public static WebElement displayEmailInputField() throws Exception34 {35 try {36 element = driver.findElement(properties.selectLocator("AddLead_email"));37 } catch (org.openqa.selenium.NoSuchElementException e) {38 e.printStackTrace();39 }40 return element;41 }42 43 public static WebElement displayEmailExistsErrorMessage() throws Exception44 {45 try {46 element = driver.findElement(properties.selectLocator("AddLead_EmailExistsError"));47 } catch (org.openqa.selenium.NoSuchElementException e) {48 e.printStackTrace();49 }50 return element;51 }52 53 public static WebElement displayMobileInputField() throws Exception54 {55 try {56 element = driver.findElement(properties.selectLocator("AddLead_mobileNumber"));57 } catch (org.openqa.selenium.NoSuchElementException e) {58 e.printStackTrace();59 }60 return element;61 }62 63 public static WebElement displayMobileExistsErrorMessage() throws Exception64 {65 try {66 element = driver.findElement(properties.selectLocator("AddLead_MobileExistsError"));67 } catch (org.openqa.selenium.NoSuchElementException e) {68 e.printStackTrace();69 }70 return element;71 }72 73 public static WebElement displayQualificationInputField() throws Exception74 {75 try {76 element = driver.findElement(properties.selectLocator("AddLead_Qualification"));77 } catch (org.openqa.selenium.NoSuchElementException e) {78 e.printStackTrace();79 }80 return element;81 }82 83 public static WebElement displaySelectSeasonDropdown() throws Exception84 {85 try {86 WebDriverWait wait = new WebDriverWait(driver, 30);87 wait.until(ExpectedConditions.visibilityOfElementLocated(properties.selectLocator("AddLead_SelectSeason")));88 element = driver.findElement(properties.selectLocator("AddLead_SelectSeason"));89 } catch (org.openqa.selenium.NoSuchElementException e) {90 e.printStackTrace();91 }92 return element;93 }94 95 public static WebElement displaySelectSourceDropdown() throws Exception96 {97 try {98 element = driver.findElement(properties.selectLocator("AddLead_SelectSource"));99 } catch (org.openqa.selenium.NoSuchElementException e) {100 e.printStackTrace();101 }102 return element;103 }104 105 public static WebElement displaySelectChannelDropdown() throws Exception106 {107 try {108 element = driver.findElement(properties.selectLocator("AddLead_SelectChannel"));109 } catch (org.openqa.selenium.NoSuchElementException e) {110 e.printStackTrace();111 }112 return element;113 }114 115 public static WebElement displaySelectPriorityDropdown() throws Exception116 {117 try {118 element = driver.findElement(properties.selectLocator("AddLead_SelectPriority"));119 } catch (org.openqa.selenium.NoSuchElementException e) {120 e.printStackTrace();121 }122 return element;123 }124 125 public static WebElement displaySelectStatusDropdown() throws Exception126 {127 try {128 element = driver.findElement(properties.selectLocator("AddLead_SelectStatus"));129 } catch (org.openqa.selenium.NoSuchElementException e) {130 e.printStackTrace();131 }132 return element;133 }134 135 public static WebElement displaySelectReasonDropdown() throws Exception136 {137 try {138 element = driver.findElement(properties.selectLocator("AddLead_SelectReason"));139 } catch (org.openqa.selenium.NoSuchElementException e) {140 e.printStackTrace();141 }142 return element;143 }144 145 public static WebElement displaySelectReferredToDropdown() throws Exception146 {147 try {148 element = driver.findElement(properties.selectLocator("AddLead_SelectReferredTo"));149 } catch (org.openqa.selenium.NoSuchElementException e) {150 e.printStackTrace();151 }152 return element;153 }154 155 public static WebElement displaySelectEntity1Dropdown() throws Exception156 {157 try {158 element = driver.findElement(properties.selectLocator("AddLead_SelectEntity1"));159 } catch (org.openqa.selenium.NoSuchElementException e) {160 e.printStackTrace();161 }162 return element;163 }164 165 public static WebElement displaySelectEntity2Dropdown() throws Exception166 {167 try {168 element = driver.findElement(properties.selectLocator("AddLead_SelectEntity2"));169 } catch (org.openqa.selenium.NoSuchElementException e) {170 e.printStackTrace();171 }172 return element;173 }174 175 public static WebElement displaySelectEntity3Dropdown() throws Exception176 {177 try {178 element = driver.findElement(properties.selectLocator("AddLead_SelectEntity3"));179 } catch (org.openqa.selenium.NoSuchElementException e) {180 e.printStackTrace();181 }182 return element;183 }184 185 public static WebElement displaySelectEntity4Dropdown() throws Exception186 {187 try {188 element = driver.findElement(properties.selectLocator("AddLead_SelectEntity4"));189 } catch (org.openqa.selenium.NoSuchElementException e) {190 e.printStackTrace();191 }192 return element;193 }194 195 public static WebElement displaySelectBestTimeDropdown() throws Exception196 {197 try {198 element = driver.findElement(properties.selectLocator("AddLead_BestTime"));199 } catch (org.openqa.selenium.NoSuchElementException e) {200 e.printStackTrace();201 }202 return element;203 }204 205 public static WebElement displaySelectLeadQualifiedDropdown() throws Exception206 {207 try {208 element = driver.findElement(properties.selectLocator("AddLead_LeadQualified"));209 } catch (org.openqa.selenium.NoSuchElementException e) {210 e.printStackTrace();211 }212 return element;213 }214 215 public static WebElement displaySelectLeadContactableDropdown() throws Exception216 {217 try {218 element = driver.findElement(properties.selectLocator("AddLead_LeadContactable"));219 } catch (org.openqa.selenium.NoSuchElementException e) {220 e.printStackTrace();221 }222 return element;223 }224 225 public static WebElement displayMobileVerifiedDropdown() throws Exception226 {227 try {228 element = driver.findElement(properties.selectLocator("AddLead_MobileVerified"));229 } catch (org.openqa.selenium.NoSuchElementException e) {230 e.printStackTrace();231 }232 return element;233 }234 235 public static WebElement displayField1Dropdown() throws Exception236 {237 try {238 element = driver.findElement(properties.selectLocator("AddLead_Field1"));239 } catch (org.openqa.selenium.NoSuchElementException e) {240 e.printStackTrace();241 }242 return element;243 }244 245 public static WebElement displayField2Dropdown() throws Exception246 {247 try {248 element = driver.findElement(properties.selectLocator("AddLead_Field2"));249 } catch (org.openqa.selenium.NoSuchElementException e) {250 e.printStackTrace();251 }252 return element;253 }254 255 public static WebElement displayField3Dropdown() throws Exception256 {257 try {258 element = driver.findElement(properties.selectLocator("AddLead_Field3"));259 } catch (org.openqa.selenium.NoSuchElementException e) {260 e.printStackTrace();261 }262 return element;263 }264 265 public static WebElement displayField4Dropdown() throws Exception266 {267 try {268 element = driver.findElement(properties.selectLocator("AddLead_Field4"));269 } catch (org.openqa.selenium.NoSuchElementException e) {270 e.printStackTrace();271 }272 return element;273 }274 275 public static WebElement displayField5Dropdown() throws Exception276 {277 try {278 element = driver.findElement(properties.selectLocator("AddLead_Field5"));279 } catch (org.openqa.selenium.NoSuchElementException e) {280 e.printStackTrace();281 }282 return element;283 }284 285 public static WebElement displayCountryDropdown() throws Exception286 {287 try {288 element = driver.findElement(properties.selectLocator("AddLead_SelectCountry"));289 } catch (org.openqa.selenium.NoSuchElementException e) {290 e.printStackTrace();291 }292 return element;293 }294 295 public static WebElement displayStateDropdown() throws Exception296 {297 try {298 element = driver.findElement(properties.selectLocator("AddLead_SelectState"));299 } catch (org.openqa.selenium.NoSuchElementException e) {300 e.printStackTrace();301 }302 return element;303 }304 305 public static WebElement displayCityDropdown() throws Exception306 {307 try {308 element = driver.findElement(properties.selectLocator("AddLead_SelectCity"));309 } catch (org.openqa.selenium.NoSuchElementException e) {310 e.printStackTrace();311 }312 return element;313 }314 315 public static WebElement displayCommentInputField() throws Exception316 {317 try {318 element = driver.findElement(properties.selectLocator("AddLead_Comment"));319 } catch (org.openqa.selenium.NoSuchElementException e) {320 e.printStackTrace();321 }322 return element;323 }324 325 public static WebElement displayAddLeadButton()326 {327 try {328 element = driver.findElement(properties.selectLocator("AddLead_AddLeadButton"));329 } catch (Exception e) {330 e.printStackTrace();331 }332 return element; 333 }...

Full Screen

Full Screen

Source:multipleloginsteps.java Github

copy

Full Screen

...40 if (b==true) {41 String s1 = str.getText();42 System.out.println(s1); 43 }44 } catch (org.openqa.selenium.NoSuchElementException e) {45 System.out.println("Element is not found suspend");46 }47 Thread.sleep(4000); 48 try {49 WebElement str = driver.findElement(By.xpath("//*[@id=\"error\"]"));50 boolean b = str.isDisplayed();51 if (b==true) {52 String s1 = str.getText();53 System.out.println(s1); 54 }55 } catch (org.openqa.selenium.NoSuchElementException e) {56 System.out.println("Element is not found id error");57 }58 try {59 WebElement str = driver.findElement(By.xpath("(//*[@class=\"font12 bld padt10\"])[2]"));60 boolean b = str.isDisplayed();61 if (b==true) {62 String s1 = str.getText();63 System.out.println(s1); 64 }65 } catch (org.openqa.selenium.NoSuchElementException e) {66 System.out.println("Element is not found id mobile verification");67 }68 try {69 driver.findElement(By.xpath("//*[@class=\"linkb font13\"]")).click();70 } catch (org.openqa.selenium.NoSuchElementException e) {71 System.out.println("Element is not found logout");72 }73 74 }75 @When("user have to enter the login url two")76 public void user_have_to_enter_the_login_url_two() throws Throwable {77 waitingWeb();78 loadUrl("https://www.communitymatrimony.com/");79 Thread.sleep(4000); 80 }81 @When("user have to enter valid second {string} and password and {string}")82 public void user_have_to_enter_valid_second_and_password_and(String username, String status) throws Throwable {83 waitingWeb();84 driver.findElement(By.xpath("//*[@name='idEmail']")).sendKeys(username);85 WebElement pass = driver.findElement(By.xpath("//*[@id='password1']"));86 JavascriptExecutor j = (JavascriptExecutor) driver;87 j.executeScript("arguments[0].setAttribute('value','cbstest')", pass);88 System.out.println(username);89 System.out.println(status);90 driver.findElement(By.xpath("//*[@value='LOGIN']")).click();91 Thread.sleep(4000); 92 getScreenshot(driver, username);93 }94 @When("user have to click the submit button second")95 public void user_have_to_click_the_submit_button_second() throws Throwable {96 97 try {98 WebElement str = driver.findElement(By.xpath("//*[@class=\"nomsg mediumtxt pad10 \"]"));99 boolean b = str.isDisplayed();100 if (b==true) {101 String s1 = str.getText();102 System.out.println(s1); 103 }104 } catch (org.openqa.selenium.NoSuchElementException e) {105 System.out.println("Element is not found suspend");106 }107 Thread.sleep(4000); 108 try {109 WebElement str = driver.findElement(By.xpath("//*[@id=\"error\"]"));110 boolean b = str.isDisplayed();111 if (b==true) {112 String s1 = str.getText();113 System.out.println(s1); 114 }115 } catch (org.openqa.selenium.NoSuchElementException e) {116 System.out.println("Element is not found id error");117 }118 try {119 WebElement str = driver.findElement(By.xpath("(//*[@class=\"font12 bld padt10\"])[2]"));120 boolean b = str.isDisplayed();121 if (b==true) {122 String s1 = str.getText();123 System.out.println(s1); 124 }125 } catch (org.openqa.selenium.NoSuchElementException e) {126 System.out.println("Element is not found id mobile verification");127 }128 try {129 driver.findElement(By.xpath("//*[@class=\"linkb font13\"]")).click();130 } catch (org.openqa.selenium.NoSuchElementException e) {131 System.out.println("Element is not found logout");132 }133 }134 @When("user have to enter the login url third")135 public void user_have_to_enter_the_login_url_third() throws Throwable {136 loadUrl("https://www.agarwalmatrimony.com/");137 Thread.sleep(4000); 138 driver.findElement(By.xpath("//*[@id=\"loginbtn\"]")).click();139 }140 @When("user have to enter valid third {string} and password and {string}")141 public void user_have_to_enter_valid_third_and_password_and(String username, String status) throws Throwable {142 Thread.sleep(4000); 143 driver.findElement(By.xpath("//*[@id=\"a12\"]")).sendKeys(username);144 WebElement pass = driver.findElement(By.xpath("//*[@name=\"password\"]"));145 JavascriptExecutor js = (JavascriptExecutor) driver;146 js.executeScript("arguments[0].value='cbstest';", pass);147 System.out.println(username);148 System.out.println(status); 149 Thread.sleep(4000); 150 WebElement click1 = driver.findElement(By.xpath("//*[@value=\"Login\"]"));151 JavascriptExecutor executor = (JavascriptExecutor)driver;152 executor.executeScript("arguments[0].click();", click1);153 Thread.sleep(4000);154 getScreenshot(driver, username);155 }156 @When("user have to click the submit button third")157 public void user_have_to_click_the_submit_button_third() throws Throwable {158 159 try {160 WebElement str = driver.findElement(By.xpath("//*[@class=\"nomsg mediumtxt pad10 \"]"));161 boolean b = str.isDisplayed();162 if (b==true) {163 String s1 = str.getText();164 System.out.println(s1); 165 }166 } catch (org.openqa.selenium.NoSuchElementException e) {167 System.out.println("Element is not found suspend");168 }169 Thread.sleep(4000); 170 try {171 WebElement str = driver.findElement(By.xpath("//*[@id=\"error\"]"));172 boolean b = str.isDisplayed();173 if (b==true) {174 String s1 = str.getText();175 System.out.println(s1); 176 }177 } catch (org.openqa.selenium.NoSuchElementException e) {178 System.out.println("Element is not found id error");179 }180 try {181 WebElement str = driver.findElement(By.xpath("(//*[@class=\"font12 bld padt10\"])[2]"));182 boolean b = str.isDisplayed();183 if (b==true) {184 String s1 = str.getText();185 System.out.println(s1); 186 }187 } catch (org.openqa.selenium.NoSuchElementException e) {188 System.out.println("Element is not found id mobile verification");189 }190 try {191 driver.findElement(By.xpath("//*[@class=\"linkb font13\"]")).click();192 } catch (org.openqa.selenium.NoSuchElementException e) {193 System.out.println("Element is not found logout");194 }195 }196 @Then("user credentials")197 public void user_credentials() {198 199 }200}...

Full Screen

Full Screen

Source:Page_GlobalSearch.java Github

copy

Full Screen

...16 public static boolean displayGlobalSearchBar() throws Exception17 {18 try {19 visibleFlag = driver.findElement(properties.selectLocator("GLobal_SeachBar")).isDisplayed();20 } catch (org.openqa.selenium.NoSuchElementException e) {21 e.printStackTrace();22 }23 return visibleFlag;24 }25 public static WebElement displayLenseIcon() throws Exception26 {27 try {28 element = driver.findElement(properties.selectLocator("LenseIcon_GlobalSearchBar"));29 } catch (org.openqa.selenium.NoSuchElementException e) {30 e.printStackTrace();31 }32 return element;33 }34 public static WebElement displayGoButton() throws Exception35 {36 try {37 element = driver.findElement(properties.selectLocator("Go_button_globalSearchBar"));38 } catch (org.openqa.selenium.NoSuchElementException e) {39 e.printStackTrace();40 }41 return element;42 }43 public static WebElement displayPlaceHolder() throws Exception44 {45 try {46 element = driver.findElement(properties.selectLocator("Placeholder_GlobalSearchBar"));47 } catch (org.openqa.selenium.NoSuchElementException e) {48 e.printStackTrace();49 }50 return element;51 }52 53 public static WebElement displayResultPageText() throws Exception54 {55 try {56 Thread.sleep(2000);57 element = driver.findElement(properties.selectLocator("SearchValidator_HTMLElement"));58 } catch (org.openqa.selenium.NoSuchElementException e) {59 e.printStackTrace();60 }61 return element;62 }63 64 public static WebElement displaySuccessResult() throws Exception65 {66 try {67 element = driver.findElement(properties.selectLocator("GlobalSearch_SuccessResult"));68 } catch (org.openqa.selenium.NoSuchElementException e) {69 e.printStackTrace();70 }71 return element;72 }73 public static String getElementText(WebElement ele)74 {75 try {76 elementText = ele.getText();77 } catch (org.openqa.selenium.NoSuchElementException e) {78 }79 return elementText;80 }81 public static WebElement getSearchedString()82 {83 try {84 element = driver.findElement(By.xpath(".//span[contains(text(),'"+prospectEmail+"')]"));85 } catch (org.openqa.selenium.NoSuchElementException e) {86 e.printStackTrace();87 }88 return element;89 }90 91 public static WebElement knowErrorMessage() throws Exception92 {93 Thread.sleep(2000);94 if(getSearchedString().getText().contains(prospectEmail))95 {96 try {97 switchCounter=0;98 caseValues[switchCounter] =getSearchedString().getText();99 visibleFlag = true;100 } catch (org.openqa.selenium.NoSuchElementException e) {101 e.printStackTrace();102 }103 }104 else if(displayResultPageText().getText().contains("Oops"))105 {106 try {107 switchCounter=1;108 caseValues[switchCounter] = displayResultPageText().getText();109 visibleFlag = false;110 } catch (org.openqa.selenium.NoSuchElementException e) {111 e.printStackTrace();112 }113 }114 else115 {116 try {117 switchCounter=2;118 caseValues[switchCounter] = displayResultPageText().getText();119 visibleFlag = true;//As of now, we have considered result on NULL input as PASS case and hence flag is set to True120 } catch (org.openqa.selenium.NoSuchElementException e) {121 e.printStackTrace();122 }123 }124 return element;125 }126 127 public static boolean validateGlobalSearch(String validatorString) throws Exception128 { 129 helperString = Thread.currentThread().getStackTrace()[1].getMethodName(); 130 try 131 { 132 switch (switchCounter) 133 { 134 case 1:135 try 136 {137 System.out.println(caseValues[switchCounter]);138 HelperHand.getscreenshot(helperString); 139 Reporter.log("Screenshot is taken and stored at specified location successfully.", true); 140 Reporter.log("No results found for provided string.", true); 141 } catch (Exception e) {142 System.out.println("Exception Handled for No Result.");143 e.printStackTrace();144 }145 break;146 case 2: 147 try 148 {149 System.out.println(caseValues[switchCounter]);150 HelperHand.getscreenshot(helperString); 151 Reporter.log("Screenshot is taken and stored at specified location successfully.", true); 152 Reporter.log("User has not provided any string to search.", true); 153 } catch (Exception e) {154 System.out.println("Exception Handled for Null Result.");155 e.printStackTrace();156 }157 break;158 159 default:160 try {161 System.out.println("Result Found "+caseValues[switchCounter]);162 Reporter.log("Specified user details are successfully located in the system.", true); 163 HelperHand.getscreenshot(helperString); 164 Reporter.log("Screenshot is taken and stored at specified location successfully.", true);165 } catch (Exception e) {166 e.printStackTrace();167 }168 break;169 }170 } catch (org.openqa.selenium.NoSuchElementException e) 171 {172 System.out.println(e);173 }174 return visibleFlag;175 }176}...

Full Screen

Full Screen

Source:Page_AppFormPayment.java Github

copy

Full Screen

...17 try {18 WebDriverWait wait = new WebDriverWait(driver, 30);19 wait.until(ExpectedConditions.visibilityOfElementLocated(properties.selectLocator("AppFormPaymentPage_LoginLink")));20 element =driver.findElement(properties.selectLocator("AppFormPaymentPage_LoginLink"));21 } catch (org.openqa.selenium.NoSuchElementException e) {22 e.printStackTrace();23 }24 return element; 25 }26 27 public static void moveToLoginModal()28 {29 List<WebElement> iframeElements = driver.findElements(By.tagName("iframe"));30 System.out.println("The total number of iframes are " + iframeElements.size());31 driver.switchTo().frame("login-iframe");32 }33 public static WebElement displayLoginUsername() throws Exception34 {35 try {36 WebDriverWait wait = new WebDriverWait(driver, 30);37 wait.until(ExpectedConditions.visibilityOfElementLocated(properties.selectLocator("AppFormPaymentPage_LoginId")));38 element =driver.findElement(properties.selectLocator("AppFormPaymentPage_LoginId"));39 } catch (org.openqa.selenium.NoSuchElementException e) {40 e.printStackTrace();41 }42 return element; 43 }44 45 public static WebElement displayRequestOTPButton() throws Exception46 {47 try {48 element =driver.findElement(properties.selectLocator("AppFormPaymentPage_RequestOTPButton"));49 } catch (org.openqa.selenium.NoSuchElementException e) {50 e.printStackTrace();51 }52 return element; 53 }54 55 public static WebElement displayOTPInputField() throws Exception56 {57 try {58 element =driver.findElement(properties.selectLocator("AppFormPaymentPage_OTPInputField"));59 } catch (org.openqa.selenium.NoSuchElementException e) {60 e.printStackTrace();61 }62 return element; 63 }64 65 public static WebElement displayLoginButtonPaytmLoginWindow() throws Exception66 {67 try {68 element =driver.findElement(properties.selectLocator("AppFormPaymentPage_LoginButton"));69 } catch (org.openqa.selenium.NoSuchElementException e) {70 e.printStackTrace();71 }72 return element; 73 }74 75 public static WebElement displayAmountToBePaidOnPaymentPage() throws Exception76 {77 try {78 Thread.sleep(2000);79 element =driver.findElement(properties.selectLocator("AppFormPaymentPage_AmountToBePaid"));80 } catch (org.openqa.selenium.NoSuchElementException e) {81 e.printStackTrace();82 }83 return element; 84 }85 86 public static WebElement displayPayNowButtonOnPaymentPage() throws Exception87 {88 try {89 element =driver.findElement(properties.selectLocator("AppFormPaymentPage_PayNowButton"));90 } catch (org.openqa.selenium.NoSuchElementException e) {91 e.printStackTrace();92 }93 return element; 94 }95 96 public static WebElement displaySuccessulPaymentMessage() throws Exception97 {98 try {99 element =driver.findElement(properties.selectLocator("SuccessPaymentPage_Message"));100 } catch (org.openqa.selenium.NoSuchElementException e) {101 e.printStackTrace();102 }103 return element; 104 }105 106 public static WebElement displayPaymentModeSectionInSuccessMessage() throws Exception107 {108 try {109 element =driver.findElement(properties.selectLocator("SuccessPaymentPage_PaymentModeSection"));110 } catch (org.openqa.selenium.NoSuchElementException e) {111 e.printStackTrace();112 }113 return element; 114 }115 116 public static WebElement displayTranscnIdSectionInSuccessMessage() throws Exception117 {118 try {119 element =driver.findElement(properties.selectLocator("SuccessPaymentPage_TransactionIDSection"));120 } catch (org.openqa.selenium.NoSuchElementException e) {121 e.printStackTrace();122 }123 return element; 124 }125 126 public static WebElement displayAmountSectionInSuccessMessage() throws Exception127 {128 try {129 element =driver.findElement(properties.selectLocator("SuccessPaymentPage_AmountSection"));130 } catch (org.openqa.selenium.NoSuchElementException e) {131 e.printStackTrace();132 }133 return element; 134 }135 136 public static WebElement displayPaymentModeValueInSuccessMessage() throws Exception137 {138 try {139 element =driver.findElement(properties.selectLocator("SuccessPaymentPage_PaymentModeValue"));140 } catch (org.openqa.selenium.NoSuchElementException e) {141 e.printStackTrace();142 }143 return element; 144 }145 146 public static WebElement displayTranscnIdValueInSuccessMessage() throws Exception147 {148 try {149 element =driver.findElement(properties.selectLocator("SuccessPaymentPage_TransactionIDValue"));150 } catch (org.openqa.selenium.NoSuchElementException e) {151 e.printStackTrace();152 }153 return element; 154 }155 156 public static WebElement displayAmountValueInSuccessMessage() throws Exception157 {158 try {159 element =driver.findElement(properties.selectLocator("SuccessPaymentPage_AmountValue"));160 } catch (org.openqa.selenium.NoSuchElementException e) {161 e.printStackTrace();162 }163 return element; 164 }165}...

Full Screen

Full Screen

Source:Page_GenerateLeadApplicationForm.java Github

copy

Full Screen

...15 Thread.sleep(500);16 17 try {18 element = driver.findElement(properties.selectLocator("BasicInfo_FullName"));19 } catch (org.openqa.selenium.NoSuchElementException e) {20 e.printStackTrace();21 }22 return element;23 }24 25 public static WebElement displayMobileNumberInputField() throws Exception26 {27 try {28 element = driver.findElement(properties.selectLocator("BasicInfo_MobileNumber"));29 } catch (org.openqa.selenium.NoSuchElementException e) {30 e.printStackTrace();31 }32 return element;33 }34 35 public static WebElement displayEmailInputField() throws Exception36 {37 try {38 element = driver.findElement(properties.selectLocator("BasicInfo_Email"));39 } catch (org.openqa.selenium.NoSuchElementException e) {40 e.printStackTrace();41 }42 return element;43 }44 45 public static Select displayEntityDropDown() throws Exception46 {47 try {48 dropdown = new Select(driver.findElement(properties.selectLocator("BasicInfo_EntityDropdown")));49 } catch (org.openqa.selenium.NoSuchElementException e) {50 e.printStackTrace();51 }52 return dropdown;53 }54 55 public static WebElement displayEntityDropDown1() throws Exception56 {57 try {58 element = driver.findElement(properties.selectLocator("BasicInfo_EntityDropdown"));59 } catch (org.openqa.selenium.NoSuchElementException e) {60 e.printStackTrace();61 }62 return element;63 }64 65 public static WebElement displaySubmitButton() throws Exception66 {67 try {68 element = driver.findElement(properties.selectLocator("BasicInfo_SubmitButton"));69 } catch (org.openqa.selenium.NoSuchElementException e) {70 e.printStackTrace();71 }72 return element;73 }74 75 public static WebElement displaySuccessRegMessage() throws Exception76 {77 try {78 element = driver.findElement(properties.selectLocator("BasicInfo_RegistrationMessage"));79 } catch (org.openqa.selenium.NoSuchElementException e) {80 e.printStackTrace();81 }82 return element;83 }84 85 public static WebElement displaySuccessInstructionMessage() throws Exception86 {87 try {88 element = driver.findElement(properties.selectLocator("BasicInfo_InstructionMessage"));89 } catch (org.openqa.selenium.NoSuchElementException e) {90 e.printStackTrace();91 }92 return element;93 }94}...

Full Screen

Full Screen

Source:FluentWaitConcept.java Github

copy

Full Screen

1package seleniumSessions;2import java.time.Duration;3import java.util.NoSuchElementException;4import org.openqa.selenium.By;5import org.openqa.selenium.StaleElementReferenceException;6import org.openqa.selenium.WebDriver;7import org.openqa.selenium.WebElement;8import org.openqa.selenium.chrome.ChromeDriver;9import org.openqa.selenium.support.ui.ExpectedConditions;10import org.openqa.selenium.support.ui.FluentWait;11import org.openqa.selenium.support.ui.Wait;12import org.openqa.selenium.support.ui.WebDriverWait;13import io.github.bonigarcia.wdm.WebDriverManager;14public class FluentWaitConcept {15 public static WebDriver driver;16 17 public static void main(String[] args) {18 19 WebDriverManager.chromedriver().setup();20 driver = new ChromeDriver();21 22 driver.get("https://demo.opencart.com/index.php?route=account/login");23 24 By emailId = By.id("input-email1");25 By password = By.id("input-password");26 27// Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)28// .withTimeout(Duration.ofSeconds(10))29// .pollingEvery(Duration.ofSeconds(2))30// .ignoring(NoSuchElementException.class)31// .ignoring(StaleElementReferenceException.class);32//33// wait.until(ExpectedConditions.visibilityOfElementLocated(emailId)).sendKeys("test@123");34 35 waitForElementVisibleWithFluentWait(emailId, 10, 2).sendKeys("testing@123");36 driver.findElement(password).sendKeys("123");37 38 }39 40 public static WebElement waitForElementVisibleWithFluentWait(By locator, int duration, int pollingTime) {41 Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)42 .withTimeout(Duration.ofSeconds(duration))43 .pollingEvery(Duration.ofSeconds(pollingTime))44 .ignoring(NoSuchElementException.class)45 .ignoring(StaleElementReferenceException.class)46 .withMessage(locator + " is not found within the given time ....");47 return wait.until(ExpectedConditions.visibilityOfElementLocated(locator));48 }49 50 public static WebElement waitForElementPresenceWithWait(By locator, int duration, int pollingTime) {51 52 WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(duration));53 54 wait.pollingEvery(Duration.ofSeconds(pollingTime))55 .ignoring(NoSuchElementException.class)56 .ignoring(StaleElementReferenceException.class)57 .withMessage(locator + " is not found within the given time ....");58 59 return wait.until(ExpectedConditions.visibilityOfElementLocated(locator));60 61 62 }63}...

Full Screen

Full Screen

NoSuchElementException

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.NoSuchElementException;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.chrome.ChromeDriver;4import org.openqa.selenium.chrome.ChromeOptions;5import org.openqa.selenium.firefox.FirefoxDriver;6import org.openqa.selenium.firefox.FirefoxOptions;7import org.openqa.selenium.ie.InternetExplorerDriver;8import org.openqa.selenium.ie.InternetExplorerOptions;9import org.openqa.selenium.remote.DesiredCapabilities;10import org.openqa.selenium.remote.RemoteWebDriver;11import java.net.MalformedURLException;12import java.net.URL;13import java.util.HashMap;14import java.util.Map;15import java.util.concurrent.TimeUnit;16public class Test1 {17 public static void main(String[] args) throws MalformedURLException, InterruptedException {18 DesiredCapabilities caps = new DesiredCapabilities();19 caps.setCapability("browserName", "chrome");20 caps.setCapability("browserVersion", "92.0");21 caps.setCapability("platformName", "windows");22 caps.setCapability("platformVersion", "10");23 caps.setCapability("selenoid:options", new HashMap<String, Object>() {{24 put("enableVNC", true);25 put("enableVideo", true);26 }});27 driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);28 driver.manage().window().maximize();29 driver.findElement(By.name("q")).sendKeys("Selenide");30 try {31 } catch (NoSuchElementException e) {32 System.out.println("Element not found");33 }34 driver.quit();35 }36}37 (Session info: chrome=92.0.4515.131)38try {39 } catch (NoSuchElementException e) {40 System.out.println("Element not found");41 }42try {43 driver.findElement(By

Full Screen

Full Screen

NoSuchElementException

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.*;2import org.openqa.selenium.firefox.*;3import org.openqa.selenium.support.ui.*;4import org.openqa.selenium.support.ui.ExpectedConditions;5import org.openqa.selenium.support.ui.WebDriverWait;6import org.openqa.selenium.By;7import org.openqa.selenium.WebDriver;8import org.openqa.selenium.WebElement;9import org.openqa.selenium.chrome.ChromeDriver;10import org.openqa.selenium.support.ui.Select;11import org.openqa.selenium.support.ui.ExpectedConditions;12import org.openqa.selenium.support.ui.WebDriverWait;13import java.util.List;14import java.util.concurrent.TimeUnit;15import org.openqa.selenium.JavascriptExecutor;16import org.openqa.selenium.Keys;17import org.openqa.selenium.interactions.Actions;18import org.openqa.selenium.NoSuchElementException;19import org.openqa.selenium.firefox.FirefoxDriver;20import org.openqa.selenium.firefox.FirefoxProfile;21import org.openqa.selenium.firefox.internal.ProfilesIni;22import org.openqa.selenium.support.ui.Select;23import org.openqa.selenium.By;24import org.openqa.selenium.WebDriver;25import org.openqa.selenium.WebElement;26import org.openqa.selenium.chrome.ChromeDriver;27import org.openqa.selenium.support.ui.Select;28import org.openqa.selenium.support.ui.ExpectedConditions;29import org.openqa.selenium.support.ui.WebDriverWait;30import java.util.List;31import java.util.concurrent.TimeUnit;32import org.openqa.selenium.JavascriptExecutor;33import org.openqa.selenium.Keys;34import org.openqa.selenium.interactions.Actions;35import org.openqa.selenium.NoSuchElementException;36import org.openqa.selenium.firefox.FirefoxDriver;37import org.openqa.selenium.firefox.FirefoxProfile;38import org.openqa.selenium.firefox.internal.ProfilesIni;39import org.openqa.selenium.support.ui.Select;40import org.openqa.selenium.By;41import org.openqa.selenium.WebDriver;42import org.openqa.selenium.WebElement;43import org.openqa.selenium.chrome.ChromeDriver;44import org.openqa.selenium.support.ui.Select;45import org.openqa.selenium.support.ui.ExpectedConditions;46import org.openqa.selenium.support.ui.WebDriverWait;47import java.util.List;48import java.util.concurrent.TimeUnit;49import org.openqa.selenium.JavascriptExecutor;50import org.openqa.selenium.Keys;51import org.openqa.selenium.interactions.Actions;52import org.openqa.selenium.NoSuchElementException;53import org.openqa.selenium.firefox.FirefoxDriver;54import org.openqa.selenium.firefox.FirefoxProfile;55import org.openqa.selenium.firefox.internal.ProfilesIni;56import org.openqa.selenium.support.ui.Select;57import org.openqa.selenium.By;58import org.openqa.selenium.WebDriver;59import org.openqa.selenium.WebElement;60import org.openqa.selenium.chrome.ChromeDriver;61import org.openqa.selenium.support.ui.Select;62import org.openqa.selenium.support.ui.ExpectedConditions;63import org.openqa.selenium.support.ui.WebDriverWait;64import java.util.List;65import java.util.concurrent.TimeUnit;

Full Screen

Full Screen

NoSuchElementException

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.NoSuchElementException;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.chrome.ChromeDriver;4import org.openqa.selenium.firefox.FirefoxDriver;5import org.openqa.selenium.remote.DesiredCapabilities;6public class NoSuchElementExceptionExample {7 public static void main(String[] args) {8 System.setProperty("webdriver.chrome.driver","C:\\Program Files\\Selenium\\chromedriver.exe");9 WebDriver driver = new ChromeDriver();10 String expectedTitle = "Welcome: Mercury Tours";11 String actualTitle = "";12 driver.get(baseUrl);13 actualTitle = driver.getTitle();14 if (actualTitle.contentEquals(expectedTitle)){15 System.out.println("Test Passed!");16 } else {17 System.out.println("Test Failed");18 }19 driver.close();20 System.exit(0);21 }22}

Full Screen

Full Screen

NoSuchElementException

Using AI Code Generation

copy

Full Screen

1import org.openqa.selenium.NoSuchElementException;2import org.openqa.selenium.WebDriver;3import org.openqa.selenium.WebElement;4import org.openqa.selenium.By;5import org.openqa.selenium.chrome.ChromeDriver;6import org.openqa.selenium.interactions.Actions;7import org.openqa.selenium.Keys;8import java.util.concurrent.TimeUnit;9public class Test {10public static void main(String[] args) {11System.setProperty("webdriver.chrome.driver", "C:\\Users\\Acer\\Desktop\\Selenium\\chromedriver.exe");12WebDriver driver = new ChromeDriver();13driver.manage().window().maximize();14Actions actions = new Actions(driver);15WebElement element = driver.findElement(By.name("q"));16actions.moveToElement(element).perform();17actions.moveToElement(element1).perform();18actions.moveToElement(element2).perform();19actions.moveToElement(element3).perform();20actions.moveToElement(element4).perform();

Full Screen

Full Screen

NoSuchElementException

Using AI Code Generation

copy

Full Screen

1package com.test;2import org.openqa.selenium.By;3import org.openqa.selenium.NoSuchElementException;4import org.openqa.selenium.WebDriver;5import org.openqa.selenium.chrome.ChromeDriver;6public class NoSuchElementExceptionDemo {7 public static void main(String[] args) {8 System.setProperty("webdriver.chrome.driver", "C:\\Users\\saurabh123\\Downloads\\chromedriver_win32\\chromedriver.exe");9 WebDriver driver = new ChromeDriver();10 driver.manage().window().maximize();11 try {12 System.out.println("Element Found");13 }14 catch(NoSuchElementException e) {15 System.out.println("Element not found");16 }17 driver.close();18 }19}20 (Session info: chrome=71.0.3578.98)21 (Driver info: chromedriver=2.41.578700 (9e21b3e3e3c1b4e1f4d4f4d4c2b4d4e1e3c2b2f2),platform=Windows NT 10.0.17134 x86_64)22at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)23at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)24at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)25at java.lang.reflect.Constructor.newInstance(Constructor.java:423)26at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)27at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)28at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)29at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)30at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)31at org.openqa.selenium.remote.RemoteWebDriver.execute(R

Full Screen

Full Screen

NoSuchElementException

Using AI Code Generation

copy

Full Screen

1WebDriver driver = new ChromeDriver();2try {3 WebElement element = driver.findElement(By.name("q"));4 element = driver.findElement(By.className("gsfi"));5 element = driver.findElement(By.id("lst-ib"));6 element = driver.findElement(By.tagName("input"));7 element = driver.findElement(By.linkText("Gmail"));8 element = driver.findElement(By.partialLinkText("Gma"));9 element = driver.findElement(By.cssSelector("input.gsfi"));10 driver.quit();11} catch (NoSuchElementException e) {12 System.out.println("Element not found");13}14WebDriver driver = new ChromeDriver();15try {16 WebElement element = driver.findElement(By.name("q"));17 element = driver.findElement(By.className("gsfi"));18 element = driver.findElement(By.id("lst-ib"));19 element = driver.findElement(By.tagName("input"));20 element = driver.findElement(By.linkText("Gmail"));21 element = driver.findElement(By.partialLinkText("Gma"));22 element = driver.findElement(By.cssSelector("input.gsfi"));23 driver.quit();24} catch (StaleElementReferenceException e) {25 System.out.println("Element not found");26}

Full Screen

Full Screen
copy
1@FindBy(name="q")2private WebElement searchField;34@FindBy(name="btnG")5private WebElement searchButton;6
Full Screen
copy
1@FindBy(xpath = "//*[@class = 'stackoverflow']")2private WebElement question;3
Full Screen

Selenium 4 Tutorial:

LambdaTest’s Selenium 4 tutorial is covering every aspects of Selenium 4 testing with examples and best practices. Here you will learn basics, such as how to upgrade from Selenium 3 to Selenium 4, to some advanced concepts, such as Relative locators and Selenium Grid 4 for Distributed testing. Also will learn new features of Selenium 4, such as capturing screenshots of specific elements, opening a new tab or window on the browser, and new protocol adoptions.

Chapters:

  1. Upgrading From Selenium 3 To Selenium 4?: In this chapter, learn in detail how to update Selenium 3 to Selenium 4 for Java binding. Also, learn how to upgrade while using different build tools such as Maven or Gradle and get comprehensive guidance for upgrading Selenium.

  2. What’s New In Selenium 4 & What’s Being Deprecated? : Get all information about new implementations in Selenium 4, such as W3S protocol adaption, Optimized Selenium Grid, and Enhanced Selenium IDE. Also, learn what is deprecated for Selenium 4, such as DesiredCapabilites and FindsBy methods, etc.

  3. Selenium 4 With Python: Selenium supports all major languages, such as Python, C#, Ruby, and JavaScript. In this chapter, learn how to install Selenium 4 for Python and the features of Python in Selenium 4, such as Relative locators, Browser manipulation, and Chrom DevTool protocol.

  4. Selenium 4 Is Now W3C Compliant: JSON Wireframe protocol is retiring from Selenium 4, and they are adopting W3C protocol to learn in detail about the advantages and impact of these changes.

  5. How To Use Selenium 4 Relative Locator? : Selenium 4 came with new features such as Relative Locators that allow constructing locators with reference and easily located constructors nearby. Get to know its different use cases with examples.

  6. Selenium Grid 4 Tutorial For Distributed Testing: Selenium Grid 4 allows you to perform tests over different browsers, OS, and device combinations. It also enables parallel execution browser testing, reads up on various features of Selenium Grid 4 and how to download it, and runs a test on Selenium Grid 4 with best practices.

  7. Selenium Video Tutorials: Binge on video tutorials on Selenium by industry experts to get step-by-step direction from automating basic to complex test scenarios with Selenium.

Selenium 101 certifications:

LambdaTest also provides certification for Selenium testing to accelerate your career in Selenium automation testing.

Run Selenium automation tests on LambdaTest cloud grid

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

Most used methods in NoSuchElementException

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful