Example usage for org.openqa.selenium.interactions Actions Actions

List of usage examples for org.openqa.selenium.interactions Actions Actions

Introduction

In this page you can find the example usage for org.openqa.selenium.interactions Actions Actions.

Prototype

public Actions(WebDriver driver) 

Source Link

Usage

From source file:com.xirrus.xms.locallib.NavigateTo.java

/**
 * Navigates to the specified XMS webpage.
 * //from w w  w  .  ja v a 2 s.c  om
 * @mainPage Main panel xmstest:id getting from PATH properties file
 * @subPage Sub panel xmstest:id getting from PATH properties file
 * @throws InterruptedException
 */
public void goTo(String mainPage, String subPage) throws InterruptedException {
    App_Log.debug("Debug:" + " Navigating to " + mainPage + " " + subPage);
    Actions actions = new Actions(driver);
    // Move mouse to Monitor
    if (subPage == null) {
        driver.findElement(By.xpath("//a[@*='" + mainPage + "']")).click();
    } else {
        // Navigate to Overview Access Points (Monitor>>Access Points)
        actions.moveToElement(driver.findElement(By.xpath("//a[@*='" + mainPage + "']")))
                .moveToElement(driver.findElement(By.xpath("//a[@*='" + subPage + "']"))).click().build()
                .perform();
    }
    Thread.sleep(clickDelay);
}

From source file:com.zaizi.automation.abfts.core.pages.Dashboard.java

License:Open Source License

/**
 * @param dashletTitle//from  ww  w.  java 2 s .  c om
 * @throws InterruptedException
 */
public void customizeDashboard(String dashletTitle) throws InterruptedException {
    Link customize = new Link(driver, By.xpath("//img[@alt='Customize Dashboard']"));
    customize.click();
    Thread.sleep(2000);
    Button addDashlets = new Button(driver, By.xpath(
            "//button[@id='template_x002e_customise-dashlets_x002e_customise-user-dashboard_x0023_default-addDashlets-button-button']"));
    addDashlets.click();
    Thread.sleep(2000);
    Actions performer = new Actions(driver);
    WebElement rssFeed = driver.findElement(By.xpath("//div[@title='" + dashletTitle + "']"));
    WebElement list = driver.findElement(By.xpath(
            "//ul[@id='template_x002e_customise-dashlets_x002e_customise-user-dashboard_x0023_default-column-ul-1']"));
    Action dragAndDrop = performer.clickAndHold(rssFeed).moveToElement(list).release(list).build();
    Thread.sleep(5000);
    dragAndDrop.perform();
    Thread.sleep(5000);
    Button okButton = new Button(driver, By.xpath(
            "//button[@id='template_x002e_customise-dashlets_x002e_customise-user-dashboard_x0023_default-save-button-button']"));
    okButton.click();
    Thread.sleep(5000);
    Division rssFeedBlog = new Division(driver, By.xpath(
            "//div[@id='page_x002e_component-1-3_x002e_user_x007e_admin_x007e_dashboard_x0023_default-title']"));
    if (rssFeedBlog.getWebElement().isDisplayed()) {
        LOGGER.info(TEXT_TEST_PASSED);
    } else {
        LOGGER.info(TEXT_TEST_FAILED);
    }
}

From source file:com.zaizi.automation.abfts.core.pages.Dashboard.java

License:Open Source License

/**
 * @param dashletTitle// ww  w .j  a v  a 2 s .c om
 * @throws InterruptedException
 */
