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


Java WebElement.getSize方法代码示例

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


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

示例1: mark

import org.openqa.selenium.WebElement; //导入方法依赖的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

示例2: setFirstPickerWheelValue

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
@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();
}
 
开发者ID:alfa-laboratory,项目名称:colibri-ui,代码行数:13,代码来源:BaseIOSPickerWheelSteps.java

示例3: setLastPickerWheelValue

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
@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();
}
 
开发者ID:alfa-laboratory,项目名称:colibri-ui,代码行数:13,代码来源:BaseIOSPickerWheelSteps.java

示例4: setNextPickerWheelValue

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
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();
}
 
开发者ID:alfa-laboratory,项目名称:colibri-ui,代码行数:9,代码来源:BaseIOSPickerWheelSteps.java

示例5: setPrevPickerWheelValue

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
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();
}
 
开发者ID:alfa-laboratory,项目名称:colibri-ui,代码行数:9,代码来源:BaseIOSPickerWheelSteps.java

示例6: hover

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

示例7: getSize

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
public void getSize() 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"));
    Dimension size = element1.getSize();
    java.awt.Dimension d = EventQueueWait.call(button, "getSize");
    AssertJUnit.assertEquals(d.width, size.width);
    AssertJUnit.assertEquals(d.height, size.height);
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:15,代码来源:JavaDriverTest.java

示例8: scrollTo

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
/**
 * Scroll to element (at the center of the screen)
 *
 * @return this mobile element which allows chained actions
 */
@SuppressWarnings( "unchecked")
@PublicAtsApi
public T scrollTo() {

    try {

        if (MobileElementFinder.getElementContext(this).toUpperCase().startsWith("WEBVIEW")) {

            // in WEBVIEWs the target element exists, while in the NATIVE context it doesn't until we scroll to it
            new MobileElementState(this).waitToBecomeExisting();

            Dimension screenDimensions = ((MobileDriver) getUiDriver()).getScreenDimensions();
            WebElement element = MobileElementFinder.findElement(appiumDriver, this);

            // window.scrollTo(0, element.getLocation().y);    -->  will scroll the element to top-left

            int scrollToY = 0;
            int screenCenter = screenDimensions.getHeight() / 2 + element.getSize().height / 2;
            if (element.getLocation().y < screenCenter) {
                // the element is located after the screen center if we scroll to (0, element.getLocation().y)
                // because it is near the bottom of the application => we can't center it, but it is OK on that position
                scrollToY = element.getLocation().y;
            } else {
                scrollToY = element.getLocation().y - screenCenter;
            }

            ((JavascriptExecutor) appiumDriver).executeScript("window.scrollTo(0," + scrollToY + ")");
        } else {

            if (getElementProperty("name") != null) {
                appiumDriver.scrollTo(getElementProperty("name")); // only works for NATIVE context
            }
        }

        return (T) this;
    } catch (Exception e) {
        throw new MobileOperationException(this, "scrollTo", e);
    }
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:45,代码来源:MobileElement.java

示例9: test

import org.openqa.selenium.WebElement; //导入方法依赖的package包/类
static void test() {
	System.setProperty("webdriver.chrome.driver", "D:\\selenium\\chromedriver_win32\\chromedriver.exe");
	
	WebDriver driver = new ChromeDriver();
	
	driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
	driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
	
	String url = "http://www.baidu.com/";

	driver.get(url);
		
		//��ȡ��ǰҳ��ȫ��iframe������iframe����Ԫ��
		try {
			List<WebElement> iframes = driver.findElements(By.tagName("iframe")); //��ȡȫ��iframe��ǩ
			if(iframes.size()!=0) {
				for(WebElement iframe : iframes) {
					if(iframe.getSize() != null) {
						  System.out.println(iframe.getAttribute("outerHtml"));
					}
				}
			}else{
				System.out.println("��ҳ�治����iframe");
			}				
		}catch(Exception e) {
			System.out.println(e);
		}
	
}
 
开发者ID:Yinqingseu,项目名称:SeleniumTest,代码行数:30,代码来源:WebdriverTest.java


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