I have a web page which displays a dynamic layout (generated by extjs) which is supposed to occupy 100% of the width. I am using
WebElement element = driver.findElement(By.id("ext-gen4"));
String backgroundColor = element.getCssValue("width");
But currently it is returning the width in pixel and on top that the WebDriver browser (Firefox) is not displayed in maximum mode so the value is even less. Is there any way I can get the value in %? I came to know of some GetCssProperty class but I am unable to use it properly. Any details on that? I am using Selenium WebDriver 2.23 with JUnit.
I guess there must be a way to maximize the window.
As Slanec said you can maximize your window like
driver.manage().window().maximize()
Than you can create a method
private float getWidthInRelationToWindow(WebElement element){
return ((float)element.getSize().getWidth())/
this.drivy.manage().window().getSize().getWidth();
}