Search in sources :

Example 66 with Actions

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;
        }
    });
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Actions(org.openqa.selenium.interactions.Actions) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) List(java.util.List) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Example 67 with Actions

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();
}
Also used : Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement) Test(org.junit.Test)

Example 68 with Actions

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");
}
Also used : Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement) File(java.io.File) Test(org.junit.Test)

Example 69 with Actions

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)");
}
Also used : Actions(org.openqa.selenium.interactions.Actions) WebElement(org.openqa.selenium.WebElement)

Example 70 with Actions

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();
}
Also used : Actions(org.openqa.selenium.interactions.Actions) MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) AndroidDriver(io.appium.java_client.android.AndroidDriver) WebElement(org.openqa.selenium.WebElement) MobileOperationException(com.axway.ats.uiengine.exceptions.MobileOperationException) VerificationException(com.axway.ats.uiengine.exceptions.VerificationException) MobileElementState(com.axway.ats.uiengine.utilities.mobile.MobileElementState) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

Actions (org.openqa.selenium.interactions.Actions)116 WebElement (org.openqa.selenium.WebElement)72 WebDriver (org.openqa.selenium.WebDriver)26 Test (org.junit.Test)21 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)18 PublicAtsApi (com.axway.ats.common.PublicAtsApi)16 Action (org.openqa.selenium.interactions.Action)10 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)9 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)6 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)4 List (java.util.List)3 MobileOperationException (com.axway.ats.uiengine.exceptions.MobileOperationException)2 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)2 MobileElementState (com.axway.ats.uiengine.utilities.mobile.MobileElementState)2 AndroidDriver (io.appium.java_client.android.AndroidDriver)2 File (java.io.File)2 DecimalFormat (java.text.DecimalFormat)2 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)2 SystemException (com.github.bordertech.wcomponents.util.SystemException)1 VerticalLayoutElement (com.vaadin.testbench.elements.VerticalLayoutElement)1