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

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

Introduction

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

Prototype

public Actions clickAndHold(WebElement target) 

Source Link

Document

Clicks (without releasing) in the middle of the given element.

Usage

From source file:com.vmware.gemfire.tools.pulse.tests.PulseAbstractTest.java

License:Apache License

@Test
public void testDataViewTreeMapPopUpData() {
    searchByLinkAndClick(CLUSTER_VIEW_LABEL);
    searchByLinkAndClick(DATA_DROPDOWN_ID);
    WebElement TreeMapMember = driver.findElement(By.id("GraphTreeMapClusterData-canvas"));
    Actions builder = new Actions(driver);
    builder.clickAndHold(TreeMapMember).perform();
    String RegionType = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div/div[2]/div"))
            .getText();/*from   w w w  . j a  va2 s. com*/
    String regionType = JMXProperties.getInstance().getProperty("region.R2.regionType");
    assertEquals(regionType, RegionType);

    String EntryCount = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[2]/div[2]/div"))
            .getText();
    String entryCount = JMXProperties.getInstance().getProperty("region.R2.systemRegionEntryCount");
    assertEquals(entryCount, EntryCount);

    String EntrySizetemp = driver
            .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[3]/div[2]/div")).getText();
    float EntrySize = Float.parseFloat(EntrySizetemp);
    float entrySize = Float.parseFloat(JMXProperties.getInstance().getProperty("region.R2.entrySize"));
    entrySize = entrySize / 1024 / 1024;
    entrySize = Float.parseFloat(new DecimalFormat("##.####").format(entrySize));
    assertEquals(entrySize, EntrySize);
    builder.moveToElement(TreeMapMember).release().perform();
}

From source file:com.vmware.gemfire.tools.pulse.tests.PulseTest.java

License:Apache License

public void testTreeMapPopUpData(String S1, String gridIcon) {
    for (int i = 1; i <= 3; i++) {
        searchByLinkAndClick(CLUSTER_VIEW_LABEL);
        if (gridIcon.equals(SERVER_GROUP_GRID_ID)) {
            WebElement ServerGroupRadio = driver.findElement(By.xpath("//label[@for='radio-servergroups']"));
            ServerGroupRadio.click();/*from  w  w  w .ja va 2s . c o m*/
        }
        if (gridIcon.equals(REDUNDANCY_GRID_ID)) {
            WebElement ServerGroupRadio = driver.findElement(By.xpath("//label[@for='radio-redundancyzones']"));
            ServerGroupRadio.click();
        }
        searchByIdAndClick(gridIcon);
        WebElement TreeMapMember = driver.findElement(By.xpath("//div[@id='" + S1 + "M" + (i) + "']/div"));
        Actions builder = new Actions(driver);
        builder.clickAndHold(TreeMapMember).perform();
        int j = 1;
        String CPUUsageM1temp = driver
                .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div/div[2]/div")).getText();
        String CPUUsageM1 = CPUUsageM1temp.replaceAll("[\\%]", "");
        String cpuUsageM1 = JMXProperties.getInstance().getProperty("member.M" + (i) + ".cpuUsage");
        Assert.assertEquals(cpuUsageM1, CPUUsageM1);

        String MemoryUsageM1temp = driver
                .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 1) + "]/div[2]/div"))
                .getText();
        String MemoryUsageM1 = MemoryUsageM1temp.replaceAll("MB", "");
        String memoryUsageM1 = JMXProperties.getInstance().getProperty("member.M" + (i) + ".UsedMemory");
        Assert.assertEquals(memoryUsageM1, MemoryUsageM1);

        String LoadAvgM1 = driver
                .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 2) + "]/div[2]/div"))
                .getText();
        String loadAvgM1 = JMXProperties.getInstance().getProperty("member.M" + (i) + ".loadAverage");
        Assert.assertEquals(df2.format(Double.valueOf(loadAvgM1)), LoadAvgM1);

        String ThreadsM1 = driver
                .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 3) + "]/div[2]/div"))
                .getText();
        String threadsM1 = JMXProperties.getInstance().getProperty("member.M" + (i) + ".numThreads");
        Assert.assertEquals(threadsM1, ThreadsM1);

        String SocketsM1 = driver
                .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 4) + "]/div[2]/div"))
                .getText();
        String socketsM1 = JMXProperties.getInstance()
                .getProperty("member.M" + (i) + ".totalFileDescriptorOpen");
        Assert.assertEquals(socketsM1, SocketsM1);
        builder.moveToElement(TreeMapMember).release().perform();
    }
}

From source file:com.vmware.gemfire.tools.pulse.tests.PulseTest.java

