Search in sources :

Example 86 with TimeoutException

use of org.openqa.selenium.TimeoutException in project chrome_page_performance_sqlite_java by sergueik.

the class ChromePagePerformanceUtilTest method testnavigateBaseURL.

@Ignore
@Test
public void testnavigateBaseURL() {
    System.err.println("base URL loading test");
    try {
        driver.get(baseURL);
        // Wait for page url to update
        WebDriverWait wait = new WebDriverWait(driver, 20);
        wait.pollingEvery(500, TimeUnit.MILLISECONDS);
        ExpectedCondition<Boolean> urlChange = driver -> driver.getCurrentUrl().matches(String.format("^%s.*", baseURL));
        wait.until(urlChange);
        System.err.println("Current  URL: " + driver.getCurrentUrl());
    } catch (TimeoutException e) {
    }
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver) LogEntry(org.openqa.selenium.logging.LogEntry) BeforeClass(org.junit.BeforeClass) WebDriver(org.openqa.selenium.WebDriver) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) HashMap(java.util.HashMap) CoreMatchers.notNullValue(org.hamcrest.CoreMatchers.notNullValue) Level(java.util.logging.Level) ChromeOptions(org.openqa.selenium.chrome.ChromeOptions) CapabilityType(org.openqa.selenium.remote.CapabilityType) JSONObject(org.json.JSONObject) LoggingPreferences(org.openqa.selenium.logging.LoggingPreferences) LogType(org.openqa.selenium.logging.LogType) Map(java.util.Map) After(org.junit.After) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Before(org.junit.Before) LogEntries(org.openqa.selenium.logging.LogEntries) AfterClass(org.junit.AfterClass) Iterator(java.util.Iterator) IOException(java.io.IOException) Test(org.junit.Test) DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) File(java.io.File) TimeUnit(java.util.concurrent.TimeUnit) TimeoutException(org.openqa.selenium.TimeoutException) Ignore(org.junit.Ignore) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) TimeoutException(org.openqa.selenium.TimeoutException) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 87 with TimeoutException

use of org.openqa.selenium.TimeoutException in project selenium_java by sergueik.

the class NgIgnoreSyncIntegrationTest method testNonAngular.

// @Ignore
@Test
public void testNonAngular() {
    if (isCIBuild) {
        return;
    }
    ngDriver.navigate().to("http://www.google.com");
    try {
        long startTime = System.currentTimeMillis();
        ngDriver.waitForAngular();
        // exception: window.angular is undefined
        long estimatedTime = System.currentTimeMillis() - startTime;
        System.err.println("waitForAngular: " + estimatedTime);
        NgWebElement element = ngDriver.findElement(By.cssSelector("input#gs_htif0"));
        element.getAttribute("id");
    } catch (TimeoutException exception) {
        System.err.println("TimeoutException thrown:");
        rootCauseMessage = ExceptionUtils.getRootCauseMessage(exception);
        System.err.println("Exception thrown: " + rootCauseMessage);
        return;
    }
}
Also used : NgWebElement(com.github.sergueik.jprotractor.NgWebElement) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.junit.Test)

Example 88 with TimeoutException

use of org.openqa.selenium.TimeoutException in project selenium_java by sergueik.

the class AngularAndWebDriverTest method waitTests.

@SuppressWarnings("deprecation")
@Test(enabled = true)
public void waitTests() {
    driver.get("http://juliemr.github.io/protractor-demo/");
    ngWebDriver.waitForAngularRequestsToFinish();
    driver.findElement(ByAngular.model("first")).sendKeys("40");
    driver.findElement(ByAngular.model("second")).sendKeys("2");
    driver.findElement(ByAngular.buttonText("Go!")).click();
    By locator = ByAngular.exactBinding("latest");
    WebDriverWait wait = new WebDriverWait(driver, 120);
    wait.pollingEvery(1000, TimeUnit.MILLISECONDS);
    try {
        // should work
        wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
        System.err.println("After wait");
    } catch (TimeoutException e) {
        System.err.println("Timeout Exception");
    } catch (Exception e) {
        System.err.println("Exception (ignored) " + e.toString());
    }
    try {
        wait.until(new ExpectedCondition<Boolean>() {

            @Override
            public Boolean apply(WebDriver d) {
                WebElement e = d.findElement(locator);
                Boolean result = e.isDisplayed();
                System.err.println("In apply: Element = " + e.getAttribute("outerHTML") + "\nresult = " + result.toString());
                return result;
            }
        });
    } catch (Exception e) {
        System.err.println("Exception: " + e.toString());
    // throw new RuntimeException(e);
    }
    try {
        Thread.sleep(10000);
    } catch (Exception e) {
    }
}
Also used : FluentWebDriver(org.seleniumhq.selenium.fluent.FluentWebDriver) WebDriver(org.openqa.selenium.WebDriver) FluentBy(org.seleniumhq.selenium.fluent.FluentBy) By(org.openqa.selenium.By) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement) FluentWebElement(org.seleniumhq.selenium.fluent.FluentWebElement) TimeoutException(org.openqa.selenium.TimeoutException) WebDriverException(org.openqa.selenium.WebDriverException) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException) Test(org.testng.annotations.Test)

