Java 类org.openqa.selenium.Rectangle 实例源码

项目:selenium-components    文件:AnimatedSeleniumComponent.java   
default void waitUntilAnimationFinished()
{
    SeleniumUtils.keepTrying(SeleniumGlobals.getLongTimeoutInSeconds(), () -> {
        WebElement element = element();

        if (element.isDisplayed())
        {
            return false;
        }

        Rectangle bounds = element.getRect();

        SeleniumUtils.waitForSeconds(0.1);

        return Objects.equals(element.getRect(), bounds) ? true : null;
    });
}
项目:xframium-java    文件:ReportingWebElementAdapter.java   
@Override
public Rectangle getRect()
{
    Rectangle returnValue = null;
    webDriver.getExecutionContext().startStep( createStep( "AT" ), null, null );
    try
    {
        returnValue = baseElement.getRect();
    }
    catch( Exception e )
    {
        webDriver.getExecutionContext().completeStep( StepStatus.FAILURE, e );
    }

    webDriver.getExecutionContext().completeStep( StepStatus.SUCCESS, null );

    return returnValue;
}
项目:xframium-java    文件:ByImage.java   
@Override
public List<WebElement> findElements( SearchContext context )
{
    if ( imageName != null )
    {
        Rectangle r = webDriver.getCloud().getCloudActionProvider().findImage( webDriver, imageName, propertyMap );
        if ( r != null )
        {
            List<WebElement> elementList = new ArrayList<WebElement>( 1 );
            elementList.add( new VisualWebElement( webDriver, r ) );
            return elementList;
        }
    }

    return null;
}
项目:xframium-java    文件:ByOCR.java   
@Override
public List<WebElement> findElements( SearchContext context )
{
    if ( text != null )
    {
        Rectangle r = webDriver.getCloud().getCloudActionProvider().findText( webDriver, text, propertyMap );
        if ( r != null )
        {
            List<WebElement> elementList = new ArrayList<WebElement>( 1 );
            elementList.add( new VisualWebElement( webDriver, r ) );
            return elementList;
        }
    }

    return null;
}
项目:carina    文件:ScreenElementExtractor.java   
@Override
public ExtendedWebElement getElementsByCoordinates(int x, int y) {
    String elementName = String.format("Element founded by x:%d - y:%d", x, y);
    WebDriver driver = DriverPool.getDriver();
    List<WebElement> elements = getEndLevelElements(driver);
    List<WebElement> result = new ArrayList<WebElement>();
    Rectangle rect;
    for (WebElement webElement : elements) {
        try {
            rect = getRect(webElement);
        } catch (Exception e) {
            continue;
        }
        if (isInside(rect, x, y)) {
            result.add(webElement);
        }
    }
    return generateExtenedElement(result, driver, elementName);
}
项目:xframium-java    文件:PERFECTOCloudActionProvider.java   
@Override
public Rectangle findImage( DeviceWebDriver webDriver, String imageName, Map<String, String> propertyMap )
{

    ImageExecution imageExec = PerfectoMobile.instance( webDriver.getxFID() ).imaging().imageExists( webDriver.getExecutionId(), webDriver.getDeviceName(), imageName, propertyMap );

    if ( imageExec != null && Boolean.parseBoolean( imageExec.getStatus() ) )
        return new Rectangle( new Point( Integer.parseInt( imageExec.getLeft() ), Integer.parseInt( imageExec.getTop() ) ), new Dimension( Integer.parseInt( imageExec.getWidth() ), Integer.parseInt( imageExec.getHeight() ) ) );

    return null;
}
项目:xframium-java    文件:PERFECTOCloudActionProvider.java   
@Override
public Rectangle findText( DeviceWebDriver webDriver, String text, Map<String, String> propertyMap )
{
    ImageExecution imageExec = PerfectoMobile.instance( webDriver.getxFID() ).imaging().textExists( webDriver.getExecutionId(), webDriver.getDeviceName(), text, propertyMap );


    if ( imageExec != null && Boolean.parseBoolean( imageExec.getStatus() ) )
           return new Rectangle( new Point( Integer.parseInt( imageExec.getLeft() ), Integer.parseInt( imageExec.getTop() ) ), new Dimension( Integer.parseInt( imageExec.getWidth() ), Integer.parseInt( imageExec.getHeight() ) ) );

    return null;
}
项目:xframium-java    文件:VisualWebElement.java   
public VisualWebElement ( DeviceWebDriver webDriver, Rectangle r )
{
    this.location = r.getPoint();
    this.size = r.getDimension();
    this.webDriver = webDriver;

}
项目:hsac-fitnesse-fixtures    文件:CachingRemoteWebElement.java   
@Override
public Rectangle getRect() {
    if (rectCache == null) {
        rectCache = new ObjectCache<>(super::getRect);
    }
    return rectCache.getValue();
}
项目:darcy-webdriver    文件:TargetedWebElementTest.java   
@Test
public void shouldCallGetRectOnUnderlyingWebElement() {
    WebDriver.TargetLocator locator = mock(WebDriver.TargetLocator.class);
    WebDriverTarget target = mock(WebDriverTarget.class);
    TargetedWebElement element = mock(TargetedWebElement.class);
    when(element.getRect()).thenReturn(mock(Rectangle.class));
    TargetedWebElement targetedWebElement = new TargetedWebElement(locator, target, element);

    targetedWebElement.getRect();
    verify(element).getRect();
}
项目:carina    文件:Screen.java   
@Override
public ICapturable highlight(Rectangle rect)
{
    try
    {
        Graphics2D g2d = screenshot.createGraphics();
        g2d.setColor(Color.red);
        g2d.drawRect(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
    }
    catch (Exception e) 
    {
        LOGGER.error("Unable to highligh screenshot: " + e.getMessage());
    }
    return this;
}
项目:carina    文件:AbstractElementExtractor.java   
/**
 * Method return 1 in case if y is lower than element, -1 if higher, 0 - if
 * 'y' within the element's range
 * 
 * @param rect Rectangle
 * @param y int
 * @return int
 */
public int isLower(Rectangle rect, int y) {
    LOGGER.debug(String.format("isLower(): Rectangle: x - %d. y - %d. Width: %d, height: %d", rect.x, rect.y, rect.width, rect.height));
    if (y > rect.y + rect.height) {
        return 1;
    } else if (y < rect.y) {
        return -1;
    }
    return 0;
}
项目:carina    文件:DivisionElementExtractor.java   
@Override
public ExtendedWebElement getElementsByCoordinates(int x, int y) {
    String elementName = String.format("Element founded by x:%d - y:%d", x, y);
    WebDriver driver = DriverPool.getDriver();
    List<WebElement> elements = getEndLevelElements(driver);
    WebElement tempElement;
    int index = 0;
    int isLower;
    Rectangle tempRect;
    while (elements.size() != 1) {
        index = (int) (Math.round(elements.size() / 2));
        tempElement = elements.get(index);
        tempRect = getRect(tempElement);
        isLower = isLower(tempRect, y);
        LOGGER.debug("Is Lower: " + isLower);
        if (isInside(tempRect, x, y) || isLower == 0) {
            break;
        }
        if (isLower == 1) {
            elements = elements.subList(index, elements.size());
        } else {
            elements = elements.subList(0, index);
        }
    }
    LOGGER.debug("Index: " + index);

    if (elements.size() == 1) {
        return generateExtenedElement(elements, driver, elementName);
    }

    return generateExtenedElement(checkBoundaryElements(elements, x, y, index), driver, elementName);
}
项目:carina    文件:DivisionElementExtractor.java   
/**
 * Method to check boundary elements since there is a chance that there are
 * some elements in the same 'y' range
 * 
 * @param elements
 * @param x
 * @param y
 * @param index
 * @return
 */
private List<WebElement> checkBoundaryElements(List<WebElement> elements, int x, int y, int index) {
    LOGGER.debug(String.format("Index: %d.", index));
    List<WebElement> elementsFirstPart = elements.subList(0, index);
    List<WebElement> elementsSecondPart = elements.subList(index, elements.size());
    List<WebElement> elementsInside = new ArrayList<WebElement>();
    WebElement element;
    Rectangle tempRect;
    for (int i = elementsFirstPart.size() - 1; i >= 0; i--) {
        element = elementsFirstPart.get(i);
        tempRect = getRect(element);
        if (isInside(tempRect, x, y)) {
            elementsInside.add(element);
        } else if (tempRect.y > y) {
            // stop validation as soon as 'y' coordinate will be out of
            // element's location
            break;
        }
    }

    for (int i = 0; i < elementsSecondPart.size(); i++) {
        element = elementsSecondPart.get(i);
        tempRect = getRect(element);

        if (isInside(tempRect, x, y)) {
            elementsInside.add(element);
        } else if (tempRect.y + tempRect.height < y) {
            // stop validation as soon as 'y' coordinate will be out of
            // element's location
            break;
        }
    }
    return elementsInside;
}
项目:BrainBridge    文件:StaleRefresherWebElement.java   
@Override
public Rectangle getRect() {
    ensureReferenceNotStaled();
    return this.mElement.getRect();
}
项目:bobcat    文件:BobcatWebElement.java   
@Override
public Rectangle getRect() {
  return element.getRect();
}
项目:xframium-java    文件:CachedWebElement.java   
public Rectangle getRect()
{
    return new Rectangle( getLocation(), getSize() );
}
项目:xframium-java    文件:AbstractCloudActionProvider.java   
@Override
public Rectangle findText( DeviceWebDriver webDriver, String text, Map<String, String> propertyMap )
{
    return null;
}
项目:xframium-java    文件:AbstractCloudActionProvider.java   
@Override
public Rectangle findImage( DeviceWebDriver webDriver, String imageName, Map<String, String> propertyMap )
{
    return null;
}
项目:xframium-java    文件:VisualWebElement.java   
@Override
public Rectangle getRect()
{
    return new Rectangle( location, size );
}
项目:Sparkle    文件:AntiTrapWebElement.java   
@Override
public Rectangle getRect() {
    return this.mElement.getRect();
}
项目:Sparkle    文件:DelayedWebElement.java   
@Override
public Rectangle getRect() {
    return this.mElement.getRect();
}
项目:Sparkle    文件:StaleRefresherWebElement.java   
@Override
public Rectangle getRect() {
    ensureReferenceNotStaled();
    return this.mElement.getRect();
}
项目:blog-java2    文件:ClickAndWaitRemoteWebElement.java   
@Override
public Rectangle getRect() {
    return parent.getRect();
}
项目:darcy-webdriver    文件:TargetedWebElement.java   
@Override
public Rectangle getRect() {
    return element().getRect();
}
项目:minium    文件:DocumentWebElement.java   
@Override
public Rectangle getRect() {
    webDriver.ensureSwitch();
    return webElement.getRect();
}
项目:minium    文件:MockWebElement.java   
@Override
public Rectangle getRect() {
    return null;
}
项目:carina    文件:AbstractElementExtractor.java   
public boolean isInside(Rectangle rect, int x, int y) {
    return rect.x <= x && rect.x + rect.width >= x && rect.y <= y && rect.y + rect.height >= y;
}
项目:carina    文件:ICapturable.java   
/**
 * Highlights rectangle on screenshot.
 * @param rect - of region to highlight
 * @return {@link ICapturable} instance
 */
ICapturable highlight(Rectangle rect);
项目:carina    文件:AbstractElementExtractor.java   
/**
* 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());
  }
项目:xframium-java    文件:CloudActionProvider.java   
public Rectangle findImage( DeviceWebDriver webDriver, String imageName, Map<String,String> propertyMap );
项目:xframium-java    文件:CloudActionProvider.java   
public Rectangle findText( DeviceWebDriver webDriver, String text, Map<String,String> propertyMap );
项目:Testy    文件:WebLocatorExecutor.java   
Rectangle getRect(WebLocator el);