License:Apache License

@Test
public void testDataViewTreeMapPopUpData() {
    searchByLinkAndClick(CLUSTER_VIEW_LABEL);
    searchByLinkAndClick(DATA_DROPDOWN_ID);
    WebElement TreeMapMember = driver.findElement(By.id("GraphTreeMapClusterData-canvas"));
    Actions builder = new Actions(driver);
    builder.clickAndHold(TreeMapMember).perform();
    String RegionType = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div/div[2]/div"))
            .getText();/*  ww  w  .  jav  a2s  .  c  om*/
    String regionType = JMXProperties.getInstance().getProperty("region.R2.regionType");
    Assert.assertEquals(regionType, RegionType);

    String EntryCount = driver.findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[2]/div[2]/div"))
            .getText();
    String entryCount = JMXProperties.getInstance().getProperty("region.R2.systemRegionEntryCount");
    Assert.assertEquals(entryCount, EntryCount);

    String EntrySizetemp = driver
            .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[3]/div[2]/div")).getText();
    float EntrySize = Float.parseFloat(EntrySizetemp);
    float entrySize = Float.parseFloat(JMXProperties.getInstance().getProperty("region.R2.entrySize"));
    entrySize = entrySize / 1024 / 1024;
    entrySize = Float.parseFloat(new DecimalFormat("##.####").format(entrySize));
    Assert.assertEquals(entrySize, EntrySize);
    builder.moveToElement(TreeMapMember).release().perform();
}

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

License:Open Source License

/**
 * @param dashletTitle/*from   ww  w  . j  av a 2  s. c o m*/
 * @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//from  w w  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:info.magnolia.integrationtests.uitest.AbstractMagnoliaUITest.java

License:Open Source License

/**
 * Drag (source element) and drop it (in destination element).
 *///from   w w  w .ja  v  a 2  s .  c  o m
protected void dragAndDropElement(WebElement sourceElement, WebElement destinationElement) {
    Actions actionBuilder = new Actions(driver);

    Action dragAndDrop = actionBuilder.clickAndHold(sourceElement).moveToElement(destinationElement)
            .release(destinationElement).build();

    dragAndDrop.perform();
}

From source file:org.alfresco.po.PageElement.java

License:Open Source License

/**
 * Drag the source element and drop into target element.
 * /*from   ww  w. j ava  2 s  .com*/
 * @param source - Source Element
 * @param target - Target Element
 */
public void dragAndDrop(WebElement source, WebElement target) {
    PageUtils.checkMandatoryParam("source element", source);
    PageUtils.checkMandatoryParam("target element", target);
    Actions builder = new Actions(driver);
    Action dragAndDrop = builder.clickAndHold(source).moveToElement(target).release(target).build();
    dragAndDrop.perform();
}

From source file:org.apache.geode.tools.pulse.tests.ui.PulseBase.java

License:Apache License

public void testTreeMapPopUpData(String S1, String gridIcon) {
    for (int i = 1; i <= 3; i++) {
        searchByLinkAndClick(CLUSTER_VIEW_LABEL);
        if (gridIcon.equals(SERVER_GROUP_GRID_ID)) {
            WebElement ServerGroupRadio = getWebDriver()
                    .findElement(By.xpath("//label[@for='radio-servergroups']"));
            ServerGroupRadio.click();//from  w w w.j  a  v a  2s  .c  o m
        }
        if (gridIcon.equals(REDUNDANCY_GRID_ID)) {
            WebElement ServerGroupRadio = getWebDriver()
                    .findElement(By.xpath("//label[@for='radio-redundancyzones']"));
            ServerGroupRadio.click();
        }
        searchByIdAndClick(gridIcon);
        WebElement TreeMapMember = getWebDriver()
                .findElement(By.xpath("//div[@id='" + S1 + "M" + (i) + "']/div"));
        Actions builder = new Actions(getWebDriver());
        builder.clickAndHold(TreeMapMember).perform();
        int j = 1;
        String CPUUsageM1temp = getWebDriver()
                .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div/div[2]/div")).getText();
        String CPUUsageM1 = CPUUsageM1temp.replaceAll("[\\%]", "");
        String cpuUsageM1 = JMXProperties.getInstance().getProperty("member.M" + (i) + ".cpuUsage");
        assertEquals(cpuUsageM1, CPUUsageM1);

        String MemoryUsageM1temp = getWebDriver()
                .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 1) + "]/div[2]/div"))
                .getText();
        String MemoryUsageM1 = MemoryUsageM1temp.replaceAll("MB", "");
        String memoryUsageM1 = JMXProperties.getInstance().getProperty("member.M" + (i) + ".UsedMemory");
        assertEquals(memoryUsageM1, MemoryUsageM1);

        String LoadAvgM1 = getWebDriver()
                .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 2) + "]/div[2]/div"))
                .getText();
        String loadAvgM1 = JMXProperties.getInstance().getProperty("member.M" + (i) + ".loadAverage");
        assertEquals(new DecimalFormat(PulseConstants.DECIMAL_FORMAT_PATTERN).format(Double.valueOf(loadAvgM1)),
                LoadAvgM1);

        String ThreadsM1 = getWebDriver()
                .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 3) + "]/div[2]/div"))
                .getText();
        String threadsM1 = JMXProperties.getInstance().getProperty("member.M" + (i) + ".numThreads");
        assertEquals(threadsM1, ThreadsM1);

        String SocketsM1 = getWebDriver()
                .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[" + (j + 4) + "]/div[2]/div"))
                .getText();
        String socketsM1 = JMXProperties.getInstance()
                .getProperty("member.M" + (i) + ".totalFileDescriptorOpen");
        assertEquals(socketsM1, SocketsM1);
        builder.moveToElement(TreeMapMember).release().perform();
    }
}

