Testing javascript prompt popups with Culerity

4 October 2009 in Ruby on Rails, Testing

Solution


And /^I test the prompt/ do
  $browser.webclient.send_remote(:setPromptHandler) ...
         {"lambda {'god help me if this worked'}"}
  And %Q{I follow "hi"}
  Then %Q{I should see "god help me if this worked"}
end

In my previous post, I chronicled the pains of testing javascript popups with Celerity. I thought I had solved my problem until I tried to implement a real test in Cucumber. In my project, I am running standard ruby, but Celerity is jruby. Because you probably don’t want to convert your project to jruby just so you can test javascript a library named Culerity lets you run Celerity without having to run your rails app in jruby. It starts up a separate jruby server process and shells out commands on your behalf. This works pretty well, except of course, when testing javascript prompt popups.

Again, the code in the documentation doesn’t seem to work as advertised, so I had to struggle again with a fix. I’m not going to go into why this works - I’m not totally sure myself. I just want to give you the solution so you won’t have to go through this all over again. I am your testing martyr:


And /^I test the prompt/ do
  $browser.webclient.send_remote(:setPromptHandler) . . .
          {"lambda {'god help me if this worked'}"}
  And %Q{I follow "hi"}
  Then %Q{I should see "god help me if this worked"}
end

Hope that helps someone!

Tags: , , ,

4 October 2009 Ruby on Rails, Testing

No comments yet.

Leave a comment



Tweets

  • Tobi:
    ^^ shit, ok now I see it's not your fault, its (my...
  • Tobi:
    Thanks for this great writeup! btw. you missed...
  • Chris Young:
    Thanks for letting me know. I updated the link....
  • maxjgon:
    The link of the project in Github is broken!...
  • Chris Young:
    Oh I see . . . Maybe I should check out this so-c...