List of usage examples for org.openqa.selenium JavascriptExecutor executeScript
Object executeScript(String script, Object... args);
From source file:com.citrix.g2w.webdriver.pages.branding.settings.ManageBrandingSettingsPage.java
License:Open Source License
public void selectBrandingTheme(String themeName) { WebElement elementToSelect = driver.findElement(themeDropDown); //making drop down visible ((JavascriptExecutor) this.driver).executeScript("arguments[0].style.display='block';", elementToSelect); Select select = new Select(elementToSelect); JavascriptExecutor executor = (JavascriptExecutor) driver; executor.executeScript("arguments[0].click();", elementToSelect); this.logger.logWithScreenShot("After click on dropdown", this.driver); select.selectByVisibleText(themeName); clickOnSave();/*from w w w .ja va 2 s . c om*/ }
From source file:com.coderoad.automation.common.util.old.BasePage.java
License:Open Source License
/** * this method send the click () event to the web element. * //from w w w .jav a 2 s. com * @param elem the elem */ protected void click(WebElement elem) { JavascriptExecutor executor = (JavascriptExecutor) getDriver(); executor.executeScript("arguments[0].click();", elem); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do tap.//w w w . ja v a2 s . co m * * @param element the element * @param driver the driver */ public static void doTap(final WebElement element, final WebDriver driver) { Point point = element.getLocation(); double x = point.getX(); double y = point.getY(); Dimension dimesions = element.getSize(); int width = dimesions.width; int height = dimesions.height; final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); // tapObject.put("duration", 0.7); tapObject.put("x", x + width - 2); tapObject.put("y", y + height - 2); js.executeScript("mobile: tap", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do left tap.//from w w w . jav a 2 s .c o m * * @param element the element * @param driver the driver */ public static void doLeftTap(final WebElement element, final WebDriver driver) { LogUtil.log("Do Left Tap", LogLevel.HIGH); Point point = element.getLocation(); double x = point.getX(); double y = point.getY(); Dimension dimesions = element.getSize(); int height = dimesions.height; final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); x = x + 2; y = y + height + 2; tapObject.put("x", x); tapObject.put("y", y); LogUtil.log("X :" + x, LogLevel.HIGH); LogUtil.log("Y :" + y, LogLevel.HIGH); js.executeScript("mobile: tap", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do middle tap./*from w w w. j av a 2 s .com*/ * * @param element the element * @param driver the driver */ public static void doMiddleTap(final WebElement element, final WebDriver driver) { LogUtil.log("Do Middle Tap", LogLevel.HIGH); Point point = element.getLocation(); double x = point.getX(); double y = point.getY(); Dimension dimesions = element.getSize(); int width = dimesions.width; int height = dimesions.height; final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); tapObject.put("duration", 0.1); int midX = (int) x + (width / 2); int midY = (int) y + (height / 2); LogUtil.log("midX :" + midX, LogLevel.HIGH); LogUtil.log("midY :" + midY, LogLevel.HIGH); tapObject.put("duration", 0.7); tapObject.put("x", (double) midX); tapObject.put("y", (double) midY); js.executeScript("mobile: tap", tapObject); js.executeScript("mobile: tap", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do exact tap./* w ww.ja v a 2 s . c om*/ * * @param element the element * @param driver the driver */ public static void doExactTap(final WebElement element, final WebDriver driver) { LogUtil.log("Do Exact Tap", LogLevel.HIGH); final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); Point point = element.getLocation(); double x = point.getX(); double y = point.getY(); tapObject.put("x", x); tapObject.put("y", y); js.executeScript("mobile: tap", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do tap./*w ww.ja v a 2 s . c om*/ * * @param x the x * @param y the y * @param driver the driver */ public static void doTap(final double x, final double y, final WebDriver driver) { Map<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); tapObject.put("duration", 0.7); tapObject.put("x", x); tapObject.put("y", y); final JavascriptExecutor js = (JavascriptExecutor) driver; // LogUtil.log("Page Source : " + driver.getPageSource(), // LogLevel.HIGH); js.executeScript("mobile: tap", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do swipe horizontal.// ww w. ja v a 2 s.com * * @param element the element * @param driver the driver * @param length the length */ public static void doSwipeHorizontal(final WebElement element, final WebDriver driver, final int length) { Point point = element.getLocation(); double x = point.getX(); double y = point.getY(); LogUtil.log("X :" + element.getLocation().getX(), LogLevel.HIGH); LogUtil.log("Y :" + element.getLocation().getY(), LogLevel.HIGH); LogUtil.log("Length :" + length, LogLevel.HIGH); final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); tapObject.put("duration", 0.7); tapObject.put("startX", x + 5); tapObject.put("startY", y); tapObject.put("endX", x + length); tapObject.put("endY", y); js.executeScript("mobile: swipe", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do swipe page left.//from w ww . ja v a 2 s . c o m * * @param element the element * @param driver the driver */ public static void doSwipePageLeft(final WebElement element, final WebDriver driver) { // final Point point = element.getLocation(); // double x = point.getX(); // double y = point.getY(); LogUtil.log("X :" + element.getLocation().getX(), LogLevel.HIGH); LogUtil.log("Y :" + element.getLocation().getY(), LogLevel.HIGH); final Dimension dimesions = element.getSize(); //int width = dimesions.width; //int height = dimesions.height; LogUtil.log("width :" + dimesions.width, LogLevel.HIGH); LogUtil.log("hieght:" + dimesions.height, LogLevel.HIGH); final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); tapObject.put("duration", 0.7); tapObject.put("startX", (double) getWindowWidth(driver)); tapObject.put("startY", (double) (getWindowHeight(driver) / 2)); tapObject.put("endX", 0.0); tapObject.put("endY", (double) (getWindowHeight(driver) / 2)); js.executeScript("mobile: swipe", tapObject); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do swipe page right./*w w w . jav a2 s. co m*/ * * @param element the element * @param driver the driver */ public static void doSwipePageRight(final WebElement element, final WebDriver driver) { Point point = element.getLocation(); double x = point.getX(); double y = point.getY(); LogUtil.log("X :" + element.getLocation().getX(), LogLevel.HIGH); LogUtil.log("Y :" + element.getLocation().getY(), LogLevel.HIGH); Dimension dimesions = element.getSize(); int width = dimesions.width; // int height = dimesions.height; LogUtil.log("width :" + dimesions.width, LogLevel.HIGH); LogUtil.log("hieght:" + dimesions.height, LogLevel.HIGH); final JavascriptExecutor js = (JavascriptExecutor) driver; final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("tapCount", 1.0); tapObject.put("touchCount", 1.0); tapObject.put("duration", 0.7); tapObject.put("startX", x + width); tapObject.put("startY", y); tapObject.put("endX", x); tapObject.put("endY", y); js.executeScript("mobile: swipe", tapObject); }