List of usage examples for org.openqa.selenium WebElement getLocation
Point getLocation();
From source file:com.ecofactor.qa.automation.newapp.page.impl.LoginPageImpl.java
License:Open Source License
/** * Checks if is error info position top of login box. * @return true, if is error info position top of login box * @see com.ecofactor.qa.automation.newapp.page.LoginPage#isErrorInfoPositionTopOfLoginBox() *///from www .j av a 2 s .co m @Override public boolean isErrorInfoPositionTopOfLoginBox() { LogUtil.setLogString("Check if error info message is in top of login box.", true, CustomLogLevel.HIGH); boolean isErrorInfoPositionTop = false; isDisplayed(getDriver(), By.className(LOGIN_RESP_BOX), MEDIUM_TIMEOUT); WebElement errorMsg = getElement(getDriver(), By.className(LOGIN_RESP_BOX), MEDIUM_TIMEOUT); WebElement formElement = getElement(getDriver(), By.className(LOGIN_FORM), MEDIUM_TIMEOUT); isErrorInfoPositionTop = (errorMsg.getLocation().y < formElement.getLocation().y) ? true : false; return isErrorInfoPositionTop; }
From source file:com.ecofactor.qa.automation.newapp.page.impl.SavingsPageImpl.java
License:Open Source License
/** * @return/*from ww w.j a v a2s .c om*/ * @see com.ecofactor.qa.automation.newapp.page.SavingsPage#isSavingsDollarVertical() */ @Override public boolean isSavingsDollarVertical() { final WebElement savingsDollarElement = getElement(getDriver(), By.className("fusioncharts-yaxis-0-gridlabels"), TINY_TIMEOUT); final List<WebElement> savingsDollar = getElementsBySubElement(getDriver(), savingsDollarElement, By.tagName("text"), TINY_TIMEOUT); boolean isVertical = false; for (WebElement webElement : savingsDollar) { setLogString("SavingsDollar :" + getElementBySubElement(getDriver(), webElement, By.tagName("tspan"), TINY_TIMEOUT).getText(), true, CustomLogLevel.HIGH); isVertical = Integer.valueOf(webElement.getLocation().getX()) .equals(Integer.valueOf(savingsDollar.get(1).getLocation().getX())); if (!isVertical) { break; } } setLogString("SavingsDollar isVertical :" + isVertical, true, CustomLogLevel.LOW); return isVertical; }
From source file:com.ecofactor.qa.automation.newapp.page.impl.SavingsPageImpl.java
License:Open Source License
/** * @return/*from w w w. ja va 2 s . c om*/ * @see com.ecofactor.qa.automation.newapp.page.SavingsPage#isSavingsMonthHorizontal() */ @Override public boolean isSavingsMonthHorizontal() { final WebElement savingsMonthElement = getElement(getDriver(), By.className("fusioncharts-xaxis-0-gridlabels"), TINY_TIMEOUT); final List<WebElement> savingsMonth = getElementsBySubElement(getDriver(), savingsMonthElement, By.tagName("text"), TINY_TIMEOUT); boolean isHorizontal = false; for (WebElement webElement : savingsMonth) { setLogString("SavingsMonth :" + getElementBySubElement(getDriver(), webElement, By.tagName("tspan"), TINY_TIMEOUT).getText(), true, CustomLogLevel.HIGH); isHorizontal = Integer.valueOf(webElement.getLocation().getY()) .equals(Integer.valueOf(savingsMonth.get(1).getLocation().getY())); if (!isHorizontal) { break; } } setLogString("SavingsMonth isHorizontal :" + isHorizontal, true, CustomLogLevel.LOW); return isHorizontal; }
From source file:com.ecofactor.qa.automation.newapp.page.impl.ThermostatPageOpsImpl.java
License:Open Source License
/** * Target temp change value by drag.// www . j av a2 s . c om * @param change the change * @see com.ecofactor.qa.automation.newapp.page.ThermostatPageUI#targetTempChangeValueByDrag(int) */ @Override public void targetTempChangeValueByDrag(final int change) { setLogString("Verify Target Temperature Value Change", true, CustomLogLevel.HIGH); final WebElement temperatureSlider = getElement(getDriver(), By.cssSelector(".setPointContainer.ui-draggable"), TINY_TIMEOUT); if (change < 0) { getAction().doSwipeUp(temperatureSlider, temperatureSlider.getLocation().getX(), temperatureSlider.getLocation().getY(), -change, 0.5); } else { getAction().doSwipeDown(temperatureSlider, temperatureSlider.getLocation().getX(), temperatureSlider.getLocation().getY(), change, 0.5); } }
From source file:com.ecofactor.qa.automation.newapp.page.impl.ThermostatPageUIImpl.java
License:Open Source License
/** * Current temperature drag./*w w w . j a v a 2 s . c o m*/ * @param change the change * @see com.ecofactor.qa.automation.newapp.page.ThermostatPageUI#currentTemperatureDrag(int) */ @Override public void currentTemperatureDrag(int change) { final WebElement temperatureSlider = getElement(getDriver(), By.cssSelector(".currentContainer"), TINY_TIMEOUT); getAction().doSwipeDown(temperatureSlider, temperatureSlider.getLocation().getX(), temperatureSlider.getLocation().getY(), change, 0.5); }
From source file:com.ecofactor.qa.automation.platform.action.impl.AndroidUIAction.java
License:Open Source License
/** * Do swipe left./*from w ww .j a v a 2 s. c om*/ * @param element the element * @see com.ecofactor.qa.automation.mobile.action.UIAction#doSwipeLeft(org.openqa.selenium.WebElement) */ @Override public void doSwipeLeft(final WebElement element) { saveTestFlowScreenShot(); swipe(element, element.getLocation().x, element.getLocation().y, 1.0, Direction.LEFT); }
From source file:com.ecofactor.qa.automation.platform.action.impl.IOSUIAction.java
License:Open Source License
/** * Do Tap./* ww w .j a va 2s .c o m*/ * @param element the element * @see com.ecofactor.qa.automation.platform.action.UIAction#doTap(org.openqa.selenium.WebElement) */ @Override public void doTap(final WebElement element) { final JavascriptExecutor js = (JavascriptExecutor) driverOps.getDeviceDriver(); final HashMap<String, Double> tapObject = new HashMap<String, Double>(); tapObject.put("x", (double) element.getLocation().getX()); tapObject.put("y", (double) element.getLocation().getY()); js.executeScript("mobile: tap", tapObject); }
From source file:com.googlecode.fightinglayoutbugs.DetectElementsWithInvisibleFocus.java
License:Apache License
private FocusedElement toFocusedElement(@Nonnull WebElement activeElement, WebPage webPage) { // I don't trust WebDriver, that's why I determine the offset, width and height with jQuery too ... Map temp = new Gson() .fromJson(//from w w w . j ava2 s . c o m (String) webPage.executeJavaScript( "var $element = jQuery(arguments[0]);\n" + "var offset = $element.offset();\n" + "var $temp = $element.clone(false).wrap('<div></div>').parent();\n" + "try {\n" + " return JSON.stringify({\n" + " x: offset.left,\n" + " y: offset.top,\n" + " w: $element.width(),\n" + " h: $element.height(),\n" + " html: $temp.html()\n" + " });\n" + "} finally {\n" + " $temp.remove();\n" + "}", activeElement), Map.class); int x = ((Number) temp.get("x")).intValue(); int y = ((Number) temp.get("y")).intValue(); int w = ((Number) temp.get("w")).intValue(); int h = ((Number) temp.get("h")).intValue(); String html = (String) temp.get("html"); if (activeElement.isDisplayed()) { Point location = activeElement.getLocation(); Dimension size = activeElement.getSize(); int x1 = Math.min(location.getX(), x); int y1 = Math.min(location.getY(), y); int x2 = Math.max(location.getX() + size.getWidth(), x + w) - 1; int y2 = Math.max(location.getY() + size.getHeight(), y + h) - 1; return new FocusedElement(activeElement, new RectangularRegion(x1, y1, x2, y2), html); } else { return new FocusedElement(activeElement, NOT_DISPLAYED, html); } }
From source file:com.induscorp.prime.testing.ui.core.objects.DOMObjectValidator.java
License:Open Source License
@Override public void rightClick(int numRetries) { try {/* w w w . j ava 2 s .co m*/ WebElement webElem = findElement(numRetries); Point location = webElem.getLocation(); Dimension size = webElem.getSize(); browser.getSikuliScreen() .rightClick(new Region(location.getX(), location.getY(), size.getWidth(), size.getHeight())); } catch (Throwable th) { Assert.fail("Failed to perform mouse right click on element '" + domObject.getDisplayName() + "'.", th); } }
From source file:com.induscorp.prime.testing.ui.core.objects.scrollbar.Scrollbar.java
License:Open Source License
/** * Scroll element into/*from ww w. j a v a2s.c om*/ * * @param elemLocator * @param searchDirection * direction to locate element from the current focus point. */ public void scrollElementToViewport(WebBrowser browser, UIObject elemLocator) { if (elemLocator.getLocatorType() == LocatorType.DOM) { UIObject domLocator = elemLocator; WebElement webElem = null; try { // Rectangle hScrollbarThumbGripCurrLocation = // findHScrollbarThumbGripLeftPartImageLocation(); System.out.println("AAA"); Rectangle vScrollbarThumbGripCurrLocation = findVScrollbarThumbGripTopPartImageLocation(); webElem = (WebElement) domLocator.getValidator(browser, null).findElementNoException(0); boolean hsbEndReached, vsbEndReached = false; boolean vsbTGCurrPointReached = false; int vsbEndReachedCounter = 0; do { // Move vertical scrollbar hsbEndReached = false; do { // Move horizontal scrollbar if (webElem != null) { if (hScrollbar != null) { Point webElemPoint = webElem.getLocation(); Match hscM1 = hScrollbar.findLeftScrollImage(hScrollbarRegion); if (webElemPoint.getX() - hscM1.getX() <= 80) { break; } else if (hsbEndReached) { break; } else { hsbEndReached = hScrollbar.clickRightScrollImage(hScrollbarRegion, 2); webElem = (WebElement) domLocator.getValidator(browser, null) .findElementNoException(0); if (webElem == null) { hScrollbar.clickLeftScrollImage(hScrollbarRegion, 2); webElem = (WebElement) domLocator.getValidator(browser, null) .findElementNoException(0); break; } } } else { break; } } else { if (hScrollbar != null) { if (hsbEndReached) { hScrollbar.scrollThumbGripToExtremeLeft(hScrollbarRegion); break; } else { hsbEndReached = hScrollbar.clickRightScrollImage(hScrollbarRegion, 2); webElem = (WebElement) domLocator.getValidator(browser, null) .findElementNoException(0); continue; } } else { break; } } } while (true); // -----done ---- if (webElem != null) { if (vScrollbar != null) { Point webElemPoint = webElem.getLocation(); Match vscM1 = vScrollbar.findTopScrollImage(vScrollbarRegion); if (webElemPoint.getY() - vscM1.getY() <= 80) { break; } else if (vsbEndReached) { break; } else { vsbEndReached = vScrollbar.clickBottomScrollImage(vScrollbarRegion, 2); webElem = (WebElement) domLocator.getValidator(browser, null) .findElementNoException(0); if (webElem == null) { vScrollbar.clickTopScrollImage(vScrollbarRegion, 2); webElem = (WebElement) domLocator.getValidator(browser, null) .findElementNoException(0); break; } } } else { break; } } else { if (vScrollbar != null) { if (vsbEndReachedCounter > 0 && vsbTGCurrPointReached) { break; } else if (vsbEndReachedCounter == 0 && vsbEndReached) { vScrollbar.scrollThumbGripToExtremeTop(vScrollbarRegion); vsbEndReached = false; vsbEndReachedCounter++; continue; } else { vsbEndReached = vScrollbar.clickBottomScrollImage(vScrollbarRegion, 2); Rectangle vScrollbarThumbGripRunLocation = findVScrollbarThumbGripTopPartImageLocation(); if (vScrollbarThumbGripRunLocation.getY() - vScrollbarThumbGripCurrLocation.getY() >= 0) { vsbTGCurrPointReached = true; } webElem = (WebElement) domLocator.getValidator(browser, null) .findElementNoException(0); continue; } } else { break; } } } while (true); } catch (Throwable th) { Assert.fail("Failed to scroll element '" + elemLocator.getDisplayName() + "' into view port.", th); } Assert.assertNotNull(webElem, "Failed to find element '" + elemLocator.getDisplayName() + "'"); } else if (elemLocator.getLocatorType() == LocatorType.IMAGE) { UIObject imgLocator = elemLocator; Match match = null; try { // Rectangle hScrollbarThumbGripCurrLocation = // findHScrollbarThumbGripLeftPartImageLocation(); Rectangle vScrollbarThumbGripCurrLocation = findVScrollbarThumbGripTopPartImageLocation(); match = (Match) imgLocator.getValidator(browser, null).findElementNoException(0); boolean hsbEndReached, vsbEndReached = false; boolean vsbTGCurrPointReached = false; int vsbEndReachedCounter = 0; do { // Move vertical scrollbar hsbEndReached = false; do { // Move horizontal scrollbar if (match != null) { if (hScrollbar != null) { // Point webElemPoint = match.getLocation(); Match hscM1 = hScrollbar.findLeftScrollImage(hScrollbarRegion); if (match.getX() - hscM1.getX() <= 80) { break; } else if (hsbEndReached) { break; } else { hsbEndReached = hScrollbar.clickRightScrollImage(hScrollbarRegion, 2); match = (Match) imgLocator.getValidator(browser, null) .findElementNoException(0); if (match == null) { hScrollbar.clickLeftScrollImage(hScrollbarRegion, 2); match = (Match) imgLocator.getValidator(browser, null) .findElementNoException(0); break; } } } else { break; } } else { if (hScrollbar != null) { if (hsbEndReached) { hScrollbar.scrollThumbGripToExtremeLeft(hScrollbarRegion); break; } else { hsbEndReached = hScrollbar.clickRightScrollImage(hScrollbarRegion, 2); match = (Match) imgLocator.getValidator(browser, null) .findElementNoException(0); continue; } } else { break; } } } while (true); // -----done ---- if (match != null) { if (vScrollbar != null) { // Point webElemPoint = match.getLocation(); Match vscM1 = vScrollbar.findTopScrollImage(vScrollbarRegion); if (match.getY() - vscM1.getY() <= 80) { break; } else if (vsbEndReached) { break; } else { vsbEndReached = vScrollbar.clickBottomScrollImage(vScrollbarRegion, 2); match = (Match) imgLocator.getValidator(browser, null).findElementNoException(0); if (match == null) { vScrollbar.clickTopScrollImage(vScrollbarRegion, 2); match = (Match) imgLocator.getValidator(browser, null) .findElementNoException(0); break; } } } else { break; } } else { if (vScrollbar != null) { if (vsbEndReachedCounter > 0 && vsbTGCurrPointReached) { break; } else if (vsbEndReachedCounter == 0 && vsbEndReached) { vScrollbar.scrollThumbGripToExtremeTop(vScrollbarRegion); vsbEndReached = false; vsbEndReachedCounter++; continue; } else { vsbEndReached = vScrollbar.clickBottomScrollImage(vScrollbarRegion, 2); Rectangle vScrollbarThumbGripRunLocation = findVScrollbarThumbGripTopPartImageLocation(); if (vScrollbarThumbGripRunLocation.getY() - vScrollbarThumbGripCurrLocation.getY() >= 0) { vsbTGCurrPointReached = true; } match = (Match) imgLocator.getValidator(browser, null).findElementNoException(0); continue; } } else { break; } } } while (true); } catch (Throwable th) { Assert.fail("Failed to scroll element '" + elemLocator.getDisplayName() + "' into view port.", th); } Assert.assertNotNull(match, "Failed to find element '" + elemLocator.getDisplayName() + "'"); } }