posted 14 years ago
My problem seems simple enough...but I've been stuck on it for a while. I need to execute JavaScript(Dojo) in my HtmlUnit code in order to select an item in a grid. I'm able to select them fine using the following code:
page.executeJavaScript("store.fetch({onComplete: function(items, request)"
+ "{ grid.selection.setSelected(" + ROW_INDEX + ", true);" +
"}, onError: function(items, request) {alert(\"Oops!\");}});");
The problem is, it's not very dynamic. I have to know what the row index is beforehand on the grid; This problem is magnified when I try to get the newly selected item:
page.executeJavaScript("store.fetch({onComplete: function(items, request)"
+ "{ grid.selection.getSelected();" +
"}, onError: function(items, request) {alert(\"Oops!\");}});");
What is returned by this code is a ScriptResult Object.
This is the toString() of the above code:
ScriptResult[result=[object Object] page=HtmlPage(javascript:'<html><head><script>if("loadFirebugConsole" in window){window.loadFirebugConsole();}</script></head><body></body></html>')@8926788]
Basically, what I want to do is find a way to take the ScriptResult object and make it give me the correct return value that the Dojo code would return. Any help at all would be greatly appreciated.