How to use addInfoForNoSuchElementException method of com.paypal.selion.platform.html.AbstractElement class

Best SeLion code snippet using com.paypal.selion.platform.html.AbstractElement.addInfoForNoSuchElementException

Source:AbstractElement.java Github

copy

Full Screen

...98 }99 } catch (ParentNotFoundException p) {100 throw p;101 } catch (NoSuchElementException n) {102 addInfoForNoSuchElementException(n);103 }104 return foundElement;105 }106 /**107 * Instance method used to call static class method locateElements.108 *109 * @return the list of web elements found by locator110 */111 public List<WebElement> getElements() {112 List<WebElement> foundElements = null;113 try {114 if (parent == null) {115 foundElements = HtmlElementUtils.locateElements(getLocator());116 } else {117 foundElements = parent.locateChildElements(getLocator());118 }119 } catch (NoSuchElementException n) {120 addInfoForNoSuchElementException(n);121 }122 return foundElements;123 }124 /**125 * A utility method to provide additional information to the user when a NoSuchElementException is thrown.126 *127 * @param cause128 * The associated cause for the exception.129 */130 private void addInfoForNoSuchElementException(NoSuchElementException cause) {131 if (parent == null) {132 throw cause;133 }134 BasicPageImpl page = this.parent.getCurrentPage();135 if (page == null) {136 throw cause;137 }138 String resolvedPageName = page.getClass().getSimpleName();139 // Find if page exists: This part is reached after a valid page instance is assigned to page variable. So its140 // safe to proceed!141 boolean pageExists = page.hasExpectedPageTitle();142 if (!pageExists) {143 // ParentType: Page does not exist: Sending the cause along with it144 throw new ParentNotFoundException(resolvedPageName + " : With Page Title {" + page.getActualPageTitle()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful