Java Code Examples for org.openqa.selenium.WebElement.getSize()

The following are Jave code examples for showing how to use getSize() of the org.openqa.selenium.WebElement class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: phoenix.webui.framework   File: TargetElementMark.java   View Source Code Vote up 6 votes
@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)
	{
	}
}
 
Example 2
Project: colibri-ui   File: BaseIOSPickerWheelSteps.java   View Source Code Vote up 5 votes
@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();
}
 
Example 3
Project: colibri-ui   File: BaseIOSPickerWheelSteps.java   View Source Code Vote up 5 votes
@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();
}
 
Example 4
Project: colibri-ui   File: BaseIOSPickerWheelSteps.java   View Source Code Vote up 5 votes
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();
}
 
Example 5
Project: colibri-ui   File: BaseIOSPickerWheelSteps.java   View Source Code Vote up 5 votes
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();
}
 
Example 6
Project: phoenix.webui.framework   File: SeleniumHover.java   View Source Code Vote up 5 votes
@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();
		}
	}
}
 
Example 7
Project: marathonv5   File: JavaDriverTest.java   View Source Code Vote up 5 votes
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);
}
 
Example 8
Project: ats-framework   File: MobileElement.java   View Source Code Vote up 5 votes
/**
 * 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);
    }
}
 
Example 9
Project: SeleniumTest   File: WebdriverTest.java   View Source Code Vote up 5 votes
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);
		}
	
}