Codota Logo
WebElement.getSize
Code IndexAdd Codota to your IDE (free)

How to use
getSize
method
in
org.openqa.selenium.WebElement

Best Java code snippets using org.openqa.selenium.WebElement.getSize (Showing top 20 results out of 657)

  • Common ways to obtain WebElement
private void myMethod () {
WebElement w =
  • Codota IconWebDriver driver;By by;driver.findElement(by)
  • Codota IconWebDriver driver;String id;driver.findElement(By.id(id))
  • Codota IconWebDriver driver;driver.findElement(By.tagName("body"))
  • Smart code suggestions by Codota
}
origin: selenide/selenide

private BufferedImage takeScreenshotAsImage(WebDriver webdriver, WebElement element) {
 if (!(webdriver instanceof TakesScreenshot)) {
  log.warning("Cannot take screenshot because browser does not support screenshots");
  return null;
 }
 byte[] screen = ((TakesScreenshot) webdriver).getScreenshotAs(OutputType.BYTES);
 Point elementLocation = element.getLocation();
 try {
  BufferedImage img = ImageIO.read(new ByteArrayInputStream(screen));
  int elementWidth = element.getSize().getWidth();
  int elementHeight = element.getSize().getHeight();
  if (elementWidth > img.getWidth()) {
   elementWidth = img.getWidth() - elementLocation.getX();
  }
  if (elementHeight > img.getHeight()) {
   elementHeight = img.getHeight() - elementLocation.getY();
  }
  return img.getSubimage(elementLocation.getX(), elementLocation.getY(), elementWidth, elementHeight);
 }
 catch (IOException e) {
  log.log(SEVERE, "Failed to take screenshot of " + element, e);
  return null;
 }
 catch (RasterFormatException e) {
  log.warning("Cannot take screenshot because element is not displayed on current screen position");
  return null;
 }
}
origin: selenide/selenide

 return null;
int iframeHeight = iframe.getSize().getHeight();
SelenideTargetLocator switchTo = new SelenideTargetLocator(driver.config(), driver.getWebDriver());
switchTo.frame(iframe);
int elementWidth = element.getSize().getWidth();
int elementHeight = element.getSize().getHeight();
if (elementWidth > iframeWidth) {
 elementWidth = iframeWidth - elementLocation.getX();
origin: galenframework/galen

  @Override
  public Rect findArea(WebPageElement webPageElement) {
    WebElement webElement = webPageElement.getWebElement();
    Point location = webElement.getLocation();
    Dimension size = webElement.getSize();
    return new Rect(location.getX(), location.getY(), size.getWidth(), size.getHeight());
  }
}),
origin: TEAMMATES/teammates

/**
 * Checks if the midpoint of an element is covered by any other element.
 * @return true if element is covered, false otherwise.
 */
public boolean isElementCovered(WebElement element) {
  int x = element.getLocation().x + element.getSize().width / 2;
  int y = element.getLocation().y + element.getSize().height / 2;
  WebElement topElem = (WebElement) executeScript("return document.elementFromPoint(" + x + "," + y + ");");
  return !topElem.equals(element);
}
origin: org.rapidpm/rapidpm-vaadin-testbench-ng-m-pageobject

@Override
public Dimension getSize() {
 if (delegateWebElement != null) {
  return delegateWebElement.getSize();
 } else {
  return wrappedWebElement.getSize();
 }
}
origin: yandex-qatools/htmlelements

/**
 * Gets width and height of the rendered element. See {@link org.openqa.selenium.WebElement#getSize()}
 * for more details.
 *
 * @return The size of the element on the page.
 */
@Override
public Dimension getSize() {
  return wrappedElement.getSize();
}
origin: com.vaadin/vaadin-testbench-core

@Override
public Dimension getSize() {
  waitForVaadin();
  return wrappedElement.getSize();
}
origin: qaprosoft/carina

/**
 * Method to generate rectangle for the element since current version of
 * appium driver throws unimplemented exception
 * 
 * @param element WebElement
 * @return Rectangle
 */
public Rectangle getRect(WebElement element) {
  return new Rectangle(element.getLocation(), element.getSize());
}
origin: vmi/selenese-runner-java

  @Override
  public Integer execute(Context context, String... args) {
    return context.findElement(args[ARG_LOCATOR]).getSize().getHeight();
  }
}
origin: qaprosoft/carina

@Override
public Dimension doGetSize() {
  Dimension dim = element.getSize();
  LOGGER.debug(Messager.ELEMENT_ATTRIBUTE_FOUND.getMessage("Size", dim.toString(), getName()));
  return dim;
}
origin: com.atlassian.selenium/atlassian-webdriver-core

@Override
public int getRight()
{
  return getLeft() + getElement().getSize().getWidth();
}
origin: com.atlassian.jira/atlassian-jira-pageobjects

public EditIssueTypeSchemePage moveFromAvailableToAboveSelected(final String availableIssueType, final String selectedIssueType)
{
  WebElement source = getIssueTypeListItemFromAvailableOptions(availableIssueType);
  WebElement target = getIssueTypeListItemFromSelectedOptions(selectedIssueType);
  final double offset = target.getSize().getHeight() * DROP_TARGET_RATIO;
  dragAndDropWithOffset(source, target, (int) -offset);
  return this;
}
origin: com.atlassian.jira/atlassian-jira-pageobjects

