Subversion Repositories SmartDukaan

Rev

Rev 37424 | Rev 37428 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 37424 Rev 37425
Line 227... Line 227...
227
    private void installResponseCapture(WebDriver driver) {
227
    private void installResponseCapture(WebDriver driver) {
228
        try {
228
        try {
229
            ((JavascriptExecutor) driver).executeScript(
229
            ((JavascriptExecutor) driver).executeScript(
230
                "if (!window.__oppoCapInstalled) {"
230
                "if (!window.__oppoCapInstalled) {"
231
              + "  window.__oppoCapInstalled = true; window.__oppoResp = null;"
231
              + "  window.__oppoCapInstalled = true; window.__oppoResp = null;"
-
 
232
              // axios can sit on either transport, and realme's page uses fetch --
-
 
233
              // an XHR-only hook silently captures nothing, which is exactly what
-
 
234
              // 'no getDeviceInfo response captured' was reporting.
232
              + "  var O = XMLHttpRequest.prototype.open;"
235
              + "  var O = XMLHttpRequest.prototype.open;"
233
              + "  XMLHttpRequest.prototype.open = function(m,u){"
236
              + "  XMLHttpRequest.prototype.open = function(m,u){"
234
              + "    this.addEventListener('load', function(){"
237
              + "    this.addEventListener('load', function(){"
235
              + "      try { if (String(u).indexOf('getDeviceInfo') !== -1) window.__oppoResp = this.responseText; } catch(e){}"
238
              + "      try { if (String(u).indexOf('getDeviceInfo') !== -1) window.__oppoResp = this.responseText; } catch(e){}"
236
              + "    });"
239
              + "    });"
237
              + "    return O.apply(this, arguments);"
240
              + "    return O.apply(this, arguments);"
238
              + "  };"
241
              + "  };"
-
 
242
              + "  var F = window.fetch;"
-
 
243
              + "  if (F) { window.fetch = function(){"
-
 
244
              + "    var u = arguments[0]; u = (u && u.url) ? u.url : String(u);"
-
 
245
              + "    return F.apply(this, arguments).then(function(r){"
-
 
246
              + "      try { if (u.indexOf('getDeviceInfo') !== -1) { r.clone().text().then(function(t){ window.__oppoResp = t; }); } } catch(e){}"
-
 
247
              + "      return r;"
-
 
248
              + "    });"
-
 
249
              + "  }; }"
239
              + "}");
250
              + "}");
240
        } catch (Exception e) {
251
        } catch (Exception e) {
241
            LOGGER.warn("Could not install the response capture hook: " + e.getMessage());
252
            LOGGER.warn("Could not install the response capture hook: " + e.getMessage());
242
        }
253
        }
243
    }
254
    }