| Module | Selenium::Client::Extensions |
| In: |
lib/selenium/client/extensions.rb
|
Convenience methods not explicitely part of the protocol
These for all Ajax request to finish (Only works if you are using prototype, the wait in happenning browser side)
See davidvollbracht.com/2008/6/4/30-days-of-tech-day-3-waitforajax for more background.
# File lib/selenium/client/extensions.rb, line 11
11: def wait_for_ajax(timeout_in_seconds=nil)
12: wait_for_condition "selenium.browserbot.getCurrentWindow().Ajax.activeRequestCount == 0", timeout_in_seconds
13: end
Wait for all Prototype effects to be processed (the wait in happenning browser side).
Credits to github.com/brynary/webrat/tree/master
# File lib/selenium/client/extensions.rb, line 18
18: def wait_for_effects(timeout_in_seconds=nil)
19: wait_for_condition "window.Effect.Queue.size() == 0", timeout_in_seconds
20: end
Wait for an element to be present (the wait in happenning browser side).
# File lib/selenium/client/extensions.rb, line 23
23: def wait_for_element(locator, timeout_in_seconds=nil)
24: script = "var element;\ntry {\nelement = selenium.browserbot.findElement('\#{locator}');\n} catch(e) {\nelement = null;\n}\nelement != null\n"
25:
26: wait_for_condition script, timeout_in_seconds
27: end
Wait for a field to get a specific value (the wait in happenning browser side).
# File lib/selenium/client/extensions.rb, line 81
81: def wait_for_field_value(locator, expected_value, timeout_in_seconds=nil)
82: script = "var element;
83: try {
84: element = selenium.browserbot.findElement('#{locator}');
85: } catch(e) {
86: element = null;
87: }
88: element != null && element.value == '#{expected_value}'"
89:
90: wait_for_condition script, timeout_in_seconds
91: end
Wait for an element to NOT be present (the wait in happenning browser side).
# File lib/selenium/client/extensions.rb, line 39
39: def wait_for_no_element(locator, timeout_in_seconds=nil)
40: script = "var element;\ntry {\nelement = selenium.browserbot.findElement('\#{locator}');\n} catch(e) {\nelement = null;\n}\nelement == null\n"
41:
42: wait_for_condition script, timeout_in_seconds
43: end
Wait for some text to NOT be present (the wait in happenning browser side).
# File lib/selenium/client/extensions.rb, line 68
68: def wait_for_no_text(locator, original_text, timeout_in_seconds=nil)
69: script = "var element;
70: try {
71: element = selenium.browserbot.findElement('#{locator}');
72: } catch(e) {
73: element = null;
74: }
75: element != null && element.innerHTML != '#{original_text}'"
76:
77: wait_for_condition script, time
78: end
Wait for some text to be present (the wait in happenning browser side).
# File lib/selenium/client/extensions.rb, line 55
55: def wait_for_text(locator, text, timeout_in_seconds=nil)
56: script = "var element;
57: try {
58: element = selenium.browserbot.findElement('#{locator}');
59: } catch(e) {
60: element = null;
61: }
62: element != null && element.innerHTML == '#{text}'"
63:
64: wait_for_condition script, timeout_in_seconds
65: end