public void customizeSiteDashboard(String dashletTitle) throws InterruptedException {
    Thread.sleep(5000);
    Link customize = new Link(driver, By.xpath("//img[@alt='Site configuration options']"));
    customize.click();
    Thread.sleep(2000);
    Link customizeOption = new Link(driver, By.xpath("//a[contains(., 'Customize Dashboard')]"));
    customizeOption.click();
    Thread.sleep(1000);
    Button addDashlets = new Button(driver, By.xpath(
            "//span/span/button[@id='template_x002e_customise-dashlets_x002e_customise-site-dashboard_x0023_default-addDashlets-button-button']"));
    addDashlets.click();
    Thread.sleep(2000);
    Actions performer = new Actions(driver);
    WebElement wiki = driver.findElement(By.xpath("//div[@title='" + dashletTitle + "']"));
    WebElement list = driver.findElement(By.xpath(
            "//div/ul[@id='template_x002e_customise-dashlets_x002e_customise-site-dashboard_x0023_default-column-ul-1']"));
    Action dragAndDrop = performer.clickAndHold(wiki).moveToElement(list).release(list).build();
    Thread.sleep(5000);
    dragAndDrop.perform();
    Thread.sleep(5000);
    Button okButton = new Button(driver, By.xpath(
            "//span/span/button[@id='template_x002e_customise-dashlets_x002e_customise-site-dashboard_x0023_default-save-button-button']"));
    okButton.click();
    Thread.sleep(5000);
    Division wikiDashlet = new Division(driver,
            By.xpath("//div/div/div[@class='title' and contains(., 'Wiki')]"));
    if (wikiDashlet.getWebElement().isDisplayed()) {
        LOGGER.info(TEXT_TEST_PASSED);
    } else {
        LOGGER.info(TEXT_TEST_FAILED);
    }
}

From source file:com.zaizi.automation.alfresco.core.pages.AdminConsolePage.java

License:Open Source License

/**
 * Change System Theme//from  ww w .ja  v a  2  s.co  m
 * 
 * @param themeName
 *            : Name of the theme
 * @throws InterruptedException
 * @throws AWTException
 */

public void changeTheme(String themeName) throws InterruptedException, AWTException {
    NavigateToPage navigateToPage = new NavigateToPage(driver);
    navigateToPage.goToHome();
    Element.waitForLoad(driver);
    navigateToPage.goToAdminTools();
    Element.waitForLoad(driver);

    Actions action = new Actions(driver);

    Button themeDropDown = new Button(driver, By.xpath("//div//select[@id='console-options-theme-menu']"));
    themeDropDown.click();
    Thread.sleep(500);

    WebElement themeSelect = driver.findElement(By.xpath(
            "//div//select[@id='console-options-theme-menu']//option[contains(text(),'" + themeName + "')]"));

    action.click(themeSelect).sendKeys(Keys.ENTER).build().perform();
    Thread.sleep(1000);
    Element.waitForLoad(driver);
    Thread.sleep(1000);
    Button applyButton = new Button(driver,
            By.xpath("//div[@class='apply']//span//span//button[contains(text(),'Apply')]"));
    applyButton.click();
    Thread.sleep(1000);
    Element.waitForLoad(driver);
    Thread.sleep(500);
    navigateToPage.goToHome();
    Element.waitForLoad(driver);
}

From source file:com.zutubi.pulse.acceptance.SeleniumBrowser.java

License:Apache License

/**
 * Double clicks on an element.  Respects the implicit wait period.
 * /*from www  . ja  v a2 s  .  com*/
 * @param by element locator
 */
public void doubleClick(By by) {
    new Actions(webDriver).doubleClick(webDriver.findElement(by)).build().perform();
}

From source file:contentspeed.ProdusCeai.java

void CosClick() {

    Actions actions = new Actions(driver);
    actions.click(driver.findElement(cosComanda)).perform();

}

From source file:contentspeededgedriver.ProdusCeai.java

void CosClick() {
    //driver.findElement(cosComanda).click();

    Actions actions = new Actions(driver);
    actions.click(driver.findElement(cosComanda)).perform();
    String MainWindow = driver.getWindowHandle();

    Set<String> s1 = driver.getWindowHandles();
    Iterator<String> i1 = s1.iterator();

    //System.out.println(s1.size());

    while (i1.hasNext()) {
        String ChildWindow = i1.next();

        driver.switchTo().window(ChildWindow);

        driver.findElement(By.partialLinkText("Vezi cosul")).click();

    }//from   w w w  .j  a v a 2  s.c o m
}

