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


Java Dimension类代码示例

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


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

示例1: swipeRight

import org.openqa.selenium.Dimension; //导入依赖的package包/类
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();

    }
 
开发者ID:mcdcorp,项目名称:opentest,代码行数:22,代码来源:AppiumTestAction.java

示例2: doCreateDriver

import org.openqa.selenium.Dimension; //导入依赖的package包/类
private RemoteWebDriver doCreateDriver(URL webDriverUrl) {
  DesiredCapabilities capability;

  switch (browser) {
    case GOOGLE_CHROME:
      ChromeOptions options = new ChromeOptions();
      options.addArguments("--no-sandbox");
      options.addArguments("--dns-prefetch-disable");

      capability = DesiredCapabilities.chrome();
      capability.setCapability(ChromeOptions.CAPABILITY, options);
      break;

    default:
      capability = DesiredCapabilities.firefox();
      capability.setCapability("dom.max_script_run_time", 240);
      capability.setCapability("dom.max_chrome_script_run_time", 240);
  }

  RemoteWebDriver driver = new RemoteWebDriver(webDriverUrl, capability);
  driver.manage().window().setSize(new Dimension(1920, 1080));

  return driver;
}
 
开发者ID:eclipse,项目名称:che,代码行数:25,代码来源:SeleniumWebDriver.java

示例3: waitElementIsStatic

import org.openqa.selenium.Dimension; //导入依赖的package包/类
private void waitElementIsStatic(FluentWait<WebDriver> webDriverWait, WebElement webElement) {
  AtomicInteger sizeHashCode = new AtomicInteger();

  webDriverWait.until(
      (ExpectedCondition<Boolean>)
          driver -> {
            Dimension newDimension = waitAndGetWebElement(webElement).getSize();

            if (dimensionsAreEquivalent(sizeHashCode, newDimension)) {
              return true;
            } else {
              sizeHashCode.set(getSizeHashCode(newDimension));
              return false;
            }
          });
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:TestWebElementRenderChecker.java

示例4: mark

import org.openqa.selenium.Dimension; //导入依赖的package包/类
@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)
	{
	}
}
 
开发者ID:LinuxSuRen,项目名称:phoenix.webui.framework,代码行数:20,代码来源:TargetElementMark.java

示例5: windowSetSize

import org.openqa.selenium.Dimension; //导入依赖的package包/类
public void windowSetSize() throws Throwable {
    driver = new JavaDriver();
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override public void run() {
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    });
    Window window = driver.manage().window();
    Dimension actual = window.getSize();
    AssertJUnit.assertNotNull(actual);
    java.awt.Dimension expected = EventQueueWait.call(frame, "getSize");
    AssertJUnit.assertEquals(expected.width, actual.width);
    AssertJUnit.assertEquals(expected.height, actual.height);
    window.setSize(new Dimension(expected.width * 2, expected.height * 2));
    actual = window.getSize();
    AssertJUnit.assertEquals(expected.width * 2, actual.width);
    AssertJUnit.assertEquals(expected.height * 2, actual.height);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:20,代码来源:JavaDriverTest.java

示例6: 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

示例7: 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

示例8: 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

示例9: swipeDown

import org.openqa.selenium.Dimension; //导入依赖的package包/类
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();

    }
 
开发者ID:mcdcorp,项目名称:opentest,代码行数:19,代码来源:AppiumTestAction.java

示例10: createWebDriver

import org.openqa.selenium.Dimension; //导入依赖的package包/类
private WebDriver createWebDriver(final Consumer<DesiredCapabilities> desiredCapabilities) {

		String hostName = GhostDriverService.get().getHostName();

		DesiredCapabilities capabilities = DesiredCapabilities.phantomjs();
		if (desiredCapabilities != null) {
			desiredCapabilities.accept(capabilities);
		}
		try {
			WebDriver driver = new RemoteWebDriver(new URL("http://localhost:" + GhostDriverService.get().getLocalPort() + "/"), capabilities);
			driver.manage().window().setSize(new Dimension(1920, 1080));
			return driver;
		} catch (MalformedURLException e) {
			throw new IllegalStateException("Wrong hostName '" + hostName + "', possibly GhostDriverService::start not called ", e);
		}
	}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:17,代码来源:WebDriverService.java

