Search in sources :

Example 26 with TimeoutException

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

the class DriverExtention method waitForElement.

public WebElement waitForElement(final By by) throws BFElementNotFoundException {
    BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
    long startTime = System.currentTimeMillis();
    WebElement element = null;
    FluentWait<WebDriver> wait = new FluentWait<WebDriver>(driver);
    wait.pollingEvery(250, TimeUnit.MILLISECONDS);
    wait.withTimeout(2, TimeUnit.MINUTES);
    try {
        element = webDriverWait().until(new Function<WebDriver, WebElement>() {

            @Override
            public WebElement apply(WebDriver driver) {
                return driver.findElement(by);
            }
        });
    } catch (TimeoutException | NoSuchElementException e) {
        boolean isTimeout = true;
        throw new BFElementNotFoundException(by, isTimeout, BasePage.EXPLICITYWAITTIMER);
    }
    BFLogger.logTime(startTime, "waitForElement()", by.toString());
    return element;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Function(java.util.function.Function) FluentWait(org.openqa.selenium.support.ui.FluentWait) BFElementNotFoundException(com.capgemini.mrchecker.selenium.core.exceptions.BFElementNotFoundException) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 27 with TimeoutException

use of org.openqa.selenium.TimeoutException 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 28 with TimeoutException

use of org.openqa.selenium.TimeoutException 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 29 with TimeoutException

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

the class DriverExtention method findElementsDynamic.

public List<WebElement> findElementsDynamic(By by, int timeOut) throws BFElementNotFoundException {
    BasePage.getAnalytics().sendMethodEvent(BasePage.analitycsCategoryName);
    long startTime = System.currentTimeMillis();
    WebDriverWait wait = webDriverWait(timeOut);
    List<WebElement> elements = new ArrayList<WebElement>();
    try {
        elements = wait.until((Function<? super WebDriver, List<WebElement>>) ExpectedConditions.presenceOfAllElementsLocatedBy(by));
    } catch (BFElementNotFoundException | TimeoutException e) {
        throw new BFElementNotFoundException(by, true, timeOut);
    }
    if (elements.isEmpty()) {
        BFLogger.logError("Not found element : " + by.toString() + ".");
    }
    BFLogger.logTime(startTime, "findElementDynamics()", by.toString());
    return elements;
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Function(java.util.function.Function) BFElementNotFoundException(com.capgemini.mrchecker.selenium.core.exceptions.BFElementNotFoundException) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ArrayList(java.util.ArrayList) WebElement(org.openqa.selenium.WebElement) TimeoutException(org.openqa.selenium.TimeoutException)

Example 30 with TimeoutException

use of org.openqa.selenium.TimeoutException in project jitsi-meet-torture by jitsi.

the class BreakoutRoomsTest method testCollapseRoom.

@Test(dependsOnMethods = { "testSendParticipantToRoom" })
public void testCollapseRoom() {
    BreakoutRoomsList roomsList = participant1.getBreakoutRoomsList();
    boolean visible = true;
    // there should be one breakout room with one participant
    TestUtils.waitForCondition(participant1.getDriver(), 5, (ExpectedCondition<Boolean>) d -> {
        List<BreakoutRoomsList.BreakoutRoom> rooms = roomsList.getRooms();
        return rooms.size() == 1 && rooms.get(0).getParticipantsCount() == 1;
    });
    // get id of the breakout room participant
    String participant2Id = participant1.getDriver().findElement(By.id(BREAKOUT_ROOMS_LIST_ID)).findElements(By.className(LIST_ITEM_CONTAINER)).stream().filter(el -> !el.getAttribute("id").equals("")).findFirst().map(el -> el.getAttribute("id")).orElse("");
    participant2Id = participant2Id.substring(PARTICIPANT_ITEM.length());
    // check participant 2 is visible in the pane initially
    TestUtils.waitForDisplayedElementByID(participant1.getDriver(), PARTICIPANT_ITEM + participant2Id, 5);
    // collapse the first
    roomsList.getRooms().get(0).collapse();
    try {
        TestUtils.waitForDisplayedElementByID(participant1.getDriver(), PARTICIPANT_ITEM + participant2Id, 3);
    } catch (TimeoutException e) {
        visible = false;
    }
    assertFalse(visible, "Participant 2 should no longer be visible");
    // the collapsed room should still have one participant
    TestUtils.waitForCondition(participant1.getDriver(), 5, (ExpectedCondition<Boolean>) d -> roomsList.getRooms().get(0).getParticipantsCount() == 1);
}
Also used : SkipException(org.testng.SkipException) java.util.logging(java.util.logging) java.util(java.util) WebTestBase(org.jitsi.meet.test.web.WebTestBase) By(org.openqa.selenium.By) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) BreakoutRoomsList(org.jitsi.meet.test.pageobjects.web.BreakoutRoomsList) Test(org.testng.annotations.Test) TestUtils(org.jitsi.meet.test.util.TestUtils) WebParticipant(org.jitsi.meet.test.web.WebParticipant) TimeoutException(org.openqa.selenium.TimeoutException) Assert(org.testng.Assert) ParticipantsPane(org.jitsi.meet.test.pageobjects.web.ParticipantsPane) JitsiMeetUrl(org.jitsi.meet.test.base.JitsiMeetUrl) BreakoutRoomsList(org.jitsi.meet.test.pageobjects.web.BreakoutRoomsList) BreakoutRoomsList(org.jitsi.meet.test.pageobjects.web.BreakoutRoomsList) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.testng.annotations.Test)

Aggregations

TimeoutException (org.openqa.selenium.TimeoutException)238 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)101 WebElement (org.openqa.selenium.WebElement)82 NoSuchElementException (org.openqa.selenium.NoSuchElementException)49 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)40 WebDriver (org.openqa.selenium.WebDriver)39 WebDriverException (org.openqa.selenium.WebDriverException)38 AutomatorException (com.testsigma.automator.exceptions.AutomatorException)31 MessageEvent (org.cerberus.engine.entity.MessageEvent)27 ExpectedConditions (org.openqa.selenium.support.ui.ExpectedConditions)27 Reporter (com.coveros.selenified.utilities.Reporter)26 Test (org.junit.Test)24 By (org.openqa.selenium.By)22 Test (org.testng.annotations.Test)20 Element (com.coveros.selenified.element.Element)17 AnswerItem (org.cerberus.util.answer.AnswerItem)17 IOException (java.io.IOException)16 Dimension (org.openqa.selenium.Dimension)14 Point (org.openqa.selenium.Point)14 Constants (com.coveros.selenified.utilities.Constants)13