public EditIssueTypeSchemePage moveFromSelectedToAboveAvailable(final String selectedIssueType, final String availableIssueType)
{
  WebElement source = getIssueTypeListItemFromSelectedOptions(selectedIssueType);
  WebElement target = getIssueTypeListItemFromAvailableOptions(availableIssueType);
  final double offset = target.getSize().getHeight() * DROP_TARGET_RATIO;
  dragAndDropWithOffset(source, target, (int) -offset);
  return this;
}
origin: pazone/ashot

  @Override
  public Coords ofElement(WebDriver driver, WebElement element) {
    Point point = element.getLocation();
    Dimension dimension = element.getSize();
    return new Coords(
        point.getX(),
        point.getY(),
        dimension.getWidth(),
        dimension.getHeight());
  }
}
origin: com.atlassian.jira/atlassian-jira-pageobjects

private void dragAndDropWithOffset(final WebElement source, final WebElement target, final int offset)
{
  Point currentLocation = source.getLocation();
  Point destination = target.getLocation();
  // We need to ensure we have the source in view. An egrgarious hack to make sure we can do this.
  // Assumes that scrolling to the top of the page will have our source AND target in the viewable area
  driver.findElement(By.tagName("body")).getSize();
  int xOffset = destination.x - currentLocation.x + 1;
  int yOffset = destination.y - currentLocation.y + offset;
  Actions action = new Actions(driver).dragAndDropBy(source, xOffset, yOffset);
  action.perform();
}
origin: paypal/SeLion

@Override
public void swipeDown(WebElement webElement) {
  logger.entering(webElement);
  Point currentLocation = webElement.getLocation();
  Dimension elementSize = webElement.getSize();
  int x = currentLocation.getX();
  int y = currentLocation.getY();
  int endy = y + elementSize.getHeight() - 1;
  this.swipe(x, y, x, endy, OPERATION_DURATION_MILLI_SECONDS);
  logger.exiting();
}
origin: paypal/SeLion

@Override
public void swipeRight(WebElement webElement) {
  logger.entering(webElement);
  Point currentLocation = webElement.getLocation();
  Dimension elementSize = webElement.getSize();
  int x = currentLocation.getX();
  int y = currentLocation.getY();
  int endx = x + elementSize.getWidth() - 1;
  this.swipe(x,y,endx, y, OPERATION_DURATION_MILLI_SECONDS);
  logger.exiting();
}
origin: paypal/SeLion

@Override
public void swipeRight(WebElement webElement) {
  logger.entering(webElement);
  Point point = webElement.getLocation();
  Dimension dimension = webElement.getSize();
  Point start = new Point(point.getX(), point.getY());
  Point end = new Point(point.getX() + dimension.getWidth() - 1, point.getY());
  performSwipeAction(start, end);
  logger.exiting();
}
origin: paypal/SeLion

@Override
public void swipeUp(WebElement webElement) {
  logger.entering(webElement);
  Point point = webElement.getLocation();
  Dimension dimension = webElement.getSize();
  Point start = new Point(point.getX(), point.getY() + dimension.getHeight() - 1);
  Point end = new Point(point.getX(), point.getY());
  performSwipeAction(start, end);
  logger.exiting();
}
origin: Wikia/selenium-tests

public void shouldBeFullscreenAfterClickOnIcon() {
 HiViUap hiViUap = new HiViUap(driver, slotName);
 hiViUap.waitForAdLoaded();
 hiViUap.waitForVideoStart();
 hiViUap.clickFullscreenIcon();
 Dimension windowSize = driver.findElement(By.cssSelector("body")).getSize();
 Assertion.assertEquals(hiViUap.getVideoWidth(), windowSize.width);
}
org.openqa.seleniumWebElementgetSize

Javadoc

What is the width and height of the rendered element?

Popular methods of WebElement

  • getText
    Get the visible (i.e. not hidden by CSS) text of this element, including sub-elements.
  • click
    Click this element. If this causes a new page to load, you should discard all references to this ele
  • sendKeys
    Use this method to simulate typing into an element, which may set its value.
  • getAttribute
    Get the value of the given attribute of the element. Will return the current value, even if this has
  • clear
    If this element is a text entry element, this will clear the value. Has no effect on other elements.
  • isDisplayed
    Is this element displayed or not? This method avoids the problem of having to parse an element's "st
  • findElements
    Find all elements within the current context using the given mechanism. When using xpath be aware th
  • isSelected
    Determine whether or not this element is selected or not. This operation only applies to input eleme
  • findElement
    Find the first WebElement using the given method. See the note in #findElements(By) about finding vi
  • getTagName
    Get the tag name of this element. Not the value of the name attribute: will return"input" for the el
  • isEnabled
    Is the element currently enabled or not? This will generally return true for everything but disabled
  • getLocation
    Where on the page is the top left-hand corner of the rendered element?
  • isEnabled,
  • getLocation,
  • submit,
  • getCssValue,
  • getRect,
  • getScreenshotAs,
  • getValue,
  • setSelected,
  • toggle

Popular in Java

  • Making http post requests using okhttp
  • onRequestPermissionsResult (Fragment)
  • startActivity (Activity)
  • onCreateOptionsMenu (Activity)
  • ObjectMapper (com.fasterxml.jackson.databind)
    This mapper (or, data binder, or codec) provides functionality for converting between Java objects (
  • BufferedReader (java.io)
    Reads text from a character-input stream, buffering characters so as to provide for the efficient re
  • String (java.lang)
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • JFrame (javax.swing)
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now