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

项目:phoenix.webui.framework    文件:TargetElementMark.java   
@Override
public void mark(WebElement ele, File file) throws IOException
{
    BufferedImage bufImg = ImageIO.read(file);

    try
    {
        WebElement webEle = (WebElement) ele;
        Point loc = webEle.getLocation();
        Dimension size = webEle.getSize();

        Graphics2D g = bufImg.createGraphics();
        g.setColor(Color.red);
        g.drawRect(loc.getX(), loc.getY(), size.getWidth(), size.getHeight());
    }
    catch(StaleElementReferenceException se)
    {
    }
}
项目:marathonv5    文件:JavaDriverTest.java   
public void windowSetPosition() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    Window window = driver.manage().window();
    Point actual = window.getPosition();
    AssertJUnit.assertNotNull(actual);
    java.awt.Point expected = EventQueueWait.call(frame, "getLocation");
    AssertJUnit.assertEquals(expected.x, actual.x);
    AssertJUnit.assertEquals(expected.y, actual.y);
    window.setPosition(new Point(expected.x + 10, expected.y + 10));
    actual = window.getPosition();
    AssertJUnit.assertEquals(expected.x + 10, actual.x);
    AssertJUnit.assertEquals(expected.y + 10, actual.y);
}
项目:WebAndAppUITesting    文件:IphoneBaseOpt.java   
/**
 * 判断要点击的元素是否被其它元素覆盖
 * 
 * @param clickBy
 * @param coverBy
 * @return
 */
public boolean isCover(By clickBy, By coverBy) {

    MobileElement clickElement = getDriver().findElement(clickBy);
    MobileElement coverElement = getDriver().findElement(coverBy);

    // 获取控件开始位置高度
    Point clickstart = clickElement.getLocation();
    int clickStartY = clickstart.y;

    Point coverstart = coverElement.getLocation();
    int coverStartY = coverstart.y;

    // 获取控件高度
    Dimension firstq = clickElement.getSize();
    int height = firstq.getHeight();

    // 控件中间高度是否大于底部高度
    if (clickStartY + height / 2 >= coverStartY) {
        return true;
    }
    return false;
}
项目:WebAndAppUITesting    文件:AndroidBaseOpt.java   
/**
 * 判断要点击的元素是否被其它元素覆盖
 * 
 * @param clickBy
 * @param coverBy
 * @return
 */
public boolean isCover(By clickBy, By coverBy) {

    MobileElement clickElement = getDriver().findElement(clickBy);
    MobileElement coverElement = getDriver().findElement(coverBy);

    // 获取控件开始位置高度
    Point clickstart = clickElement.getLocation();
    int clickStartY = clickstart.y;

    Point coverstart = coverElement.getLocation();
    int coverStartY = coverstart.y;

    // 获取控件高度
    Dimension firstq = clickElement.getSize();
    int height = firstq.getHeight();

    // 控件中间高度是否大于底部高度
    if (clickStartY + height / 2 >= coverStartY) {

        return true;
    }
    return false;
}
项目:opentest    文件:ReadElementAspect.java   
@Override
public void run() {
    super.run();

    By locator = readLocatorArgument("locator");

    MobileElement element = getElement(locator);
    Point point = element.getLocation();

    int x = point.getX();
    int y = point.getY();

    int width = element.getSize().width;
    int height = element.getSize().height;

    Logger.trace(String.format("The element aspect is (%s,%s,%s,%s)",
            x, y, width, height));

    this.writeOutput("x", x);
    this.writeOutput("y", y);
    this.writeOutput("width", width);
    this.writeOutput("height", height);
}
项目:opentest    文件:AppiumTestAction.java   
protected void swipeDown(MobileElement element) {
        Point point = element.getLocation();
        Dimension size = driver.manage().window().getSize();

        int screenHeight = (int) (size.height * 0.90);
        int elementY = point.getY();

        int endX = 0;
        int endY = ((int) screenHeight - elementY);
//        Logger.debug("Device height:" + size.getHeight() + "$$$ Device width:" + size.getWidth());
//        Logger.debug("Element X:" + point.getX() + "$$$ Element Y:" + point.getY());
//        Logger.debug("Element Height:" + element.getSize().height + "$$$$ Element Width:" + element.getSize().width);
//        Logger.debug("end X:" + endX + "$$$$end Y:" + endY);
        TouchAction action = new TouchAction((MobileDriver) driver);
        //action.press(element).moveTo(endX, endY).release().perform();
        action.press(element.getCenter().getX(), element.getCenter().getY()).moveTo(endX, screenHeight - element.getCenter().getY()).release().perform();

    }
项目:opentest    文件:AppiumTestAction.java   
protected void swipeRight(MobileElement element) {
        Point point = element.getLocation();
        Point p = element.getCenter();

        Dimension size = driver.manage().window().getSize();

        int screenWidth = (int) (size.width * 0.90);
        // int elementX = point.getX();
        int elementX = p.getX();

        int endY = 0;
        int endX = element.getSize().getWidth();
//        Logger.debug("Device height:" + size.getHeight() + "$$$ Device width:" + size.getWidth());
//        Logger.debug("Element X:" + point.getX() + "$$$ Element Y:" + point.getY());
//        Logger.debug("Element Height:" + element.getSize().height + "$$$$ Element Width:" + element.getSize().width);
//        Logger.debug("end X:" + endX + "$$$$end Y:" + endY);
        TouchAction action = new TouchAction((MobileDriver) driver);
        //action.press(element).moveTo(endX, endY).release().perform();
        action.press((int) (point.getX() + (element.getSize().getWidth() * 0.10)), element.getCenter().getY()).moveTo((int) (screenWidth - (point.getX() + (element.getSize().getWidth() * 0.10))), endY).release().perform();

    }
项目:opentest    文件:AppiumTestAction.java   
protected void returnElementPosition(MobileElement element) {

        Point point;
        MobileElement element1;

        List<MobileElement> allElements = (List<MobileElement>) element.findElements(By.xpath(".//*"));

        for (int i = 0; i < allElements.size(); i++) {
            element1 = allElements.get(i);
            point = element1.getLocation();

            int x = point.getX();
            int y = point.getY();

            int width = element.getSize().width;
            int height = element.getSize().height;
            break;
        }
    }
项目:BHBot    文件:MainThread.java   
/**
 * Note: raid window must be open for this to work!
 * 
 * Returns false in case it failed.
 */
private boolean setRaidType(int newType, int currentType) {
    final Color off = new Color(147, 147, 147); // color of center pixel of turned off button

    MarvinSegment seg = detectCue(cues.get("RaidLevel"));
    if (seg == null) {
        // error!
        BHBot.log("Error: Changing of raid type failed - raid type button not detected.");
        return false;
    }

    Point center = new Point(seg.x1 + 7, seg.y1 + 7); // center of the raid button
    int move = newType - currentType;
    Point pos = center.moveBy(move*25, 0);

    clickInGame(pos.x, pos.y);

    return true;
}
项目:bobcat    文件:DroppableWebElement.java   
/**
 * @return Point in the middle of the drop area.
 */
@Override
public Point getCurrentLocation() {
  Point inViewPort = null;
  switcher.switchTo(getFramePath());
  try {
    Dimension size = dropArea.getSize();
    inViewPort = ((Locatable) dropArea).getCoordinates().inViewPort()
        .moveBy(size.getWidth() / 2, size.getHeight() / 2);
  } finally {
    switcher.switchBack();
  }
  return inViewPort;
}
项目:EarthWorm    文件:BrowserAction.java   
/**
 * Check Element Position
 * @param xpath
 * @param X
 * @param Y
 */
public void expectLocation(String xpath, int X, int Y){
    if(elementExist(xpath)){
        Point point = be.getElementPosition(xpath);
        if(point.getX()==X && point.getY()==Y){
            logger.info("***** Position Right!\n");
            HtmlLogUtil.appendLog2Html(htmlLogFile, 1, "元素位置检验正确 : ["+xpath+"]");
        }
        else{
            logger.info("***** Position Error!\n");
            HtmlLogUtil.appendLog2Html(htmlLogFile, 0, "元素位置检验错误 : ["+xpath+"] X="+point.getX()+"  Y="+point.getY());
        }

    }
    else
        elementOut();
}
项目:xframium-java    文件:ReportingWebElementAdapter.java   
@Override
public Point getLocation()
{
    Point returnValue = null;
    webDriver.getExecutionContext().startStep( createStep( "AT" ), null, null );
    try
    {
        returnValue = baseElement.getLocation();
    }
    catch( Exception e )
    {
        webDriver.getExecutionContext().completeStep( StepStatus.FAILURE, e );
    }

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

    return returnValue;
}
项目:xframium-java    文件:ReportingElementAdapter.java   
@Override
public Point getAt()
{
    getWebDriver().getExecutionContext().startStep( createStep( "AT" ), null, null );
    Point returnValue = null;

    try
    {
        returnValue = baseElement.getAt();
    }
    catch( Exception e )
    {
        getWebDriver().getExecutionContext().completeStep( StepStatus.FAILURE, e );
        throw e;
    }

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

    return returnValue;
}
项目:xframium-java    文件:CachedWebElement.java   
@Override
public Point getLocation()
{
    try
    {
        String x = null, y = null;

        x=getAttribute( "x" );
        y=getAttribute( "y" );
        if ( x != null && y != null )
            return new Point( Integer.parseInt( x ), Integer.parseInt( y ) );
        else
            return new Point( 0, 0 );
    }
    catch( Exception e )
    {
        return webDriver.findElement( by ).getLocation();
    }
}
项目:xframium-java    文件:PressGesture.java   
@Override
protected boolean _executeGesture( WebDriver webDriver )
{
    AppiumDriver appiumDriver = null;

    if ( webDriver instanceof AppiumDriver )
        appiumDriver = (AppiumDriver) webDriver;
    else if ( webDriver instanceof NativeDriverProvider )
    {
        NativeDriverProvider nativeProvider = (NativeDriverProvider) webDriver;
        if ( nativeProvider.getNativeDriver() instanceof AppiumDriver )
            appiumDriver = (AppiumDriver) nativeProvider.getNativeDriver();
        else
            throw new IllegalArgumentException( "Unsupported Driver Type " + webDriver );
    }
    Dimension screenDimension = appiumDriver.manage().window().getSize();

    Point pressPosition = getActualPoint( getPressPosition(), screenDimension );

    TouchAction swipeAction = new TouchAction( appiumDriver );
    swipeAction.press(  pressPosition.getX(), pressPosition.getY() ).waitAction( Duration.ofMillis( getPressLength() ) ).release().perform();

    return true;
}
项目:xframium-java    文件:SwipeGesture.java   
@Override
protected boolean _executeGesture( WebDriver webDriver )
{
    AppiumDriver appiumDriver = null;

    if ( webDriver instanceof AppiumDriver )
        appiumDriver = (AppiumDriver) webDriver;
    else if ( webDriver instanceof NativeDriverProvider )
    {
        NativeDriverProvider nativeProvider = (NativeDriverProvider) webDriver;
        if ( nativeProvider.getNativeDriver() instanceof AppiumDriver )
            appiumDriver = (AppiumDriver) nativeProvider.getNativeDriver();
        else
            throw new IllegalArgumentException( "Unsupported Driver Type " + webDriver );
    }
    Dimension screenDimension = appiumDriver.manage().window().getSize();

    Point actualStart = getActualPoint( getSwipeStart(), screenDimension );
    Point actualEnd = getActualPoint( getSwipeEnd(), screenDimension );

    TouchAction swipeAction = new TouchAction( appiumDriver );
    swipeAction.press( actualStart.getX(), actualStart.getY() ).moveTo( actualEnd.getX(), actualEnd.getY() ).release().perform();

    return true;
}
项目:xframium-java    文件:GestureManager.java   
/**
 * Creates the swipe.
 *
 * @param swipeDirection
 *            the swipe direction
 * @return the gesture
 */
