List of usage examples for org.openqa.selenium Point getY
public int getY()
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Do middle tap.//from w w w. ja v a 2s. c om * * @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 w w .j a v a 2 s.c o m * * @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 swipe horizontal.//w ww . j a v a2 s.c o m * * @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 right.// ww w . ja va 2 s .c o 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); }
From source file:com.coderoad.automation.common.util.PageUtil.java
License:Open Source License
/** * Double tap.//w w w. java 2 s .c o m * * @param driver the driver * @param element the element */ public static void doubleTap(final WebDriver driver, WebElement element) { Point point = element.getLocation(); int x = point.getX(); int y = point.getY(); Dimension dimesions = element.getSize(); int width = dimesions.width; int height = dimesions.height; ((TouchShortcuts) driver).tap(2, x + width - 2, y + height - 2, 1); /* * for (int i = 0; i < 2; i++) { * * 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", 2.0); tapObject.put("touchCount", 1.0); * tapObject.put("duration", 0.7); tapObject.put("fingers ", 2.0); * tapObject.put("x", x + width - 2); tapObject.put("y", y + height - * 2); js.executeScript("mobile: tap", tapObject); * WaitUtil.waitUntil(1); } */ }
From source file:com.cognifide.aet.job.common.collectors.screen.ScreenCollector.java
License:Apache License
private byte[] getImagePart(byte[] fullPage, WebElement webElement) throws IOException, ProcessingException { InputStream in = new ByteArrayInputStream(fullPage); try {/*from w w w. jav a 2s.c o m*/ BufferedImage fullImg = ImageIO.read(in); Point point = webElement.getLocation(); Dimension size = webElement.getSize(); BufferedImage screenshotSection = fullImg.getSubimage(point.getX(), point.getY(), size.getWidth(), size.getHeight()); return bufferedImageToByteArray(screenshotSection); } catch (IOException e) { throw new ProcessingException("Unable to create image from taken screenshot", e); } finally { IOUtils.closeQuietly(in); } }
From source file:com.cognifide.qa.bb.aem.ui.parsys.AemParsys.java
License:Apache License
private Predicate<WebElement> parsysByLocation(final Point location) { return input -> { int xPositionDiff = Math.abs(location.getX() - input.getLocation().getX()); int yPositionDiff = Math.abs(location.getY() - input.getLocation().getY()); return xPositionDiff + yPositionDiff <= parsysOffset; };/*from w ww . j ava 2 s . co m*/ }
From source file:com.contactenergy.Tests.ContactBrowserTest.java
public void scrollandclick(String elementxpath) { WebElement submit = driver.get().findElement(By.xpath(elementxpath)); Point coordinates = submit.getLocation(); int s1 = coordinates.getX(); int s2 = coordinates.getY(); JavascriptExecutor exe1 = (JavascriptExecutor) driver.get(); exe1.executeScript("window.scroll(" + s1 + ", " + s2 + ");"); exe1.executeScript("arguments[0].click();", submit); }
From source file:com.galenframework.page.selenium.WebPageElement.java
License:Apache License
@Override public Rect calculateArea() { if (cachedArea == null) { Point location = getWebElement().getLocation(); Dimension size = getWebElement().getSize(); cachedArea = new Rect(location.getX(), location.getY(), size.getWidth(), size.getHeight()); if (getLocator() != null && getLocator().getCorrections() != null) { cachedArea = correctedRect(cachedArea, getLocator().getCorrections()); }//from ww w. j a v a2s . com } return cachedArea; }
From source file:com.github.wasiqb.coteafs.appium.device.DeviceElementActions.java
License:Apache License
/** * @author wasiqb//w w w .j av a2 s.com * @since Oct 18, 2018 * @param times */ public void nTaps(final int times) { perform(format("Performing [%d] taps on", times), e -> { final Point center = e.getCenter(); for (int index = 0; index < times; index++) { this.touch.press(PointOption.point(center.getX(), center.getY())).release().perform(); } }); }