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();
}
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();
}
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();
}
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");
}
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;
}
}
Aggregations