Search in sources :

Example 11 with Actions

use of org.openqa.selenium.interactions.Actions 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 12 with Actions

use of org.openqa.selenium.interactions.Actions 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 13 with Actions

use of org.openqa.selenium.interactions.Actions in project rstudio by rstudio.

the class RConsoleInteraction method testBasicRInteraction.

@Test
public void testBasicRInteraction() {
    Actions do42 = new Actions(driver_);
    do42.sendKeys(Keys.chord(Keys.CONTROL, "l"));
    do42.sendKeys(Keys.ESCAPE);
    do42.sendKeys("41 + 1");
    do42.sendKeys(Keys.ENTER);
    do42.perform();
    ConsoleTestUtils.waitForConsoleContainsText(driver_, "42");
}
Also used : Actions(org.openqa.selenium.interactions.Actions) Test(org.junit.Test)

Example 14 with Actions

use of org.openqa.selenium.interactions.Actions 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 15 with Actions

use of org.openqa.selenium.interactions.Actions in project ghostdriver by detro.

the class MouseCommandsTest method doubleClick.

@Test
public void doubleClick() {
    WebDriver d = getDriver();
    Actions actionBuilder = new Actions(d);
    d.get("http://www.duckduckgo.com");
    // Double click
    actionBuilder.doubleClick().build().perform();
    // Double click on the logo
    actionBuilder.doubleClick(d.findElement(By.id("logo_homepage_link"))).build().perform();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Actions(org.openqa.selenium.interactions.Actions) Test(org.junit.Test)

Aggregations

Actions (org.openqa.selenium.interactions.Actions)100 WebElement (org.openqa.selenium.WebElement)59 WebDriver (org.openqa.selenium.WebDriver)26 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)18 PublicAtsApi (com.axway.ats.common.PublicAtsApi)16 Test (org.junit.Test)16 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 Action (org.openqa.selenium.interactions.Action)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 JavascriptActions (com.wikia.webdriver.common.core.elemnt.JavascriptActions)1