use of org.openqa.selenium.interactions.Actions in project rstudio by rstudio.
the class RConsoleInteraction method testPopupCompletion.
@Test
public void testPopupCompletion() {
// Test invoking autocomplete
List<WebElement> elements = driver_.findElements(By.id(ElementIds.getElementId(ElementIds.POPUP_COMPLETIONS)));
assertEquals(elements.size(), 0);
Actions popup = new Actions(driver_);
popup.sendKeys(Keys.ESCAPE);
popup.sendKeys("print");
popup.sendKeys(Keys.TAB);
popup.perform();
(new WebDriverWait(driver_, 5)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
List<WebElement> elements = driver_.findElements(By.id(ElementIds.getElementId(ElementIds.POPUP_COMPLETIONS)));
return elements.size() > 0;
}
});
// Test cancelling autocomplete once invoked
Actions close = new Actions(driver_);
close.sendKeys(Keys.ESCAPE).perform();
(new WebDriverWait(driver_, 5)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
List<WebElement> elements = driver_.findElements(By.id(ElementIds.getElementId(ElementIds.POPUP_COMPLETIONS)));
return elements.size() == 0;
}
});
}
use of org.openqa.selenium.interactions.Actions in project rstudio by rstudio.
the class SourceInteraction method createAndSourceRFile.
@Test
public void createAndSourceRFile() {
createRFile();
// Type some code into the file. Note that the matching brace is auto
// completed.
Actions a = new Actions(driver_);
a.sendKeys("f <- function() {" + Keys.ENTER);
a.sendKeys(Keys.TAB + "42");
a.perform();
// Source the entire file
WebElement sourceMenuEntry = MenuNavigator.getMenuItem(driver_, "Code", "Source");
sourceMenuEntry.click();
// Wait for the console to contain the string "source"
ConsoleTestUtils.waitForConsoleContainsText(driver_, "source(");
closeUnsavedRFile();
}
use of org.openqa.selenium.interactions.Actions in project rstudio by rstudio.
the class WorkbenchTests method testWorkbenchPersistance.
@Test
public void testWorkbenchPersistance() throws Exception {
clearWorkspace();
// Add a variable to the workspace
(new Actions(driver_)).sendKeys(Keys.ESCAPE + "selenium <- function() { 42 }" + Keys.ENTER).perform();
// Save the workspace
WebElement saveItem = MenuNavigator.getMenuItem(driver_, "Session", "Save Workspace As...");
saveItem.click();
WebElement saveDialog = DialogTestUtils.waitForModalToAppear(driver_);
DialogTestUtils.waitForFocusedInput(driver_, saveDialog);
File tempFile = File.createTempFile("rstudio-selenium-workspace-", ".RData");
String workspaceFilePath = tempFile.getAbsolutePath();
tempFile.delete();
(new Actions(driver_)).sendKeys(workspaceFilePath + Keys.ENTER).perform();
DialogTestUtils.waitForModalToDisappear(driver_);
// Clear the workspace and load it again
clearWorkspace();
WebElement loadItem = MenuNavigator.getMenuItem(driver_, "Session", "Load Workspace...");
loadItem.click();
WebElement loadDialog = DialogTestUtils.waitForModalToAppear(driver_);
DialogTestUtils.waitForFocusedInput(driver_, loadDialog);
(new Actions(driver_)).sendKeys(workspaceFilePath + Keys.ENTER).perform();
DialogTestUtils.waitForModalToDisappear(driver_);
// List the workspace and see if the variable is present
ConsoleTestUtils.beginConsoleInteraction(driver_);
(new Actions(driver_)).sendKeys(Keys.chord(Keys.CONTROL + "l")).sendKeys(Keys.ESCAPE + "ls()" + Keys.ENTER).perform();
ConsoleTestUtils.waitForConsoleContainsText(driver_, "selenium");
}
use of org.openqa.selenium.interactions.Actions in project rstudio by rstudio.
the class WorkbenchTests method clearWorkspace.
private void clearWorkspace() {
// Clear out the workspace and make sure it's clear
WebElement menuItem = MenuNavigator.getMenuItem(driver_, "Session", "Clear Workspace...");
menuItem.click();
DialogTestUtils.respondToModalDialog(driver_, "Yes");
ConsoleTestUtils.beginConsoleInteraction(driver_);
(new Actions(driver_)).sendKeys(Keys.ESCAPE + "ls()" + Keys.ENTER).perform();
ConsoleTestUtils.waitForConsoleContainsText(driver_, "character(0)");
}
use of org.openqa.selenium.interactions.Actions in project ats-framework by Axway.
the class MobileCheckBox method check.
/**
* Check the check box
*/
@Override
@PublicAtsApi
public void check() {
new MobileElementState(this).waitToBecomeExisting();
try {
WebElement checkboxElement = MobileElementFinder.findElement(appiumDriver, this);
if (!checkboxElement.isSelected()) {
if (appiumDriver instanceof AndroidDriver) {
// checkboxElement.click(); // throwing exception (on Android) with message: Element is not clickable at point (x,y). Other element would receive the click
new Actions(appiumDriver).moveToElement(checkboxElement).click().perform();
} else {
checkboxElement.click();
}
}
} catch (Exception se) {
throw new MobileOperationException(this, "check", se);
}
UiEngineUtilities.sleep();
}
Aggregations