• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HtmlUnit: Need help deciphering the returned object ScriptResult from HtmlPage.executeJavaScript()

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic