List of usage examples for org.openqa.selenium.interactions Actions Actions
public Actions(WebDriver driver)
From source file:com.jase.knife.BrowserEmulator.java
License:Apache License
/** * click and hold element./*from ww w . j av a 2 s. c o m*/ * @param xpath * the element's xpath */ public void clickAndHold(String xpath) { waitElement(xpath, timeout); Actions action = new Actions(browser); WebElement we = browser.findElement(By.xpath(xpath)); action.clickAndHold(we).perform(); }
From source file:com.jase.knife.BrowserEmulator.java
License:Apache License
/** * Drags an element a certain distance and then drops it. * @param el_xpath, the element's xpath//from w w w . j av a 2s. c o m * @param ta_xpath, the element's xpath */ public void dragAndDrop(String el_xpath, String ta_xpath) { waitElement(el_xpath, timeout); waitElement(ta_xpath, timeout); Actions action = new Actions(browser); WebElement el = browser.findElement(By.xpath(el_xpath)); WebElement ta = browser.findElement(By.xpath(ta_xpath)); action.dragAndDrop(el, ta).perform(); }
From source file:com.java.AppTestType_18_11_2015.java
public void MYOPERATION(WebDriver driver, String fieldText, String value) { //It is used where framework actions doesn't work //We need to proviede SND<Text to enter> in the value fields to perform "Sendkeys" //We need to proviede CLK in the value fields to perform "Click" try {// w w w . j a v a2 s. c o m driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); String f = fieldText; String oper = value; String attribute = f.substring(0, 3); String locator = f.substring(3, f.length()); String operation = oper.substring(0, 3); String val = oper.substring(3, oper.length()); if (operation.equalsIgnoreCase("CLK")) { switch (attribute) { case "IDI": driver.findElement(By.id(locator)).click(); resultDetails.setFlag(true); break; case "XPH": driver.findElement(By.xpath(locator)).click(); resultDetails.setFlag(true); break; case "LNK": driver.findElement(By.linkText(locator)).click(); resultDetails.setFlag(true); break; case "PLK": driver.findElement(By.partialLinkText(locator)).click(); resultDetails.setFlag(true); break; default: System.out.println("Invalid Locator attribute"); break; } } else if (operation.equalsIgnoreCase("SND")) { switch (attribute) { case "IDI": driver.findElement(By.id(locator)).clear(); driver.findElement(By.id(locator)).sendKeys(val); resultDetails.setFlag(true); break; case "XPH": driver.findElement(By.xpath(locator)).clear(); driver.findElement(By.xpath(locator)).sendKeys(val); resultDetails.setFlag(true); break; case "LNK": driver.findElement(By.linkText(locator)).clear(); driver.findElement(By.linkText(locator)).sendKeys(val); resultDetails.setFlag(true); break; default: System.out.println("Invalid Locator attribute"); break; } } else if (operation.equalsIgnoreCase("MTE")) { switch (attribute) { case "IDI": new Actions(driver).moveToElement(driver.findElement(By.id(locator))).perform(); break; case "XPH": new Actions(driver).moveToElement(driver.findElement(By.xpath(locator))).perform(); resultDetails.setFlag(true); break; case "LNK": new Actions(driver).moveToElement(driver.findElement(By.linkText(locator))).perform(); resultDetails.setFlag(true); break; default: System.out.println("Invalid Locator attribute"); break; } } else if (operation.equalsIgnoreCase("SEL")) { switch (attribute) { case "XPH": new Select(driver.findElement(By.xpath(locator))).selectByVisibleText(val); resultDetails.setFlag(true); break; } } } catch (Exception e) { resultDetails.setFlag(false); e.printStackTrace(); } }
From source file:com.java.AppTestType_18_11_2015.java
public void SUBCATEGORYSELECTION(WebDriver driver, String fieldText, String value) { try {/*from w w w .j a va 2s . c o m*/ driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS); String category = fieldText.substring(3, fieldText.length()); String subcat = value.substring(3, value.length()); new Actions(driver).moveToElement(driver.findElement(By.xpath(category))).perform(); Thread.sleep(1500); try { driver.findElement(By.xpath(subcat)).click(); } catch (Exception e1) { driver.findElement(By.xpath(category)).click(); Thread.sleep(3000); new Actions(driver).moveToElement(driver.findElement(By.xpath(category))).perform(); Thread.sleep(3000); driver.findElement(By.xpath(subcat)).click(); } resultDetails.setFlag(true); } catch (Exception e2) { e2.printStackTrace(); resultDetails.setErrorMessage("Unable to click on sub category"); resultDetails.setFlag(false); } }
From source file:com.lazerycode.ebselen.customhandlers.TinyMCEHandler.java
License:Apache License
public TinyMCEHandler(String textAreaID, WebDriver driver) { this.textAreaID = textAreaID; this.driver = driver; this.builder = new Actions(this.driver); }
From source file:com.lazerycode.ebselen.EbselenCore.java
License:Apache License
/** * Start the WebDriver Instance//www . j a v a2 s . com */ public void startSelenium() { if (driver != null) { logger.error("There appears to be an existing driver instance.. Details are: {}", driver); logger.error("Shutting down existing instance and starting up again..."); stopSelenium(driver); } driver = setBrowser(driver); ebselen = new EbselenCommands(driver); builder = new Actions(driver); }
From source file:com.liferay.blade.sample.test.functional.utils.BladeSampleFunctionalActionUtil.java
License:Apache License
public static void customClick(WebDriver webDriver, WebElement webElement) { Actions action = new Actions(webDriver); Actions actionMoveTo = action.moveToElement(webElement); Action buildActionMoveTo = actionMoveTo.build(); buildActionMoveTo.perform();//from w w w .j a v a 2 s. c o m WebDriverWait wait = new WebDriverWait(webDriver, 30); WebElement element = wait.until(ExpectedConditions.elementToBeClickable(webElement)); element.click(); }
From source file:com.liferay.blade.samples.servicebuilder.web.BladeServiceBuilderWebTest.java
License:Apache License
public void customClick(WebDriver webDriver, WebElement webElement) { Actions action = new Actions(webDriver); action.moveToElement(webElement).build().perform(); WebDriverWait wait = new WebDriverWait(webDriver, 5); WebElement element = wait.until(ExpectedConditions.visibilityOf(webElement)); element.click();/* w ww . jav a 2 s . com*/ }
From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java
License:Open Source License
@Override public void doubleClick(String locator) { WebElement webElement = getWebElement(locator); WrapsDriver wrapsDriver = (WrapsDriver) webElement; WebDriver webDriver = wrapsDriver.getWrappedDriver(); Actions actions = new Actions(webDriver); actions.doubleClick(webElement);/*www .j av a2 s . co m*/ Action action = actions.build(); action.perform(); }
From source file:com.liferay.cucumber.selenium.BaseWebDriverImpl.java
License:Open Source License
@Override public void doubleClickAt(String locator, String coordString) { WebElement webElement = getWebElement(locator); WrapsDriver wrapsDriver = (WrapsDriver) webElement; WebDriver webDriver = wrapsDriver.getWrappedDriver(); Actions actions = new Actions(webDriver); if (Validator.isNotNull(coordString) && coordString.contains(",")) { String[] coords = coordString.split(","); int x = GetterUtil.getInteger(coords[0]); int y = GetterUtil.getInteger(coords[1]); actions.moveToElement(webElement, x, y); actions.doubleClick();//from w w w. ja v a 2 s . com } else { actions.doubleClick(webElement); } Action action = actions.build(); action.perform(); }