-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
31 lines (26 loc) · 1.37 KB
/
README
File metadata and controls
31 lines (26 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
For some reason there's an AfterStep hook in Cucumber, but no BeforeStep. This
rectifies that in Cucumber 0.8.3. Untested in any other version.
In a large, older application I've started using Selenium RC to run browser tests.
One of the fine features of the application is that some prototype responders
never hook into onComplete to declinate activeRequestCount, causing the waitForAjax
command in Selenium RC to time out. I wanted to bulldoze through the fine points
of prototype (if anybody knows how to get a list of active responders so its possible
to track down what to debug, please do tell) and do something like this:
def responders
@browser.get_eval("selenium.browserbot.getUserWindow().Ajax.activeRequestCount").to_i
end
BeforeStep do |scenario|
@before_responders = responders
end
AfterStep do |scenario|
# wait for ajax after every step if there's been a new ajax responder added to the pool.
ajax_waits = 0
while (responders > @before_responders) do
break if ajax_waits > 50 # give the new request up to 5 seconds to do what it does
ajax_waits += 1
sleep(0.1)
end
end
So if there was an old prototype responder that didn't give up the ghost properly we
promptly ignore it, wait on any new ones, and, assuming we're not buried underneath
unresolved prototype objects every step of the way, carry on our tests at a fine clip.