Example usage for org.openqa.selenium Dimension Dimension

List of usage examples for org.openqa.selenium Dimension Dimension

Introduction

In this page you can find the example usage for org.openqa.selenium Dimension Dimension.

Prototype

public Dimension(int width, int height) 

Source Link

Usage

From source file:MobileChosenIT.java

License:Apache License

@Before
public void before() {
    // will trigger the mobile layout
    webDriver.manage().window().setSize(new Dimension(450, 600));
}

From source file:acceptance.SharedDriver.java

License:Open Source License

private static WebDriver createWebDriver() {
    String driverType = getWebDriverType();
    final WebDriver driver;
    switch (driverType.toLowerCase()) {
    case "htmlunit":
        driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_24);
        break;//  w  w w. j a  va  2  s  .  c om
    case "firefox":
        driver = new FirefoxDriver();
        break;
    case "phantomjs":
        String phantomjsBinaryPath = getPhantomjsBinaryPath();
        if (phantomjsBinaryPath.length() > 0) {
            DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
            desiredCapabilities.setCapability("phantomjs.binary.path", phantomjsBinaryPath);
            driver = new PhantomJSDriver(desiredCapabilities);
        } else {
            driver = new PhantomJSDriver();
        }
        break;
    default:
        throw new RuntimeException(
                "WebDriver type not correctly configured. Unknown driver type: '" + driverType + "'");
    }
    driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
    driver.manage().window().setSize(new Dimension(1280, 800));
    return driver;
}

From source file:base.GalenTestBase.java

@DataProvider(name = "devices")
public Object[][] devices() {
    return new Object[][] { { new TestDevice("mobile", new Dimension(450, 800), asList("mobile")) },
            { new TestDevice("tablet", new Dimension(750, 800), asList("tablet")) },
            { new TestDevice("desktop", new Dimension(1024, 800), asList("desktop")) },
            { new TestDevice("iPhone 5s", new Dimension(640, 1136), asList("mobile")) } };
}

From source file:botski.selenium.SocialBot.java

License:Apache License

/**
 * Initialises Firefox as the default browser
 *//* w  w  w. j  a  v  a 2s.  c  o m*/
public void initializeFirefox() {
    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("webdriver.load.strategy", "fast");
    profile.setPreference("browser.tabs.loadInBackground", false);
    profile.setPreference("browser.tabs.warnOnClose", false);
    profile.setPreference("browser.tabs.warnOnOpen", false);
    if (proxyHost != null) {
        profile.setPreference("network.proxy.type", 1);
        profile.setPreference("network.proxy.http", proxyHost);
        profile.setPreference("network.proxy.http_port", proxyPort);
        profile.setPreference("network.proxy.ssl", proxyHost);
        profile.setPreference("network.proxy.ssl_port", proxyPort);
    }
    browser = new FirefoxDriver(profile);
    browser.manage().timeouts().pageLoadTimeout(timeout, TimeUnit.MILLISECONDS);
    browser.manage().timeouts().setScriptTimeout(timeout, TimeUnit.MILLISECONDS);
    browser.manage().timeouts().implicitlyWait(timeout, TimeUnit.MILLISECONDS);
    javascript = (JavascriptExecutor) browser;
    browser.manage().window().setSize(new Dimension(1024, 768));
}

From source file:botski.selenium.SocialBot.java

License:Apache License

/**
 * Initialises Chrome as the default browser
 *///  w  w w  . ja  v a  2s .  c  om
public void initializeChrome() {
    SeleniumUtils.setChromeDriver();
    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    if (proxyHost != null) {
        Proxy proxy = new Proxy();
        proxy.setHttpProxy(proxyHost + ":" + proxyPort);
        proxy.setHttpsProxy(proxyHost + ":" + proxyPort);
        capabilities.setCapability(CapabilityType.PROXY, proxy);
    }
    browser = new ChromeDriver(capabilities);
    javascript = (JavascriptExecutor) browser;
    browser.manage().window().setSize(new Dimension(1024, 768));
}

From source file:cc.kune.selenium.KuneSeleniumDefaults.java

License:GNU Affero Public License

/**
 * Resize./*from  w  ww  .j a v  a 2 s.  c  o m*/
 */
public void resize() {
    // Some others tested values:
    // 1024,769
    // 840,770
    // 806,707
    webdriver.manage().window().setPosition(new Point(0, 0));
    webdriver.manage().window().setSize(new Dimension(806, 707));
    // Before we were using:
    // final JavascriptExecutor js = (JavascriptExecutor) webdriver;
    // js.executeScript("window.resizeTo(806,707); window.moveTo(0,0);");
}

From source file:co.edu.uniandes.csw.sport.master.test.SportMasterTest.java

@BeforeClass
public static void setUp() throws Exception {
    driver = new FirefoxDriver();
    // se define el url base del proyecto web
    baseUrl = "http://localhost:8080";
    //* Indica cuanto se espera para la respuesta de cualquier comando realizado hacia el navegador*/.
    driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    /** Cambia el tamanio de la ventana del explorador para que los controles backbone se muestren correctamente en la prueba*/
    driver.manage().window().setSize(new Dimension(1400, 700));

}

From source file:com.assertthat.selenium_shutterbug.utils.image.ImageProcessorTest.java

License:Apache License

@Test
public void testHighlight() throws IOException {
    Point point = new Point(9, 33);
    Dimension size = new Dimension(141, 17);
    Coordinates coords = new Coordinates(point, size);
    BufferedImage clearImage = ImageIO
            .read(Thread.currentThread().getContextClassLoader().getResourceAsStream("clearImage.png"));
    BufferedImage highlightedExpectedImage = ImageIO
            .read(Thread.currentThread().getContextClassLoader().getResourceAsStream("highlightedImage.png"));
    BufferedImage highlightedActualImage = ImageProcessor.highlight(clearImage, coords, Color.red, 3);
    assertTrue("Images are not equal after highlighting",
            ImageProcessor.imagesAreEquals(highlightedExpectedImage, highlightedActualImage, 0.0));
}

From source file:com.assertthat.selenium_shutterbug.utils.web.Browser.java

License:Open Source License

public Coordinates getBoundingClientRect(WebElement element) {
    String script = FileUtil.getJsScript(RELATIVE_COORDS_JS);
    ArrayList<String> list = (ArrayList<String>) executeJsScript(RELATIVE_COORDS_JS, 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 Coordinates(start, size);
}

From source file:com.atanas.kanchev.testframework.selenium.driverfactory.DriverFactory.java

License:Apache License

private WebDriver confResolution(WebDriver driver) {

    if (isStartMaximized()) {
        logger.debug("Maximising browser window");
        driver.manage().window().maximize();
    } else {//from ww w .j av a 2s  . com
        logger.debug("Setting resolution to: " + DEFAULT_BROWSER_RES_WIDTH + "*" + DEFAULT_BROWSER_RES_HEIGHT);
        driver.manage().window().setSize(new Dimension(DEFAULT_BROWSER_RES_WIDTH, DEFAULT_BROWSER_RES_HEIGHT));
    }

    return driver;
}