Top Level Namespace
Defined Under Namespace
Modules: BlankMethod, Capybara, CheckIn, FillIN, HashSymbolizeKeys, Helpers, Locator, NodeFinders, Pickles, Waiter Classes: NodeFindError
Constant Summary collapse
- SUPPORT_DIR =
File.join(features_dir,'support')
Instance Method Summary collapse
-
#stub_xml_http_request(page) ⇒ Object
original code:.
- #trigger(text, event, within) ⇒ Object
- #wait_flags(text) ⇒ Object
Instance Method Details
#stub_xml_http_request(page) ⇒ Object
original code:
(function() {
var oldOpen = XMLHttpRequest.prototype.open;
window.openHTTPs = 0;
XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {
window.openHTTPs++;
this.addEventListener("readystatechange", function() {
if(this.readyState == 4) {
window.openHTTPs--;
}
}, false);
oldOpen.call(this, method, url, async, user, pass);
}
})(XMLHttpRequest);
module Capybara
module Selenium
class Driver
class << self
alias __pickles_redefined__new new
#
# Monkey patch initializer to load custom chrome extension in extensions/chrome
#
# It will add window.activeRequests to keep track of active AJAX requests in tests
#
# For source code of extension see extensions/chrome/src/inject/inject.js
#
# TODO: support all major browser drivers
#
def new(app, ={})
if [:browser].to_s == "chrome"
[:desired_capabilities] ||= {}
[:desired_capabilities]["chromeOptions"] ||= {}
[:desired_capabilities]["chromeOptions"]["extensions"] ||= []
extension_path = File.('extensions/chrome/compiled.crx.base64', __dir__)
[:desired_capabilities]["chromeOptions"]["extensions"].unshift(File.read(extension_path))
end
__pickles_redefined__new(app, )
end
end
end
end
end
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/cucumber/pickles/helpers/waiter.rb', line 53 def stub_xml_http_request(page) page.evaluate_script " (function() {\n\n if (window.ajaxRequestIsSet) { return; };\n window.ajaxRequestIsSet = true;\n\n var oldOpen = XMLHttpRequest.prototype.open;\n window.activeRequests = 0;\n XMLHttpRequest.prototype.open = function(method, url, async, user, pass) {\n window.activeRequests++;\n this.addEventListener(\"readystatechange\", function() {\n if (this.readyState == 4) {\n window.activeRequests--;\n\n \#{\n if Pickles.config.log_xhr_response\n <<-LOG\n if (parseInt(this.status, 10) >= 400) {\n console.error(\"############## ERRRO RESPONSE START ################\");\n console.error(this.response);\n console.error(\"############## ERRRO RESPONSE END ################\");\n }\n LOG\n end\n }\n\n }\n }, false);\n oldOpen.call(this, method, url, async, user, pass);\n };\n\n\n var style = document.createElement('style');\n style.type = 'text/css';\n style.innerHTML = '* {' +\n '/*CSS transitions*/' +\n ' -o-transition-property: none !important;' +\n ' -moz-transition-property: none !important;' +\n ' -ms-transition-property: none !important;' +\n ' -webkit-transition-property: none !important;' +\n ' transition-property: none !important;' +\n ' /*CSS animations*/' +\n ' -webkit-animation: none !important;' +\n ' -moz-animation: none !important;' +\n ' -o-animation: none !important;' +\n ' -ms-animation: none !important;' +\n ' animation: none !important;}';\n document.getElementsByTagName('head')[0].appendChild(style);\n\n })();\n JAVASCRIPT\nend\n" |
#trigger(text, event, within) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/cucumber/pickles/steps/click.rb', line 19 def trigger(text, event, within) js_wait, text, ajax_wait = wait_flags(text) if js_wait Waiter.wait { Pickles.find_node(text, within: within).public_send(event) } else Pickles.find_node(text, within: within).public_send(event) end Waiter.wait_for_ajax if ajax_wait end |
#wait_flags(text) ⇒ Object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/cucumber/pickles/steps/click.rb', line 1 def wait_flags(text) if text.starts_with?('>') text = text[1..-1] Waiter.wait_for_ajax js_wait = true end if text.ends_with?('>') text = text.chomp('>') ajax_wait = true end [js_wait, text, ajax_wait] end |