Search in sources :

Example 71 with NoSuchElementException

use of org.openqa.selenium.NoSuchElementException in project devonfw-testing by devonfw.

the class DriverExtention method waitForElementVisible.

public WebElement waitForElementVisible(final By by) throws BFElementNotFoundException {
    BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
    long startTime = System.currentTimeMillis();
    WebElement element = null;
    try {
        element = webDriverWait().until((Function<? super WebDriver, WebElement>) ExpectedConditions.visibilityOfElementLocated(by));
    } catch (TimeoutException | NoSuchElementException e) {
        boolean isTimeout = true;
        throw new BFElementNotFoundException(by, isTimeout, BasePage.EXPLICITYWAITTIMER);
    }
    BFLogger.logTime(startTime, "waitForElementVisible()", by.toString());
    return element;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Function(java.util.function.Function) BFElementNotFoundException(com.capgemini.mrchecker.selenium.core.exceptions.BFElementNotFoundException) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 72 with NoSuchElementException

use of org.openqa.selenium.NoSuchElementException in project devonfw-testing by devonfw.

the class DriverExtention method waitForPageLoaded.

public void waitForPageLoaded() throws BFElementNotFoundException {
    long startTime = System.currentTimeMillis();
    final String jsVariable = "return document.readyState";
    ExpectedCondition<Boolean> expectation = new ExpectedCondition<Boolean>() {

        public Boolean apply(WebDriver driver) {
            return ((JavascriptExecutor) driver).executeScript(jsVariable).equals("complete");
        }
    };
    int progressBarWaitTimer = BasePage.PROGRESSBARWAITTIMER;
    WebDriverWait wait = webDriverWait(progressBarWaitTimer);
    try {
        wait.until((Function<? super WebDriver, Boolean>) expectation);
    } catch (TimeoutException | NoSuchElementException e) {
        boolean isTimeout = true;
        throw new BFElementNotFoundException(By.cssSelector(jsVariable), isTimeout, progressBarWaitTimer);
    }
    BFLogger.logTime(startTime, "waitForPageLoaded");
}
Also used : WebDriver(org.openqa.selenium.WebDriver) BFElementNotFoundException(com.capgemini.mrchecker.selenium.core.exceptions.BFElementNotFoundException) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 73 with NoSuchElementException

use of org.openqa.selenium.NoSuchElementException in project devonfw-testing by devonfw.

the class DriverExtention method findElementQuietly.

@SuppressWarnings("deprecation")
public WebElement findElementQuietly(WebElement elementToSearchIn, By by) {
    BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
    WebElement element = null;
    try {
        if (null == elementToSearchIn) {
            element = getDriver().findElement(by);
        } else {
            element = new NewRemoteWebElement(elementToSearchIn).findElement(by);
        }
    } catch (NoSuchElementException e) {
        BFLogger.logError("Element [" + by.toString() + "] was not found in given element");
    }
    return element;
}
Also used : WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 74 with NoSuchElementException

use of org.openqa.selenium.NoSuchElementException in project devonfw-testing by devonfw.

the class NewFirefoxDriver method findElement.

/**
 * @deprecated As of release 1.0.0, replaced by {@link #findElementDynamic(By)()}
 */
@Deprecated
@Override
public WebElement findElement(By by) throws BFElementNotFoundException {
    BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
    WebElement elementFromDriver = null;
    try {
        elementFromDriver = super.findElement(by);
    } catch (NoSuchElementException e) {
        throw new BFElementNotFoundException(by);
    }
    return new NewRemoteWebElement(elementFromDriver);
}
Also used : BFElementNotFoundException(com.capgemini.mrchecker.selenium.core.exceptions.BFElementNotFoundException) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 75 with NoSuchElementException

use of org.openqa.selenium.NoSuchElementException in project rubia-forums by flashboss.

the class CreatePost method createPost.

public static String createPost(WebDriver driver, PostBean post) {
    WebElement home = driver.findElement(linkText(HOME_LINK));
    home.click();
    WebElement forumEl = driver.findElement(linkText(post.getTopic().getForum().getName()));
    forumEl.click();
    sleepThread();
    WebElement topicSubject = driver.findElement(linkText(post.getTopic().getSubject()));
    topicSubject.click();
    sleepThread();
    try {
        WebElement bodyText = driver.findElement(className(REPLY_POST_BUTTON)).findElement(xpath("a[2]"));
        bodyText.click();
    } catch (NoSuchElementException e) {
        return LOCKED;
    }
    sleepThread();
    WebElement bodyInput = driver.findElement(cssSelector("div.ql-editor"));
    bodyInput.sendKeys(post.getMessage().getText());
    addAttachments(driver, post);
    WebElement operationButton = driver.findElement(id(SUBMIT_BUTTON));
    operationButton.click();
    WebElement resultCreatePost = driver.findElement(xpath("//td[contains(@class,forumpostcontent)]/p[contains(text(),'" + post.getMessage().getText() + "')]"));
    String updatedPost = resultCreatePost.getText();
    return updatedPost;
}
Also used : WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Aggregations

NoSuchElementException (org.openqa.selenium.NoSuchElementException)361 WebElement (org.openqa.selenium.WebElement)199 Test (org.junit.Test)60 TimeoutException (org.openqa.selenium.TimeoutException)50 Test (org.testng.annotations.Test)50 WebDriverException (org.openqa.selenium.WebDriverException)38 MessageEvent (org.cerberus.engine.entity.MessageEvent)34 WebDriver (org.openqa.selenium.WebDriver)27 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)26 MockitoTest (com.seleniumtests.MockitoTest)23 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)23 Select (org.openqa.selenium.support.ui.Select)21 Test (org.junit.jupiter.api.Test)20 By (org.openqa.selenium.By)20 AnswerItem (org.cerberus.util.answer.AnswerItem)18 ArrayList (java.util.ArrayList)13 StaleElementReferenceException (org.openqa.selenium.StaleElementReferenceException)13 CerberusEventException (org.cerberus.exception.CerberusEventException)11 Actions (org.openqa.selenium.interactions.Actions)11 AndroidElement (io.appium.java_client.android.AndroidElement)10