Search in sources :

Example 1 with Dimension

use of org.openqa.selenium.Dimension in project ghostdriver by detro.

the class WindowSizingAndPositioningTest method manipulateWindowMaximize.

@Test
public void manipulateWindowMaximize() {
    WebDriver d = getDriver();
    d.get("http://www.google.com");
    Dimension sizeBefore = d.manage().window().getSize();
    d.manage().window().maximize();
    Dimension sizeAfter = d.manage().window().getSize();
    assertTrue(sizeBefore.width <= sizeAfter.width);
    assertTrue(sizeBefore.height <= sizeAfter.height);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Dimension(org.openqa.selenium.Dimension) Test(org.junit.Test)

Example 2 with Dimension

use of org.openqa.selenium.Dimension in project java.webdriver by sayems.

the class BrowserThreads method instantiateWebDriver.

private void instantiateWebDriver(DesiredCapabilities desiredCapabilities) {
    log.info(" ");
    log.info("Current Operating System: " + operatingSystem);
    log.info("Current Architecture: " + systemArchitecture);
    log.info("Current Browser Selection: " + selectedDriverType);
    log.info(" ");
    if (useRemoteWebDriver) {
        URL seleniumGridURL = null;
        try {
            seleniumGridURL = new URL(System.getProperty("gridURL"));
        } catch (MalformedURLException e) {
            log.error("Either no legal protocol could be found or the string could not be parsed.", e);
        }
        String desiredBrowserVersion = System.getProperty("desiredBrowserVersion");
        String desiredPlatform = System.getProperty("desiredPlatform");
        if (null != desiredPlatform && !desiredPlatform.isEmpty()) {
            desiredCapabilities.setPlatform(Platform.valueOf(desiredPlatform.toUpperCase()));
        }
        if (null != desiredBrowserVersion && !desiredBrowserVersion.isEmpty()) {
            desiredCapabilities.setVersion(desiredBrowserVersion);
        }
        webdriver = new RemoteWebDriver(seleniumGridURL, desiredCapabilities);
    } else {
        webdriver = selectedDriverType.browser.getWebDriverObject(desiredCapabilities);
    }
    webdriver.manage().window().setSize(new Dimension(1280, 1024));
    setup();
}
Also used : MalformedURLException(java.net.MalformedURLException) RemoteWebDriver(org.openqa.selenium.remote.RemoteWebDriver) Dimension(org.openqa.selenium.Dimension) URL(java.net.URL)

Example 3 with Dimension

use of org.openqa.selenium.Dimension in project java.webdriver by sayems.

the class GetHeight method main.

public static void main(String[] args) {
    WebDriver driver = new ChromeDriver();
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    driver.navigate().to("http://www.google.com");
    driver.manage().window().setSize(new Dimension(1024, 768));
    driver.quit();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) Dimension(org.openqa.selenium.Dimension) ChromeDriver(org.openqa.selenium.chrome.ChromeDriver)

Example 4 with Dimension

use of org.openqa.selenium.Dimension in project selenium-tests by Wikia.

the class Shooter method getBoundingClientRect.

private Object[] getBoundingClientRect(WebElement element, WebDriver driver) {
    JavascriptExecutor js = (JavascriptExecutor) driver;
    ArrayList<String> list = (ArrayList<String>) js.executeScript("var rect =  arguments[0].getBoundingClientRect();" + "return [ '' + parseInt(rect.left), '' + parseInt(rect.top), '' + parseInt(rect.width), '' + parseInt(rect.height) ]", element);
    Point start = new Point(Integer.parseInt(list.get(0)), Integer.parseInt(list.get(1)));
    Dimension size = new Dimension(Integer.parseInt(list.get(2)), Integer.parseInt(list.get(3)));
    return new Object[] { start, size };
}
Also used : JavascriptExecutor(org.openqa.selenium.JavascriptExecutor) ArrayList(java.util.ArrayList) Point(org.openqa.selenium.Point) Dimension(org.openqa.selenium.Dimension)

Example 5 with Dimension

use of org.openqa.selenium.Dimension in project selenium-tests by Wikia.

the class Shooter method captureWebElement.

/**
   * Create a screenshot of passed element and save screenshot as image file in temp dir. <p> Notes:
   * Method works properly in Google Chrome only if devicePixelRatio equals 1. </p>
   *
   * @param element - WebElement you want to capture
   * @param driver  - instance of WebDriver
   * @return File path  - file's handler which was saved in given path
   */
public File captureWebElement(WebElement element, WebDriver driver) {
    Point start = element.getLocation();
    Dimension size = element.getSize();
    if (!"FF".equals(Configuration.getBrowser())) {
        Object[] rect = getBoundingClientRect(element, driver);
        start = (Point) rect[0];
        size = (Dimension) rect[1];
    }
    File image = imageEditor.cropImage(start, size, capturePage(driver));
    PageObjectLogging.logImage("Shooter", image, true);
    return image;
}
Also used : Point(org.openqa.selenium.Point) Dimension(org.openqa.selenium.Dimension) File(java.io.File)

Aggregations

Dimension (org.openqa.selenium.Dimension)24 File (java.io.File)9 Point (org.openqa.selenium.Point)7 WebDriver (org.openqa.selenium.WebDriver)6 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)4 WebElement (org.openqa.selenium.WebElement)3 RemoteWebDriver (org.openqa.selenium.remote.RemoteWebDriver)3 PublicAtsApi (com.axway.ats.common.PublicAtsApi)2 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)2 Execute (com.wikia.webdriver.common.core.annotations.Execute)2 VisualEditorAddMediaDialog (com.wikia.webdriver.pageobjectsfactory.componentobject.visualeditordialogs.VisualEditorAddMediaDialog)2 AdsBaseObject (com.wikia.webdriver.pageobjectsfactory.pageobject.adsbase.AdsBaseObject)2 VisualEditorPageObject (com.wikia.webdriver.pageobjectsfactory.pageobject.visualeditor.VisualEditorPageObject)2 BufferedImage (java.awt.image.BufferedImage)2 IOException (java.io.IOException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 FessConfig (org.codelibs.fess.mylasta.direction.FessConfig)2 By (org.openqa.selenium.By)2