示例11: setBrowserSize

import org.openqa.selenium.Dimension; //导入依赖的package包/类
@Action(object = ObjectType.BROWSER, desc = "Changes the browser size into [<Data>]", input = InputType.YES)
public void setBrowserSize() {
    try {
        if (Data.matches("\\d*(x|,| )\\d*")) {
            String size = Data.replaceFirst("(x|,| )", " ");
            String[] sizes = size.split(" ", 2);
            Driver.manage().window().setSize(new Dimension(Integer.parseInt(sizes[0]), Integer.parseInt(sizes[1])));
            Report.updateTestLog(Action, " Browser is resized to " + Data,
                    Status.DONE);
        } else {
            Report.updateTestLog(Action, " Invalid Browser size [" + Data + "]",
                    Status.DEBUG);
        }
    } catch (Exception ex) {
        Report.updateTestLog(Action, "Unable to resize the Window ",
                Status.FAIL);
        Logger.getLogger(Basic.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:20,代码来源:Basic.java

示例12: horizontalSwipe

import org.openqa.selenium.Dimension; //导入依赖的package包/类
/**
 * Swipe from xStart to xStop on the horizontal center of the screen.
 * 
 * @param xStart - start point in percents 
 * @param xStop - end point in percents 
 * @param speed - swipe speed
 */
public static void horizontalSwipe(double xStart, double xStop, int speed)
{
	Dimension size = driver.manage().window().getSize();
	((AppiumDriver<?>) driver).swipe(

			// start point
			(int)xStart,
			size.height/2,
			
			// end point
			(int)xStop,
			size.height/2,

			speed);
	ThreadUtils.sleepQuiet(2000);
}
 
开发者ID:danrusu,项目名称:mobileAutomation,代码行数:24,代码来源:Driver.java

示例13: verticalSwipe

import org.openqa.selenium.Dimension; //导入依赖的package包/类
/**
 * Swipe from yStart to yStop on the vertical center of the screen.
 * 
 * @param yStart - start point in percents  
 * @param yStop - end point in percents 
 * @param speed - swipe speed
 */
public static void verticalSwipe(double yStart, double yStop, int speed)
{
	Dimension size = driver.manage().window().getSize();
	((AppiumDriver<?>) driver).swipe(

			// start point
			size.width/2,
			(int)(size.height*yStart),

			// end point
			size.width/2,
			(int)(size.height*yStop), 

			speed);
	ThreadUtils.sleepQuiet(2000);
}
 
开发者ID:danrusu,项目名称:mobileAutomation,代码行数:24,代码来源:Driver.java

示例14: getCurrentLocation

import org.openqa.selenium.Dimension; //导入依赖的package包/类
/**
 * @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;
}
 
开发者ID:Cognifide,项目名称:bobcat,代码行数:17,代码来源:DroppableWebElement.java

示例15: getSize

import org.openqa.selenium.Dimension; //导入依赖的package包/类
@Override
public Dimension getSize()
{
    Dimension returnValue = null;
    webDriver.getExecutionContext().startStep( createStep( "AT" ), null, null );
    try
    {
        returnValue = baseElement.getSize();
    }
    catch( Exception e )
    {
        webDriver.getExecutionContext().completeStep( StepStatus.FAILURE, e );
    }
    
    webDriver.getExecutionContext().completeStep( StepStatus.SUCCESS, null );
    
    return returnValue;
}
 
开发者ID:xframium,项目名称:xframium-java,代码行数:19,代码来源:ReportingWebElementAdapter.java


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