Search in sources :

Example 26 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project rstudio by rstudio.

the class SourceInteraction method findAndReplace.

@Test
public void findAndReplace() {
    createRFile();
    // Type some code into the file
    String preReplaceCode = "foo <- 'bar'";
    Actions a = new Actions(driver_);
    a.sendKeys(preReplaceCode + Keys.ENTER);
    a.perform();
    // Find the ACE editor instance that the code appears in. (CONSIDER: 
    // This is not the best way to find the code editor instance.)
    WebElement editor = null;
    List<WebElement> editors = driver_.findElements(By.className("ace_content"));
    for (WebElement e : editors) {
        if (e.getText().contains(preReplaceCode)) {
            editor = e;
            break;
        }
    }
    Assert.assertNotNull(editor);
    // Invoke find and replace
    WebElement findMenuEntry = MenuNavigator.getMenuItem(driver_, "Edit", "Find...");
    findMenuEntry.click();
    // Wait for the find and replace panel to come up
    (new WebDriverWait(driver_, 2)).until(ExpectedConditions.presenceOfElementLocated(By.id(ElementIds.getElementId(ElementIds.FIND_REPLACE_BAR))));
    // Type the text and the text to be replaced (replace 'bar' with 'foo')
    Actions rep = new Actions(driver_);
    rep.sendKeys("bar" + Keys.TAB + "foo" + Keys.ENTER);
    rep.perform();
    DialogTestUtils.respondToModalDialog(driver_, "OK");
    Actions dismiss = new Actions(driver_);
    dismiss.sendKeys(Keys.ESCAPE);
    dismiss.perform();
    // Ensure that the source has been updated
    Assert.assertTrue(editor.getText().contains("foo <- 'foo'"));
    closeUnsavedRFile();
}
Also used : Actions(org.openqa.selenium.interactions.Actions) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Example 27 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project page-factory-2 by sbtqa.

the class TagWebDriver method closeAllAlerts.

private static void closeAllAlerts() {
    try {
        LOG.info("Checking any alert opened");
        WebDriverWait alertAwaiter = new WebDriverWait(webDriver, 2);
        alertAwaiter.until(ExpectedConditions.alertIsPresent());
        Alert alert = webDriver.switchTo().alert();
        LOG.info("Got an alert: '{}'. Closing it...", alert.getText());
        alert.dismiss();
    } catch (WebDriverException e) {
        LOG.debug("No alert opened. Closing webdriver...", e);
    }
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) Alert(org.openqa.selenium.Alert) WebDriverException(org.openqa.selenium.WebDriverException)

Example 28 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project android by nextcloud.

the class Actions method login.

public static FileListView login(String url, String user, String password, Boolean isTrusted, AndroidDriver driver) throws InterruptedException {
    LoginForm loginForm = new LoginForm(driver);
    CertificatePopUp certificatePopUp = loginForm.typeHostUrl(url);
    if (!isTrusted) {
        WebDriverWait wait = new WebDriverWait(driver, 30);
        // and it doesn't appear again
        try {
            wait.until(ExpectedConditions.visibilityOf(certificatePopUp.getOkButtonElement()));
            // we need to repaint the screen
            // because of some element are misplaced
            driver.rotate(ScreenOrientation.LANDSCAPE);
            driver.rotate(ScreenOrientation.PORTRAIT);
            certificatePopUp.clickOnOkButton();
        } catch (NoSuchElementException e) {
        }
    }
    loginForm.typeUserName(user);
    loginForm.typePassword(password);
    // TODO. Assert related to check the connection?
    return loginForm.clickOnConnectButton();
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) CertificatePopUp(com.owncloud.android.test.ui.models.CertificatePopUp) LoginForm(com.owncloud.android.test.ui.models.LoginForm) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 29 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project android by nextcloud.

the class Common method setUpCommonDriver.

protected AndroidDriver setUpCommonDriver() throws Exception {
    File rootPath = new File(System.getProperty("user.dir"));
    File appDir = new File(rootPath, "src/test/resources");
    File app = new File(appDir, "ownCloud.apk");
    DesiredCapabilities capabilities = new DesiredCapabilities();
    capabilities.setCapability("platformName", "Android");
    capabilities.setCapability("deviceName", "test");
    capabilities.setCapability("app", app.getAbsolutePath());
    capabilities.setCapability("appPackage", "com.owncloud.android");
    capabilities.setCapability("appActivity", ".ui.activity.FileDisplayActivity");
    capabilities.setCapability("appWaitActivity", ".authentication.AuthenticatorActivity");
    driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    driver.manage().timeouts().implicitlyWait(waitingTime, TimeUnit.SECONDS);
    wait = new WebDriverWait(driver, waitingTime, 50);
    return driver;
}
Also used : DesiredCapabilities(org.openqa.selenium.remote.DesiredCapabilities) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) AndroidDriver(io.appium.java_client.android.AndroidDriver) File(java.io.File) URL(java.net.URL)

Example 30 with WebDriverWait

use of org.openqa.selenium.support.ui.WebDriverWait in project iTest by e-government-ua.

the class TemplatePage method ecpAuthorization.

public void ecpAuthorization() {
    new WebDriverWait(driver, 10).until(ExpectedConditions.elementToBeClickable(buttonAuthMock));
    //        cm.click(driver, buttonAuthMock);
    cm.click(driver, buttonBankID);
    cm.clickXpath(driver, "//li[1]/a//span[contains(.,'ПриватБанк')]");
    cm.click(driver, driver.findElement(By.xpath(".//legend[text()='ЕЦП']")));
    // находим элемент <input type="file">
    WebElement element = driver.findElement(By.xpath("//button[contains(@onclick,'startClientSign()')]"));
    new WebDriverWait(driver, 5).until(ExpectedConditions.elementToBeClickable(element));
    element.sendKeys("src/test/resources/files/Key-6.dat");
}
Also used : WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement)

Aggregations

WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)556 WebElement (org.openqa.selenium.WebElement)173 WebDriver (org.openqa.selenium.WebDriver)139 Test (org.junit.Test)88 By (org.openqa.selenium.By)58 Actions (org.openqa.selenium.interactions.Actions)54 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)47 TimeoutException (org.openqa.selenium.TimeoutException)41 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)38 IOException (java.io.IOException)30 List (java.util.List)27 Wait (org.openqa.selenium.support.ui.Wait)25 BeforeClass (org.junit.BeforeClass)24 NgWebDriver (com.github.sergueik.jprotractor.NgWebDriver)21 ArrayList (java.util.ArrayList)21 WebDriverException (org.openqa.selenium.WebDriverException)21 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)21 Dimension (org.openqa.selenium.Dimension)20 File (java.io.File)18 NoSuchElementException (org.openqa.selenium.NoSuchElementException)16