Struts menu action doesn't fire for Selenesse test, but does for manual test

54 views
Skip to first unread message

Karen Tobo

unread,
Jul 5, 2012, 2:06:18 PM7/5/12
to selenes...@googlegroups.com
Having fixed problem #1 on Tuesday (thanks, Chris!), problem #2 has just gotten a promotion.

I'm testing an old app that uses Struts menus. When I update a text field, a Struts action updates a select menu on the page. I need to select an option from this menu before submitting the form - it's a required field. Things work fine during manual testing, but the update action doesn't fire during my Selenesse test. I successfully do

| type; | name=myArea | DENVER |

and then attempt

| select; | name=myState | CO |    (or label=CO, neither work because the select menu is empty)

The test moves slowly, so I can view the select menu during the test to verify that it is not updating. Is there something I can do to prompt the update? A click? A key press?

Some technical details:

The text field looks like this:

<input type="text" name="myArea" size="20" value="DENVER" onblur="handleUpdate(this.form)">

Then the handleUpdate function calls a Struts action (like tempObj.action = '/pathto/myDetailUpdateAction.do') which does a tempObj.submit() and then the select menu is magically updated. 

I don't really understand the Struts actions. I just want my test script to interact with the fields like a manual user so I can successfully submit the form. I'd love some suggestions!

 - Karen


Chris McMahon

unread,
Jul 5, 2012, 2:25:58 PM7/5/12
to selenes...@googlegroups.com


I'm just guessing, but once you have DENVER in place, looks like you need to fire the js blur event to push it through.   The Se1.0 ref (http://release.seleniumhq.org/selenium-core/1.0.1/reference.html) says:

fireEvent ( locator,eventName )
Explicitly simulate an event, to trigger the corresponding "onevent" handler.

Arguments:

  • locator - an element locator
  • eventName - the event name, e.g. "focus" or "blur"

so I'm guessing you'd need to do something like

| fireEvent; | name=myArea | blur |

-C

Karen Tobo

unread,
Jul 5, 2012, 5:23:43 PM7/5/12
to selenes...@googlegroups.com
Chris, you are my new best friend.

Interesting that fireEvent was intentionally removed from WebDriver because it's such a hack. Those of us supporting crummy old apps are now supposed to implement our own hacks in JavaScript.

Many thanks,

 - Karen Tobo


On Thursday, July 5, 2012 12:25:58 PM UTC-6, Chris McMahon wrote:


I'm just guessing, but once you have DENVER in place, looks like you need to fire the js blur event to push it through.   The Se1.0 ref (http://release.seleniumhq.org/selenium-core/1.0.1/reference.html) says:

fireEvent ( locator,eventName )
Explicitly simulate an event, to trigger the corresponding "onevent" handler.

Arguments:

  • locator - an element locator
  • eventName - the event name, e.g. "focus" or "blur"

so I'm guessing you'd need to do something like

| fireEvent; | name=myArea | blur |

-C

Chris McMahon

unread,
Jul 5, 2012, 5:41:39 PM7/5/12
to selenes...@googlegroups.com
On Thu, Jul 5, 2012 at 3:23 PM, Karen Tobo <kjt...@gmail.com> wrote:
Chris, you are my new best friend.

:-)  My pleasure.
 

Interesting that fireEvent was intentionally removed from WebDriver because it's such a hack. Those of us supporting crummy old apps are now supposed to implement our own hacks in JavaScript.

Se/WebDriver should have much better native implementation of stuff like click() and type() ("should" being the operative word).   I'm just getting started with Se/WebDriver in Ruby, we shall see.

-Chris 
Reply all
Reply to author
Forward
0 new messages