当前位置: 首页>>代码示例>>Java>>正文


Java Dimension.getHeight方法代码示例

本文整理汇总了Java中org.openqa.selenium.Dimension.getHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Dimension.getHeight方法的具体用法?Java Dimension.getHeight怎么用?Java Dimension.getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openqa.selenium.Dimension的用法示例。


在下文中一共展示了Dimension.getHeight方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isCover

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
/**
 * 判断要点击的元素是否被其它元素覆盖
 * 
 * @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;
}
 
开发者ID:quanqinle,项目名称:WebAndAppUITesting,代码行数:30,代码来源:IphoneBaseOpt.java

示例2: isCover

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
/**
 * 判断要点击的元素是否被其它元素覆盖
 * 
 * @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;
}
 
开发者ID:quanqinle,项目名称:WebAndAppUITesting,代码行数:31,代码来源:AndroidBaseOpt.java

示例3: swipeTo

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
private TouchAction swipeTo (final SwipeDirection direction, final SwipeDistance distance) {
	final Dimension size = this.driver.manage ()
		.window ()
		.getSize ();
	final int startX = size.getWidth () / 2;
	final int startY = size.getHeight () / 2;
	final int endX = (int) (startX * direction.getX () * distance.getDistance ());
	final int endY = (int) (startY * direction.getY () * distance.getDistance ());
	final int beforeSwipe = this.device.getSetting ()
		.getDelayBeforeSwipe ();
	final int afterSwipe = this.device.getSetting ()
		.getDelayAfterSwipe ();
	final TouchAction returnAction = new TouchAction (this.driver);
	returnAction.press (startX, startY)
		.waitAction (ofSeconds (beforeSwipe))
		.moveTo (endX, endY)
		.waitAction (ofSeconds (afterSwipe))
		.release ();
	return returnAction;
}
 
开发者ID:WasiqB,项目名称:coteafs-appium,代码行数:21,代码来源:DeviceActions.java

示例4: get

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
public void get( String url )
{
    setLastAction();
    webDriver.get( url );
    
    try
    {
        double outerHeight = Integer.parseInt( executeScript( "return window.outerHeight;" ) + "" );
        double outerWidth = Integer.parseInt( executeScript( "return window.outerWidth;" ) + "" );
        
        Dimension windowSize = manage().window().getSize();
        Object f = executeScript( "return window.outerHeight;" );
        heightModifier = (double) windowSize.getHeight() / outerHeight;
        widthModifier = (double) windowSize.getWidth() / outerWidth;
        
    }
    catch( Exception e )
    {
        log.warn( "Could not extract height/width modifiers" );
        heightModifier = 1;
        widthModifier = 1;
    }
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:24,代码来源:DeviceWebDriver.java

示例5: pinch

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:JoeUtt,项目名称:menggeqa,代码行数:32,代码来源:AppiumDriver.java

示例6: zoom

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
/**
 * 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();
}
 
开发者ID:JoeUtt,项目名称:menggeqa,代码行数:30,代码来源:AppiumDriver.java

示例7: childConcepts

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
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;
}
 
开发者ID:hpe-idol,项目名称:find,代码行数:27,代码来源:TopicMapView.java

示例8: swipeUp

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
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);
}
 
开发者ID:bitbar,项目名称:testdroid-samples,代码行数:17,代码来源:AbstractAppiumTest.java

示例9: swipeDown

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
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);
}
 
开发者ID:bitbar,项目名称:testdroid-samples,代码行数:17,代码来源:AbstractAppiumTest.java

示例10: swipeLeft

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
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);
}
 
开发者ID:bitbar,项目名称:testdroid-samples,代码行数:17,代码来源:AbstractAppiumTest.java

示例11: swipeRight

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
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);
}
 
开发者ID:bitbar,项目名称:testdroid-samples,代码行数:17,代码来源:AbstractAppiumTest.java

示例12: tapAtCoordinates

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
public void tapAtCoordinates(int x, int y) throws Exception {
    if (automationName.equalsIgnoreCase("selendroid")) {
        selendroidTapAtCoordinate(x, y, 1);
    } else if (platform.equals(PlatformType.ANDROID)){
        Dimension size = driver.manage().window().getSize();
    	if(y > size.getHeight() || x > size.getWidth()){
			log("using adb tap at " + x + ", " + y);
			try{
                //run eclipse from commandline to get path variable correct and find adb
        		Process p = Runtime.getRuntime().exec("adb -s " + udid + " shell input tap " + x + " " + y);
        		p.waitFor();
			} catch (Exception e) {
				log(e.toString());
			}
    	} else {
    		driver.tap(1, x, y, 1);
    	}
    } else {
    	driver.tap(1, x, y, 1);
    }
}
 
开发者ID:bitbar,项目名称:testdroid-samples,代码行数:22,代码来源:TestdroidImageRecognition.java

示例13: swipeHorizontally

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
public void swipeHorizontally(double x_offset, double y_offset, int distance, int swipes, double frequency) throws Exception {

        Dimension size = driver.manage().window().getSize();
        Point middle = new Point(size.getWidth(), size.getHeight());
        Point middleWithOffset = new Point(middle.x * x_offset, middle.y * y_offset);

        int startX = (int) middleWithOffset.x;
        int startY = (int) middleWithOffset.y;
        int endX = startX + distance;
        int endY = startY;


        for (int i = 0; i < swipes; i++) {
            if (PlatformType.IOS.equals(PlatformType.IOS)) {
                iOSSwipe(startX, startY, endX, endY);
            } else {
                androidSwipe(startX, startY, endX, endY);
            }
            sleep(frequency);
        }
        log("Finished executing swipes");
    }
 
开发者ID:bitbar,项目名称:testdroid-samples,代码行数:23,代码来源:TestdroidImageRecognition.java

示例14: swipeVertically

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
public void swipeVertically(double x_offset, double y_offset, int distance, int swipes, double frequency) throws Exception {

        Dimension size = driver.manage().window().getSize();
        Point middle = new Point(size.getWidth(), size.getHeight());
        Point middleWithOffset = new Point(middle.x * x_offset, middle.y * y_offset);

        int startX = (int) middleWithOffset.x;
        int startY = (int) middleWithOffset.y;
        int endX = startX;
        int endY = startY + distance;


        for (int i = 0; i < swipes; i++) {
            if (PlatformType.IOS.equals(PlatformType.IOS)) {
                iOSSwipe(startX, startY, endX, endY);
            } else {
                androidSwipe(startX, startY, endX, endY);
            }
            sleep(frequency);
        }
        log("Finished executing swipes");
    }
 
开发者ID:bitbar,项目名称:testdroid-samples,代码行数:23,代码来源:TestdroidImageRecognition.java

示例15: dragImageToMiddle

import org.openqa.selenium.Dimension; //导入方法依赖的package包/类
public void dragImageToMiddle(String object) throws Exception {
    Dimension size = driver.manage().window().getSize();
    Point middle = new Point(size.getWidth() / 2 - 20, size.getHeight() / 2 + 20);

    ImageRecognitionSettings settings = new ImageRecognitionSettings();
    settings.setRetries(10);
    ImageSearchResult object_image = findImageOnScreen(object, settings);
    assert(object_image.isFound());
    ImageLocation object_image_location = object_image.getImageLocation();

    int startX = (int) object_image_location.getCenter().x;
    int startY = (int) object_image_location.getCenter().y;

    int endX = (int) middle.x;
    int endY = (int) middle.y;

    if (automationName.equalsIgnoreCase("selendroid")) {
        androidSwipe(startX, startY, endX, endY);
    } else {
        iOSSwipe(startX, startY, endX, endY);
    }
}
 
开发者ID:bitbar,项目名称:testdroid-samples,代码行数:23,代码来源:TestdroidImageRecognition.java


注:本文中的org.openqa.selenium.Dimension.getHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。