Example 89 with TimeoutException

use of org.openqa.selenium.TimeoutException in project blueocean-plugin by jenkinsci.

the class GitCreationPage method createPipelinePW.

public MultiBranchPipeline createPipelinePW(SSEClientRule sseCLient, String pipelineName, String url, String user, String pass) throws IOException {
    jobApi.deletePipeline(pipelineName);
    dashboardPage.clickNewPipelineBtn();
    clickGitCreationOption();
    wait.until(By.cssSelector("div.text-repository-url input")).sendKeys(url);
    wait.until(By.xpath("//*[contains(text(), 'Jenkins needs a user credential')]"));
    boolean createCredentialFound = false;
    try {
        wait.until(By.xpath("//*[contains(text(), 'Create new credential')]"));
        createCredentialFound = true;
    } catch (NoSuchElementException | TimeoutException | AcceptanceTestException e) {
    // ignore it
    }
    if (createCredentialFound) {
        driver.findElement(By.xpath("//*[contains(text(),'Create new credential')]")).click();
    }
    wait.until(By.cssSelector("div.text-username input")).sendKeys(user);
    wait.until(By.cssSelector("div.text-password input")).sendKeys(pass);
    wait.until(By.cssSelector(".button-create-credential")).click();
    wait.until(By.xpath("//*[contains(text(), 'Use existing credential')]"));
    logger.info("Created user/pass credential");
    wait.until(By.cssSelector(".button-create-pipeline")).click();
    logger.info("Click create pipeline button");
    MultiBranchPipeline pipeline = null;
    try {
        pipeline = multiBranchPipelineFactory.pipeline(pipelineName);
        String urlPart = pipeline.getUrl() + "/activity";
        logger.info("waiting for urlPart: " + urlPart);
        wait.until(ExpectedConditions.urlContains(urlPart), 30000);
        sseCLient.untilEvents(SSEEvents.activityComplete(pipeline.getName()));
        driver.navigate().refresh();
        pipeline.getActivityPage().checkUrl();
        return pipeline;
    } finally {
        deleteQuietly(pipeline, pipelineName);
    }
}
Also used : AcceptanceTestException(io.blueocean.ath.AcceptanceTestException) MultiBranchPipeline(io.blueocean.ath.model.MultiBranchPipeline) NoSuchElementException(org.openqa.selenium.NoSuchElementException) TimeoutException(org.openqa.selenium.TimeoutException)

Example 90 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) PARTICIPANT_ITEM(org.jitsi.meet.test.pageobjects.web.ParticipantsPane.PARTICIPANT_ITEM) 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)249 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)109 WebElement (org.openqa.selenium.WebElement)87 NoSuchElementException (org.openqa.selenium.NoSuchElementException)52 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)40 WebDriver (org.openqa.selenium.WebDriver)39 WebDriverException (org.openqa.selenium.WebDriverException)39 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)25 By (org.openqa.selenium.By)22 Test (org.testng.annotations.Test)20 Element (com.coveros.selenified.element.Element)17 IOException (java.io.IOException)17 AnswerItem (org.cerberus.util.answer.AnswerItem)17 Dimension (org.openqa.selenium.Dimension)14 Point (org.openqa.selenium.Point)14 Constants (com.coveros.selenified.utilities.Constants)13