public Gesture createSwipe( String xFID, Direction swipeDirection )
{
    switch ( swipeDirection )
    {
        case DOWN:
            return createSwipe( xFID, new Point( 50, 15 ), new Point( 50, 85 ) );

        case LEFT:
            return createSwipe( xFID, new Point( 55, 50 ), new Point( 85, 50 ) );

        case RIGHT:
            return createSwipe( xFID, new Point( 85, 50 ), new Point( 15, 50 ) );

        case UP:
            return createSwipe( xFID, new Point( 50, 85 ), new Point( 50, 15 ) );

        default:
            return null;
    }
}
项目:menggeqa    文件:AppiumDriver.java   
/**
 * Convenience method for pinching an element on the screen.
 * "pinching" refers to the action of two appendages pressing the
 * screen and sliding towards each other.
 * NOTE:
 * This convenience method places the initial touches around the element, if this would
 * happen to place one of them off the screen, appium with return an outOfBounds error.
 * In this case, revert to using the MultiTouchAction api instead of this method.
 *
 * @param el The element to pinch.
 */
public void pinch(WebElement el) {
    MultiTouchAction multiTouch = new MultiTouchAction(this);

    Dimension dimensions = el.getSize();
    Point upperLeft = el.getLocation();
    Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2,
        upperLeft.getY() + dimensions.getHeight() / 2);
    int yOffset = center.getY() - upperLeft.getY();

    TouchAction action0 =
        new TouchAction(this).press(el, center.getX(), center.getY() - yOffset).moveTo(el)
            .release();
    TouchAction action1 =
        new TouchAction(this).press(el, center.getX(), center.getY() + yOffset).moveTo(el)
            .release();

    multiTouch.add(action0).add(action1);

    multiTouch.perform();
}
项目:menggeqa    文件:AppiumDriver.java   
/**
 * Convenience method for "zooming in" on an element on the screen.
 * "zooming in" refers to the action of two appendages pressing the screen and sliding
 * away from each other.
 * NOTE:
 * This convenience method slides touches away from the element, if this would happen
 * to place one of them off the screen, appium will return an outOfBounds error.
 * In this case, revert to using the MultiTouchAction api instead of this method.
 *
 * @param el The element to pinch.
 */
public void zoom(WebElement el) {
    MultiTouchAction multiTouch = new MultiTouchAction(this);

    Dimension dimensions = el.getSize();
    Point upperLeft = el.getLocation();
    Point center = new Point(upperLeft.getX() + dimensions.getWidth() / 2,
        upperLeft.getY() + dimensions.getHeight() / 2);
    int yOffset = center.getY() - upperLeft.getY();

    TouchAction action0 = new TouchAction(this).press(center.getX(), center.getY())
        .moveTo(el, center.getX(), center.getY() - yOffset).release();
    TouchAction action1 = new TouchAction(this).press(center.getX(), center.getY())
        .moveTo(el, center.getX(), center.getY() + yOffset).release();

    multiTouch.add(action0).add(action1);

    multiTouch.perform();
}
项目:riot-automated-tests    文件:TestUtilities.java   
public void captureImage(String imgUrl,MobileElement element) throws IOException{
    new File(imgUrl).delete();
    File screen = ((TakesScreenshot) appiumFactory.getAndroidDriver2())
            .getScreenshotAs(OutputType.FILE);
    Point point = element.getLocation();

    //get element dimension
    int width = element.getSize().getWidth();
    int height = element.getSize().getHeight();

    BufferedImage img = ImageIO.read(screen);
    BufferedImage dest = img.getSubimage(point.getX(), point.getY(), width,
            height);
    ImageIO.write(dest, "png", screen);
    File file = new File(imgUrl);
    FileUtils.copyFile(screen, file);
}
项目:alimama    文件:SeleniumUtil.java   
public static BufferedImage createElementImage(WebDriver driver,WebElement webElement)  
          throws IOException {  
try{

          // 获得webElement的位置和大小。  
          Point location = webElement.getLocation();  
          Dimension size = webElement.getSize();  
          // 创建全屏截图。  
          BufferedImage originalImage =  
          ImageIO.read(new ByteArrayInputStream(takeScreenshot(driver)));  
          // 截取webElement所在位置的子图。  
          BufferedImage croppedImage = originalImage.getSubimage(  
          location.getX(),  
          location.getY(),  
          size.getWidth(),  
          size.getHeight());  
          return croppedImage;  
}catch(Exception e){
 e.printStackTrace();
}
return null;
          }