From source file:org.apache.geode.tools.pulse.tests.ui.PulseBase.java

License:Apache License

@Test
public void testDataViewTreeMapPopUpData() {
    searchByLinkAndClick(CLUSTER_VIEW_LABEL);
    searchByLinkAndClick(DATA_DROPDOWN_ID);
    WebElement TreeMapMember = getWebDriver().findElement(By.id("GraphTreeMapClusterData-canvas"));
    Actions builder = new Actions(getWebDriver());
    builder.clickAndHold(TreeMapMember).perform();
    String RegionType = getWebDriver()
            .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div/div[2]/div")).getText();
    String regionType = JMXProperties.getInstance().getProperty("region.R2.regionType");
    assertEquals(regionType, RegionType);

    String EntryCount = getWebDriver()
            .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[2]/div[2]/div")).getText();
    String entryCount = JMXProperties.getInstance().getProperty("region.R2.systemRegionEntryCount");
    assertEquals(entryCount, EntryCount);

    String EntrySizetemp = getWebDriver()
            .findElement(By.xpath("//div[@id='_tooltip']/div/div/div[2]/div[3]/div[2]/div")).getText();
    float EntrySize = Float.parseFloat(EntrySizetemp);
    float entrySize = Float.parseFloat(JMXProperties.getInstance().getProperty("region.R2.entrySize"));
    entrySize = entrySize / 1024 / 1024;
    entrySize = Float.parseFloat(new DecimalFormat("##.####").format(entrySize));
    assertEquals(entrySize, EntrySize, 0.001);
    builder.moveToElement(TreeMapMember).release().perform();
}

From source file:org.cerberus.service.engine.impl.WebDriverService.java

License:Open Source License

@Override
public MessageEvent doSeleniumActionMouseDown(Session session, Identifier identifier) {
    MessageEvent message;//from ww  w.  j  a va2 s .c om
    try {

        AnswerItem answer = this.getSeleniumElement(session, identifier, true, true);
        if (answer.isCodeEquals(MessageEventEnum.ACTION_SUCCESS_WAIT_ELEMENT.getCode())) {
            WebElement webElement = (WebElement) answer.getItem();
            if (webElement != null) {
                Actions actions = new Actions(session.getDriver());
                actions.clickAndHold(webElement);
                actions.build().perform();
                message = new MessageEvent(MessageEventEnum.ACTION_SUCCESS_MOUSEDOWN);
                message.setDescription(message.getDescription().replaceAll("%ELEMENT%",
                        identifier.getIdentifier() + "=" + identifier.getLocator()));
                return message;
            }
        }

        return answer.getResultMessage();
    } catch (NoSuchElementException exception) {
        message = new MessageEvent(MessageEventEnum.ACTION_FAILED_MOUSEDOWN_NO_SUCH_ELEMENT);
        message.setDescription(message.getDescription().replaceAll("%ELEMENT%",
                identifier.getIdentifier() + "=" + identifier.getLocator()));
        MyLogger.log(WebDriverService.class.getName(), Level.DEBUG, exception.toString());
        return message;
    } catch (WebDriverException exception) {
        message = new MessageEvent(MessageEventEnum.ACTION_FAILED_SELENIUM_CONNECTIVITY);
        MyLogger.log(WebDriverService.class.getName(), Level.FATAL, exception.toString());
        return message;
    }
}