From source file:dagaz.controllers.ChildController.java

private void switchChannel() {
    try {//from ww w . ja va2s . c o m
        StaticImageScreenRegion region = videoFooterSection();
        if (region != null) {
            List<ScreenRegion> re = region
                    .findAll(new ImageTarget(ImageIO.read(new File(imgRoot + "wifi.png"))));
            if (re.size() < 1) {
                throw new IOException("Failed to find the wifi icon.");
            } else {
                for (ScreenRegion screenRegion : re) {
                    Actions action = new Actions(driver);
                    int nextChannel = 0;
                    if (channel == 5) {
                        nextChannel = 1;
                    } else {
                        nextChannel = channel + 1;
                    }
                    WebElement element = driver.findElement(By.id("divFlashHolder"));
                    action.moveToElement(element, screenRegion.getCenter().getX() + 40,
                            300 + screenRegion.getCenter().getY()).click().build().perform();
                    action = new Actions(driver);
                    action.moveToElement(element, screenRegion.getCenter().getX() + 40,
                            300 + screenRegion.getCenter().getY() - (120 - (nextChannel * 20))).click().build()
                            .perform();
                    channel = nextChannel;
                    config.getRoot().appendDetails("\t ---- Connection trouble ----\n\t[" + arena
                            + "] - Switching to channel #" + channel + "\n\t---------------");
                }
            }
        }
    } catch (IOException ex) {
        Logger.getLogger(ChildController.class.getName()).log(Level.SEVERE, null, ex);
        config.getRoot().appendDetails("- [" + arena + "] - Failed to switch channel.");
    }
}

From source file:day3.Day3task4.java

@Test
public static void hoverProducts() throws InterruptedException {
    Actions action = new Actions(getDriver());
    WebElement element = getDriver()/*from w w  w . j a va2  s . co  m*/
            .findElement(By.xpath("html/body/div[1]/header/div[1]/div/div/div/div/nav/ul/li[1]/a"));

    action.moveToElement(element).build().perform();
    WebElement element1 = getDriver()
            .findElement(By.xpath("html/body/div[1]/header/div[1]/div/div/div/div/nav/ul/li[1]/ul/li[3]/a"));
    action.moveToElement(element1).build().perform();
    WebElement ele2 = getDriver().findElement(By
            .xpath("html/body/div[1]/header/div/div/div/div/div/nav/ul/li[1]/ul/li[3]/ul/li[6]/ul[2]/li[2]/a"));
    action.moveToElement(ele2).click(ele2).build().perform();
    WebElement ele3 = getDriver()
            .findElement(By.xpath("html/body/div[4]/header/div[1]/div/div/div/div/nav/ul/li[4]/a"));
    action.moveToElement(ele3).build().perform();
    WebElement element4 = getDriver().findElement(By.cssSelector(".dropdown-content_link.m-menu__a"));
    action.moveToElement(element4).build().perform();
    ((JavascriptExecutor) getDriver()).executeScript("arguments[0].click();", element4);

    //getDriver().findElement(By.xpath(" html/body/div[4]/header/div[1]/div/div/div/div/nav/ul/li[4]/ul/li[3]/a")).click();
    getDriver().findElement(By.id("email")).sendKeys("ankammarao@gmail.com");
    getDriver().findElement(By.id("license")).sendKeys("123456");
    getDriver().findElement(By.className("btn-thin-blue")).click();
    String actual = getDriver().findElement(By.xpath("html/body/div[1]/div[1]/div[2]/div/div/div/div"))
            .getText();
    String expected = "ERROR: Invalid e-mail or license number";
    Assert.assertEquals(actual, expected);

}

From source file:de.codecentric.zucchini.web.steps.TypeStep.java

License:Apache License

/**
 * Types the keys./*from w  ww  .j ava 2s.  c o m*/
 */
@Override
public void go() {
    logger.info("Typing \"{}\"...", (Object) keys);
    new Actions(getWebDriver()).sendKeys(Keys.ENTER);
}