Search in sources :

Example 21 with WebElement

use of org.openqa.selenium.WebElement in project rstudio by rstudio.

the class RConsoleInteraction method testPlotGeneration.

@Test
public void testPlotGeneration() {
    ConsoleTestUtils.resumeConsoleInteraction(driver_);
    Actions plotCars = new Actions(driver_);
    plotCars.sendKeys(Keys.ESCAPE + "plot(cars)" + Keys.ENTER);
    plotCars.perform();
    // Wait for the Plot window to activate
    final WebElement plotWindow = (new WebDriverWait(driver_, 5)).until(ExpectedConditions.presenceOfElementLocated(By.id(ElementIds.getElementId(ElementIds.PLOT_IMAGE_FRAME))));
    // Wait for a plot to appear in the window
    Assert.assertEquals(plotWindow.getTagName(), "iframe");
    driver_.switchTo().frame(plotWindow);
    (new WebDriverWait(driver_, 5)).until(ExpectedConditions.presenceOfElementLocated(By.tagName("img")));
    // Switch back to document context
    driver_.switchTo().defaultContent();
}
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 22 with WebElement

use of org.openqa.selenium.WebElement in project rstudio by rstudio.

the class RConsoleInteraction method testInvokeHelp.

@Test
public void testInvokeHelp() {
    ConsoleTestUtils.resumeConsoleInteraction(driver_);
    Actions help = new Actions(driver_);
    help.sendKeys(Keys.ESCAPE + "?lapply" + Keys.ENTER);
    help.perform();
    // Wait for the Help window to activate
    final WebElement helpWindow = (new WebDriverWait(driver_, 5)).until(ExpectedConditions.presenceOfElementLocated(By.id(ElementIds.getElementId(ElementIds.HELP_FRAME))));
    // Wait for help to appear in the window
    Assert.assertEquals(helpWindow.getTagName(), "iframe");
    driver_.switchTo().frame(helpWindow);
    (new WebDriverWait(driver_, 5)).until(ExpectedConditions.textToBePresentInElement(By.tagName("body"), "lapply"));
    // Switch back to document context
    driver_.switchTo().defaultContent();
}
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 23 with WebElement

use of org.openqa.selenium.WebElement 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 24 with WebElement

use of org.openqa.selenium.WebElement in project rstudio by rstudio.

the class SourceInteraction method closeUnsavedRFile.

private void closeUnsavedRFile() {
    WebElement closeEntry = MenuNavigator.getMenuItem(driver_, "File", "Close");
    closeEntry.click();
    DialogTestUtils.respondToModalDialog(driver_, "Don't Save");
}
Also used : WebElement(org.openqa.selenium.WebElement)

Example 25 with WebElement

use of org.openqa.selenium.WebElement in project java.webdriver by sayems.

the class MultiSelect method getFirstSelectedIndex.

public Integer getFirstSelectedIndex(Supplier<By> by) {
    try {
        Select select = new Select(findElement(by));
        List<WebElement> options = select.getOptions();
        if (!options.isEmpty()) {
            return options.indexOf(select.getFirstSelectedOption());
        }
        return null;
    } catch (NoSuchElementException e) {
        return null;
    }
}
Also used : Select(org.openqa.selenium.support.ui.Select) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Aggregations

WebElement (org.openqa.selenium.WebElement)520 Test (org.junit.Test)96 WebDriver (org.openqa.selenium.WebDriver)85 PublicAtsApi (com.axway.ats.common.PublicAtsApi)57 Actions (org.openqa.selenium.interactions.Actions)55 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)46 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)40 By (org.openqa.selenium.By)36 URL (java.net.URL)35 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)34 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)30 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)21 NoSuchElementException (org.openqa.selenium.NoSuchElementException)21 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)19 ArrayList (java.util.ArrayList)18 SeleniumOperationException (com.axway.ats.uiengine.exceptions.SeleniumOperationException)13 Select (org.openqa.selenium.support.ui.Select)13 TimeoutException (org.openqa.selenium.TimeoutException)12 VisualEditorPageObject (com.wikia.webdriver.pageobjectsfactory.pageobject.visualeditor.VisualEditorPageObject)11 List (java.util.List)10