项目:aet    文件:ScreenCollector.java   
private byte[] getImagePart(byte[] fullPage, WebElement webElement)
    throws IOException, ProcessingException {
  InputStream in = new ByteArrayInputStream(fullPage);
  try {
    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);
  }
}
项目:sentinela    文件:PrintsScreen.java   
public static File printWebElement(WebElement element, WebDriver driver) throws IOException {
    File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    Point p = element.getLocation();
    int width = element.getSize().getWidth();
    int height = element.getSize().getHeight();
    BufferedImage img = null;
    BufferedImage dest = null;
    img = ImageIO.read(scrFile);
    if (element.isDisplayed()) {
        dest = img.getSubimage(p.getX(), p.getY(), width, height);
    } else {
        dest = img.getSubimage(0, 0, 1, 1);
    }
    ImageIO.write(dest, ManipulateFiles.getListString("imgExtension"), scrFile);
    return scrFile;
}
项目:SwiftLite    文件:WebHelper.java   
/**
 * This function saves screenshot with message embossed in the screenshot
 * @param testCaseId
 * @param transactionType
 * @param Message
 * @param verficationResult
 * @return
 * @throws IOException
 */
public static String saveScreenShot(Reporter report,String ssColumnName) throws IOException
{
    byte[] b;
    TransactionMapping.report.strTestcaseId = report.strTestcaseId;
    TransactionMapping.report.strTrasactionType = report.strTrasactionType;
    ErrorMsg = ssColumnName;
    saveScreenShot();       
    ErrorMsg = "";
    VerificationScreen = TransactionMapping.report.strScreenshot;
    // Add Text to Image
    String path = VerificationScreen.substring(7);
    if (report.strStatus.equalsIgnoreCase("Pass"))
        b = mergeImageAndText(path, ssColumnName, new Point(200, 200));
    else
        b = mergeImageAndText(path, report.strActualValue, new Point(200, 200));
       FileOutputStream fos = new FileOutputStream(path);
       fos.write(b);
       fos.close();     
    return VerificationScreen;
}
项目:find    文件:TopicMapView.java   
private List<ImmutablePair<WebElement, Integer>> childConcepts(final int clusterIndex) {
    //((lowestX,highestX),(lowestY,highestY))
    final Double[][] boundariesOfChosenCluster = nthConceptCluster(clusterIndex).getBoundaries();

    final Point mapCoordinates = map().getLocation();
    //L:Concept; Y:Index
    final List<ImmutablePair<WebElement, Integer>> childConceptsOfChosenCluster = new ArrayList<>();

    int entityIndex = 0;
    for(final WebElement concepts : concepts()) {
        final Dimension entitySize = concepts.getSize();
        final Point absolutePosition = concepts.getLocation();

        final int centreX = absolutePosition.x - mapCoordinates.x + entitySize.getWidth() / 2;
        final int centreY = absolutePosition.y - mapCoordinates.y + entitySize.getHeight() / 2;
        final Point centre = new Point(centreX, centreY);

        if(boundariesOfChosenCluster[0][0] <= centre.x && centre.x <= boundariesOfChosenCluster[0][1]
            && boundariesOfChosenCluster[1][0] <= centre.y && centre.y <= boundariesOfChosenCluster[1][1]) {
            childConceptsOfChosenCluster.add(new ImmutablePair<>(concepts, entityIndex));
        }

        entityIndex++;
    }
    return childConceptsOfChosenCluster;
}
项目:testdroid-samples    文件:AbstractAppiumTest.java   
protected void swipeUp(Point rootLocation, Dimension rootSize, int duration, float topPad, float bottomPad) {
    int offset = 1;
    int topOffset = Math.round(rootSize.getHeight() * topPad);
    int bottomOffset = Math.round(rootSize.getHeight() * bottomPad);
    Point center = new Point(rootLocation.x + rootSize.getWidth() / 2, rootLocation.y + rootSize.getHeight() / 2);
    logger.debug("Swiping up at" +
            " x1: " + center.getX() +
            " y1:" + (rootLocation.getY() + rootSize.getHeight() - bottomOffset + offset) +
            " x2:" + center.getX() +
            " y2:" + (rootLocation.getY() + topOffset));
    driver.swipe(center.getX(),
            rootLocation.getY() + rootSize.getHeight() - bottomOffset + offset,
            center.getX(),
            rootLocation.getY() + topOffset,
            duration);
}
项目:testdroid-samples    文件:AbstractAppiumTest.java   
protected void swipeDown(Point rootLocation, Dimension rootSize, int duration, float topPad, float bottomPad) {
    int offset = 1;
    int topOffset = Math.round(rootSize.getHeight() * topPad);
    int bottomOffset = Math.round(rootSize.getHeight() * bottomPad);
    Point center = new Point(rootLocation.x + rootSize.getWidth() / 2, rootLocation.y + rootSize.getHeight() / 2);
    logger.debug("Swiping down at" +
            " x1: " + center.getX() +
            " y1:" + (rootLocation.getY() + topOffset) +
            " x2:" + center.getX() +
            " y2:" + (rootLocation.getY() + rootSize.getHeight() - bottomOffset + offset));
    driver.swipe(center.getX(),
            (rootLocation.getY() + topOffset),
            center.getX(),
            (rootLocation.getY() + rootSize.getHeight() - bottomOffset + offset),
            duration);
}
项目:testdroid-samples    文件:AbstractAppiumTest.java   
protected void swipeLeft(Point rootLocation, Dimension rootSize, int duration, float leftPad, float rightPad) {
    int offset = 1;
    int leftOffset = Math.round(rootSize.getWidth() * leftPad);
    int rightOffset = Math.round(rootSize.getWidth() * rightPad);
    Point center = new Point(rootLocation.x + rootSize.getWidth() / 2, rootLocation.y + rootSize.getHeight() / 2);
    logger.debug("Swiping left at" +
            " x1: " + (rootLocation.getX() + rootSize.getWidth() - rightOffset + offset) +
            " y1:" + center.getY() +
            " x2:" + (rootLocation.getX() + leftOffset) +
            " y2:" + center.getY());
    driver.swipe((rootLocation.getX() + rootSize.getWidth() - rightOffset + offset),
            center.getY(),
            (rootLocation.getX() + leftOffset),
            center.getY(),
            duration);
}
项目:testdroid-samples    文件:AbstractAppiumTest.java   
protected void swipeRight(Point rootLocation, Dimension rootSize, int duration, float leftPad, float rightPad) {
    int offset = 1;
    int leftOffset = Math.round(rootSize.getWidth() * leftPad);
    int rightOffset = Math.round(rootSize.getWidth() * rightPad);
    Point center = new Point(rootLocation.x + rootSize.getWidth() / 2, rootLocation.y + rootSize.getHeight() / 2);
    logger.debug("Swiping right at" +
            " x1: " + (rootLocation.getX() + leftOffset) +
            " y1:" + center.getY() +
            " x2:" + (rootLocation.getX() + rootSize.getWidth() - rightOffset + offset) +
            " y2:" + center.getY());
    driver.swipe((rootLocation.getX() + leftOffset),
            center.getY(),
            (rootLocation.getX() + rootSize.getWidth() - rightOffset + offset),
            center.getY(),
            duration);
}
项目:crawljax    文件:SerializeTest.java   
private OutPutModel createModel() throws IOException {
    ImmutableList<CandidateElementPosition> candidateElements =
            ImmutableList.of(new CandidateElementPosition("a/b/c", new Point(1, 2),
                    new Dimension(3, 4)));
    State state1 =
            new State("state1", "http://example.com/a", candidateElements, 1, 1, 1,
                    ImmutableList.of("failedEvent1"));
    State state2 =
            new State("state2", "http://example.com/b", candidateElements, 1, 1, 1,
                    ImmutableList.of("failedEvent2"));
    ImmutableMap<String, State> states =
            ImmutableMap.of(state1.getName(), state1, state2.getName(), state2);
    ImmutableList<Edge> edges =
            ImmutableList.of(new Edge(state1.getName(), state2.getName(), 1, "the link",
                    "id1", "A", "click"));
    return new OutPutModel(states, edges, newStatistics(states.values()),
            ExitStatus.EXHAUSTED);
}
项目:seletest    文件:WebDriverController.java   
@Override
@Monitor
public WebDriverController takeScreenShotOfElement(Object locator) throws IOException {
    File screenshot = webDriver().getScreenshotAs(OutputType.FILE);
    BufferedImage  fullImg = ImageIO.read(screenshot);
    WebElement element=waitController().waitForElementPresence(locator);
    Point point = element.getLocation();
    int eleWidth = element.getSize().getWidth();
    int eleHeight = element.getSize().getHeight();
    Rectangle elementScreen=new Rectangle(eleWidth, eleHeight);
    BufferedImage eleScreenshot= fullImg.getSubimage(point.getX(), point.getY(), elementScreen.width, elementScreen.height);
    ImageIO.write(eleScreenshot, "png", screenshot);
    File file = fileService.createScreenshotFile();
    FileUtils.copyFile(screenshot, file);
    fileService.reportScreenshot(file);
    return this;
}
项目:carina    文件:ExtendedWebElement.java   
@SuppressWarnings("unchecked")
private ElementInfo getElementInfo(ExtendedWebElement extendedWebElement) {
       ElementInfo elementInfo = new ElementInfo();
       if (extendedWebElement.isElementPresent(1)) {
           Point location = extendedWebElement.getElement().getLocation();
           Dimension size = extendedWebElement.getElement().getSize();
           elementInfo.setRect(new Rect(location.getX(), location.getY(), size.getWidth(), size.getHeight()));
           elementInfo.setElementsAttributes((Map<String, String>) ((RemoteWebDriver) driver).executeScript(ATTRIBUTE_JS, extendedWebElement.getElement()));

           try {
               elementInfo.setText(extendedWebElement.getText());
           } catch (Exception e){
               elementInfo.setText("");
           }



           return elementInfo;
       } else {
           return null;
       }

   }
