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);
}
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();
}
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();
}
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 };
}
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;
}
Aggregations