Computed style value is not updated after user actions in InternetExplorerDriver

54 views
Skip to first unread message

Piyush Dubey

unread,
Nov 15, 2010, 9:42:19 PM11/15/10
to webdriver
Hi,

I'm trying to assert computed styles which changes based on user
action. I'm getting the computed style through JavaScript. When I try
to assert the changed computed style after any user action (say button
changing color after click), The IEDriver doesn't return the updated
value.

My method looks something like this:

public static String getComputedStyle(WebDriver driver, WebElement
element, String styleName){
String Script = null;
if(driver instanceof InternetExplorerDriver){
Script = "return arguments[0].currentStyle['"+styleName+"'];";
}else {
Script = "return
document.defaultView.getComputedStyle(arguments[0],null).getPropertyValue('"+styleName
+"');";
}
String styleValue =
(String)((JavascriptExecutor)driver).executeScript(Script,
element);

return styleValue;
}


In case of FireFox and Chrome it works fine but for IE the values
don't get updated after the user actions.

Any help would be appreciated... :)


Thanks in advance

Regards,
Piyush




Nilesh

unread,
Nov 16, 2010, 9:52:16 AM11/16/10
to webdriver
Would it work if you change following line from,

Script = "return arguments[0].currentStyle['"+styleName+"'];";

to,

Script = "return arguments[0].style."+styleName+";";

-Nilesh

Piyush Dubey

unread,
Nov 16, 2010, 1:26:24 PM11/16/10
to webd...@googlegroups.com
Thanks for quick response

but with given changes, It throws an exception :
org.openqa.selenium.ie.UnexpectedJavascriptExecutionException: Cannot execute script
System info: os.name: 'Windows Server 2003', os.arch: 'x86', os.version: '5.2 build 3790 Service Pack 2', java.version: '1.6.0'
Driver info: driver.version: ie
I think the script is fine because it gives me the onload value of computed style. But when user performs an action which changes the style, it doesn't update the value.

I think this is a problem with IEDriver.

-Piyush Dubey

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.


Reply all
Reply to author
Forward
0 new messages