项目:selendroid    文件:WaitingConditions.java   
public static Callable<Point> elementLocationToBe(final WebElement element,
    final Point expectedLocation) {
  return new Callable<Point>() {
    private Point currentLocation = new Point(0, 0);

    public Point call() throws Exception {
      currentLocation = element.getLocation();
      if (currentLocation.equals(expectedLocation)) {
        return expectedLocation;
      }

      return null;
    }

    @Override
    public String toString() {
      return "location to be: " + expectedLocation + " is: " + currentLocation;
    }
  };
}
项目:colibri-ui    文件:BaseIOSPickerWheelSteps.java   
@Step
@When("установить пикер в первое значение")
public void setFirstPickerWheelValue() {
    WebElement webElement = driver.findElement(By.xpath(pickerWheelXPath));
    Point center = ((IOSElement) webElement).getCenter();
    Dimension size = webElement.getSize();
    int height = size.getHeight();
    Point target = new Point(center.getX(), center.getY() - (int) (height * stepToLast));
    TouchAction touchAction = new TouchAction(driver);
    touchAction.press(target.getX(), target.getY()).release();
    touchAction.perform();
}
项目:colibri-ui    文件:BaseIOSPickerWheelSteps.java   
@Step
@When("установить пикер в последнее значение")
public void setLastPickerWheelValue() {
    WebElement webElement = driver.findElement(By.xpath(pickerWheelXPath));
    Point center = ((IOSElement) webElement).getCenter();
    Dimension size = webElement.getSize();
    int height = size.getHeight();
    Point target = new Point(center.getX(), center.getY() + (int) (height * stepToLast));
    TouchAction touchAction = new TouchAction(driver);
    touchAction.press(target.getX(), target.getY()).release();
    touchAction.perform();
}
项目:colibri-ui    文件:BaseIOSPickerWheelSteps.java   
public void setNextPickerWheelValue(WebElement pickerWheelElement, double step) {
    Point center = ((IOSElement) pickerWheelElement).getCenter();
    Dimension size = pickerWheelElement.getSize();
    int height = size.getHeight();
    TouchAction touchAction = new TouchAction(driver);
    touchAction.press(center.getX(), center.getY() + (int) (height * step)).release();
    touchAction.perform();
}
项目:colibri-ui    文件:BaseIOSPickerWheelSteps.java   
public void setPrevPickerWheelValue(WebElement pickerWheelElement, double step) {
    Point center = ((IOSElement) pickerWheelElement).getCenter();
    Dimension size = pickerWheelElement.getSize();
    int height = size.getHeight();
    TouchAction touchAction = new TouchAction(driver);
    touchAction.press(center.getX(), center.getY() - (int) (height * step)).release();
    touchAction.perform();
}
项目:phoenix.webui.framework    文件:SeleniumHover.java   
@Override
public void hover(Element ele)
{
    WebElement webEle = searchStrategyUtils.findStrategy(WebElement.class, ele).search(ele);
    if(webEle == null)
    {
        logger.warn("can not found element.");
        return;
    }

    if(!(ele instanceof FileUpload))
    {
        Dimension size = webEle.getSize();
        Point loc = webEle.getLocation();
        int toolbarHeight = engine.getToolbarHeight();
        int x = size.getWidth() / 2 + loc.getX();
        int y = size.getHeight() / 2 + loc.getY() + toolbarHeight;

        try
        {
            new Robot().mouseMove(x, y);
        }
        catch (AWTException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}
项目:marathonv5    文件:JavaDriverTest.java   
public void windowPosition() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    Window window = driver.manage().window();
    Point actual = window.getPosition();
    AssertJUnit.assertNotNull(actual);
    java.awt.Point expected = EventQueueWait.call(frame, "getLocation");
    AssertJUnit.assertEquals(expected.x, actual.x);
    AssertJUnit.assertEquals(expected.y, actual.y);
}
项目:marathonv5    文件:JavaDriverTest.java   
public void getLocation() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    WebElement element1 = driver.findElement(By.name("click-me"));
    Point location = element1.getLocation();
    java.awt.Point p = EventQueueWait.call(button, "getLocation");
    AssertJUnit.assertEquals(p.x, location.x);
    AssertJUnit.assertEquals(p.y, location.y);
}