Example usage for org.openqa.selenium NotFoundException NotFoundException

List of usage examples for org.openqa.selenium NotFoundException NotFoundException

Introduction

In this page you can find the example usage for org.openqa.selenium NotFoundException NotFoundException.

Prototype

public NotFoundException(Throwable cause) 

Source Link

Usage

From source file:com.github.seleniumpm.pagemodel.webelements.Element.java

License:Apache License

public Element present() throws NotFoundException {
    if (!sel.isPresent(locator))
        throw new NotFoundException("locator='" + locator + "' was not found!");
    return this;
}

From source file:com.github.seleniumpm.Selenium10.java

License:Apache License

public Selenium waitForPresent(Object locator, long waitTime) throws NotFoundException {
    long currentTime = System.nanoTime();
    long endTime = currentTime + TimeUnit.MILLISECONDS.toNanos(elementWaitTime);

    while (currentTime <= endTime) {
        if (isPresent(locator))
            return this;
        try {//from   w  w  w  .  ja v a  2 s .  c  o m
            Thread.sleep(sleepTimeInMilis);
        } catch (InterruptedException ie) {
            throw new NotFoundException("An InterruptedException occured!");
        }
        currentTime = System.nanoTime();
    }
    throw new NotFoundException(locator + "was not found in " + elementWaitTime + "ms!");
}

From source file:com.github.seleniumpm.Selenium10.java

License:Apache License

public Selenium waitForVisible(Object locator, long waitTime) throws NotFoundException {
    long currentTime = System.nanoTime();
    long endTime = currentTime + TimeUnit.MILLISECONDS.toNanos(elementWaitTime);

    while (currentTime <= endTime) {
        if (isVisible(locator))
            return this;
        try {/* ww  w  .  j a va2 s  .c  o  m*/
            Thread.sleep(sleepTimeInMilis);
        } catch (InterruptedException ie) {
            throw new NotFoundException("An InterruptedException occured!");
        }
        currentTime = System.nanoTime();
    }
    throw new NotFoundException(locator + "was not visible in " + elementWaitTime + "ms!");
}

From source file:com.github.seleniumpm.webelements.Element.java

License:Apache License

public Element present() throws NotFoundException {
    if (!isPresent())
        throw new NotFoundException("locator='" + locator + "' was not found!");
    return this;
}

From source file:com.googlecode.ounit.test.moodle21.QuizPage.java

License:Open Source License

@Override
public int getGrade() {
    for (String s : gradeDiv.getText().split(" ")) {
        try {//  ww  w.ja v a  2s.  co m
            return (int) Double.parseDouble(s);
        } catch (Exception e) {
            // Keep trying
        }
    }
    throw new NotFoundException("Could not find marks in page");
}

From source file:com.hotwire.test.steps.application.ApplicationModelMobileWebApp.java

License:Open Source License

@Override
public void verifyHotwireBranded3rdPartyMobileCarSite() {
    String currentURL = getWebdriverInstance().getCurrentUrl();
    if (!currentURL.contains("cartrawler")) {
        throw new NotFoundException("Was expecting to be on cartrawler site but was on " + currentURL);
    }// w  w  w  . j a v  a 2 s.com
}

From source file:com.hotwire.test.steps.application.ApplicationModelMobileWebApp.java

License:Open Source License

@Override
public void verifySite() {
    String currentURL = getWebdriverInstance().getCurrentUrl();
    if (!currentURL.contains("/mobile")) {
        throw new NotFoundException("Was expecting to be on mobile site but was on " + currentURL);
    }// w  w w. j  av  a  2  s .c  o  m

}

From source file:com.mgmtp.jfunk.web.util.WebDriverTool.java

License:Apache License

/**
 * Opens a new window and switches to it. The window to switch to is determined by diffing
 * the given {@code existingWindowHandles} with the current ones. The difference must be
 * exactly one window handle which is then used to switch to.
 *
 * @param openCommand//ww w . j ava  2s  .c  om
 *            logic for opening the new window
 * @param timeoutSeconds
 *            the timeout in seconds to wait for the new window to open
 * @return the handle of the window that opened the new window
 */
public String openNewWindow(final Runnable openCommand, final long timeoutSeconds) {
    String oldHandle = webDriver.getWindowHandle();
    final Set<String> existingWindowHandles = webDriver.getWindowHandles();

    openCommand.run();

    Function<WebDriver, String> function = new Function<WebDriver, String>() {
        @Override
        public String apply(final WebDriver input) {
            Set<String> newWindowHandles = webDriver.getWindowHandles();
            SetView<String> newWindows = difference(newWindowHandles, existingWindowHandles);
            if (newWindows.isEmpty()) {
                throw new NotFoundException("No new window found.");
            }
            return getOnlyElement(newWindows);
        }

        @Override
        public String toString() {
            return "new window to open";
        }
    };

    String newHandle = waitFor(function, timeoutSeconds);
    webDriver.switchTo().window(newHandle);
    return oldHandle;
}

From source file:jdave.webdriver.elements.DropDownChoice.java

License:Apache License

public String getSelected() {
    Map<String, WebElement> optionsMap = optionsMap(webElement.findElements(By.tagName("option")));
    for (WebElement webElements : optionsMap.values()) {
        if (webElements.getAttribute("selected") != null) {
            return webElements.getText();
        }// w w w . j a v a  2s  .  co m
    }
    throw new NotFoundException("No selection found from DropDownChoice");
}

From source file:okw.gui.adapter.selenium.SeURL.java

License:Open Source License

public ArrayList<String> getTooltip() {
    Boolean bOK = false;/*  w  w w  . j a v  a2s.c  o m*/
    ArrayList<String> lvLsReturn = new ArrayList<String>();

    MyLogger.LogFunctionStartDebug("GetTooltip");

    try {
        // TODO: SeURL.GetTooltip: Ausnahme-Meldung auslagern
        throw new NotFoundException("GetTooltip not supported by SeURL-class!");
    } finally {
        if (bOK) {
            MyLogger.LogFunctionEndDebug(lvLsReturn);
        } else {
            MyLogger.LogFunctionEndDebug();
        }
    }
    // return lvLsReturn;
}