Top Level Namespace

Defined Under Namespace

Modules: BlankMethod, Capybara, CheckIn, FillIN, HashStringifyKeys, HashSymbolizeKeys, Helpers, Locator, NodeFinders, Pickles, Waiter Classes: NodeFindError

Constant Summary collapse

SUPPORT_DIR =
File.join(features_dir,'support')

Instance Method Summary collapse

Instance Method Details

#stub_xml_http_request(page) ⇒ Object

XMLHttpRequest.prototype.open broken in Angular2 + zone.js => have to redefine XMLHttpRequest.prototype.send



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
106
107
# File 'lib/cucumber/pickles/helpers/waiter.rb', line 56

def stub_xml_http_request(page)
  page.evaluate_script <<-JAVASCRIPT
    (function() {

      if (window.ajaxRequestIsSet) { return; };
      window.ajaxRequestIsSet = true;

      var oldSend = XMLHttpRequest.prototype.send;
      window.activeRequests =  0;
      XMLHttpRequest.prototype.send = function(method, url, async, user, pass) {
        window.activeRequests++;
        this.addEventListener("readystatechange", function() {
            if (this.readyState == 4) {
              window.activeRequests--;

              #{
                if Pickles.config.log_xhr_response
                  <<-LOG
                  if (parseInt(this.status, 10) >= 400) {
                    console.error("############## ERRRO RESPONSE START ################");
                    console.error(this.response);
                    console.error("############## ERRRO RESPONSE END   ################");
                  }
                  LOG
                end
              }

            }
          }, false);
        oldSend.call(this, method, url, async, user, pass);
      };

      var style = document.createElement('style');
      style.type = 'text/css';
      style.innerHTML = '* {' +
      '/*CSS transitions*/' +
      ' -o-transition-property: none !important;' +
      ' -moz-transition-property: none !important;' +
      ' -ms-transition-property: none !important;' +
      ' -webkit-transition-property: none !important;' +
      '  transition-property: none !important;' +
      '  /*CSS animations*/' +
      '   -webkit-animation: none !important;' +
      '   -moz-animation: none !important;' +
      '   -o-animation: none !important;' +
      '   -ms-animation: none !important;' +
      '   animation: none !important;}';
         document.getElementsByTagName('head')[0].appendChild(style);

    })();
  JAVASCRIPT
end

#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