List of usage examples for org.openqa.selenium.interactions Action perform
void perform();
From source file:au.edu.qtac.admission.webtest.DragAndDropTest.java
@Test public void shouldBeAbleToDragAndDrop() { driver.navigate().to("http://pfdemo-peterdemo101.rhcloud.com/pfdemo/dragdrop.xhtml"); Actions builder = new Actions(driver); // Action dragAndDrop = builder.clickAndHold(driver.findElement(By.id("j_idt11_header"))) // .moveByOffset(100, 300).release().build(); Action dragAndDrop = builder.dragAndDrop(driver.findElement(By.className("ui-draggable")), driver.findElement(By.className("ui-droppable"))).build(); dragAndDrop.perform(); try {//from w ww . j a va 2 s. c om Thread.sleep(5000); } catch (InterruptedException ex) { Logger.getLogger(DragAndDropTest.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:be.rubus.web.testing.AbstractWidget.java
License:Apache License
protected void click(WebElement element, Keys... keys) { Actions builder = new Actions(driver); for (Keys key : keys) { builder.keyDown(key);/*from www .j a v a2 s. c om*/ } builder.click(element); for (Keys key : keys) { builder.keyUp(key); } Action action = builder.build(); action.perform(); }
From source file:cc.kune.selenium.SeleniumUtils.java
License:GNU Affero Public License
/** * Double click.// www. j ava 2 s. co m * * @param webdriver * the webdriver * @param element * the element */ public static void doubleClick(final WebDriver webdriver, final WebElement element) { SeleniumUtils.moveMouseTo(webdriver, element); sleep(300); SeleniumUtils.hightlight(element, webdriver); final Actions builder = new Actions(webdriver); final Action doubleClick = builder.doubleClick(element).build(); doubleClick.perform(); }
From source file:cc.kune.selenium.SeleniumUtils.java
License:GNU Affero Public License
/** * Move mouse to.//from w w w . j a v a 2 s .c o m * * @param webdriver * the webdriver * @param element * the element */ public static void moveMouseTo(final WebDriver webdriver, final WebElement element) { SeleniumUtils.showCursor(webdriver, element); final Actions builder = new Actions(webdriver); final Action action = builder.moveToElement(element).build(); action.perform(); }
From source file:cc.kune.selenium.SeleniumUtils.java
License:GNU Affero Public License
/** * Move mouse to.// w w w. ja v a 2s . co m * * @param webdriver * the webdriver * @param element * the element * @param xOffset * the x offset * @param yOffset * the y offset */ public static void moveMouseTo(final WebDriver webdriver, final WebElement element, final int xOffset, final int yOffset) { showCursor(webdriver, element, xOffset, yOffset); final Actions actions = new Actions(webdriver); actions.moveToElement(element, xOffset, yOffset); final Action action = actions.build(); action.perform(); }
From source file:cc.kune.selenium.SeleniumUtils.java
License:GNU Affero Public License
/** * Move mouse to and click.// ww w .ja v a 2 s. co m * * @param webdriver * the webdriver * @param element * the element * @param xOffset * the x offset * @param yOffset * the y offset */ public static void moveMouseToAndClick(final WebDriver webdriver, final WebElement element, final int xOffset, final int yOffset) { // showCursor(webdriver, element, xOffset, yOffset); final Actions actions = new Actions(webdriver); actions.moveToElement(element, xOffset, yOffset); actions.click(); final Action action = actions.build(); action.perform(); }
From source file:com.coderoad.automation.common.util.old.BasePage.java
License:Open Source License
public String getVersion(Enum<Modules> portal) { String response = null;//from ww w. j av a 2s .c om try { if (portal == Modules.CONSUMER_MENU) { WebElement html = driver.findElement(By.tagName("html")); Assert.assertTrue("The page is not displayed.", html != null); String selectAll = Keys.chord(Keys.CONTROL, Keys.SHIFT, "v"); html.sendKeys(selectAll); Alert alertVersion = driver.switchTo().alert(); response = alertVersion.getText().split(":")[1]; alertVersion.accept(); } else if (portal == Modules.MOBILE_PORTAL) { WebElement element = driver.findElement(By.xpath("//div[contains(@class, 'site-version')]")); Actions actions = new Actions(driver); Action doubleClick = actions.doubleClick(element).build(); doubleClick.perform(); Alert alertVersion = driver.switchTo().alert(); response = alertVersion.getText(); alertVersion.accept(); } } catch (Exception e) { e.printStackTrace(); response = null; } return response; }
From source file:com.consol.citrus.selenium.actions.DropDownSelectAction.java
License:Apache License
@Override protected void execute(WebElement webElement, SeleniumBrowser browser, TestContext context) { super.execute(webElement, browser, context); Select dropdown = new Select(webElement); if (StringUtils.hasText(option)) { dropdown.selectByValue(context.replaceDynamicContentInString(option)); }/* w ww .j a v a 2s. c o m*/ if (!CollectionUtils.isEmpty(options)) { if (BrowserType.IE.equals(browser.getEndpointConfiguration().getBrowserType())) { for (String option : options) { dropdown.selectByValue(context.replaceDynamicContentInString(option)); } } else { List<WebElement> optionElements = dropdown.getOptions(); Actions builder = new Actions(browser.getWebDriver()); builder.keyDown(Keys.CONTROL); for (String optionValue : options) { for (WebElement option : optionElements) { if (!option.isSelected() && isSameValue(option, context.replaceDynamicContentInString(optionValue))) { builder.moveToElement(option).click(option); } } } builder.keyUp(Keys.CONTROL); Action multiple = builder.build(); multiple.perform(); } } }
From source file:com.consol.citrus.selenium.client.WebClient.java
License:Apache License
/** * Select multiple items from a pull-down list. * * @param by//from w w w. j ava 2 s . co m * @param from Start at index. * @param to End at index. */ public void selectMultipleItems(By by, int from, int to) { Select dropdown = new Select(findElement(by)); if (BrowserTypeEnum.INTERNET_EXPLORER.equals(browserType)) { for (int i = from; i < to; i++) { dropdown.selectByIndex(i); } } else { //Rest: List<WebElement> options = dropdown.getOptions(); Actions builder = new Actions(webDriver); builder.keyDown(Keys.CONTROL); for (int i = from; i < to; i++) { WebElement item = options.get(i); if (!item.isSelected()) { builder.moveToElement(item).click(item); } } builder.keyUp(Keys.CONTROL); Action multiple = builder.build(); multiple.perform(); } }
From source file:com.formkiq.web.WorkflowAddControllerIntegrationTest.java
License:Apache License
/** * Fill Signature./* www . ja v a2 s . c om*/ * @param datafieldid {@link String} */ private void fillSignature(final String datafieldid) { WebElement element = findElementBy("canvas", "data-fieldid", datafieldid); final int startXY = 50; Actions builder = new Actions(getDriver()); Action drawAction = builder.moveToElement(element, startXY, startXY).clickAndHold() .moveByOffset(startXY, startXY).release().build(); drawAction.perform(); }