Git Product home page Git Product logo

Comments (5)

chmanie avatar chmanie commented on May 29, 2024

Hey could you maybe post more code?

Is the request done when the website loads (i.e. before the first user interaction)?

from wdio-intercept-service.

anbusivam avatar anbusivam commented on May 29, 2024

Hi, I created a sample scenario which resulted in the same issue

  • Defined a feature file as below
Feature: Use Interceptor demo
   Scenario: Use Interceptor
   Given I open some home page and set interceptor
   When I make browser to navigate to another url
   Then I should see the interceptor working
  • Defined the code as below
const { Given, When, Then} = require('cucumber');
var chai = require('chai');
//var request = require('request-promise');
//const { get, post } = require('request-promise');
Given(/^I open some home page and set interceptor$/,function(){
    //browser.setupInterceptor(); this failed with error. "javascript error: Failed to read the 'sessionStorage' property from 'Window': Storage is disabled inside 'data:' URLs.""
    browser.url('https://www.google.com/');
    browser.pause(1000);
    browser.setupInterceptor();
})
When(/^I make browser to navigate to another url$/,function(){
    browser.url('https://www.google.co.in/');
    browser.pause(1000);
    console.log(browser.getRequests()); //this also returned empty array "[]"
    console.log(browser.getRequest(0)); //this has thrown error "Could not find request with index 0"
})
Then(/^I should see the interceptor working$/,function(){
    chai.expect(browser.getRequests().length > 0).to.be.true(); //this failed
    console.log('over');
})

Thank you for the help.

from wdio-intercept-service.

chmanie avatar chmanie commented on May 29, 2024

Yep, this is exactly the right behaviour. The interceptor can only watch on Ajax and fetch requests after any user interaction. In this case there is no user interaction (and probably not even ajax requests).

from wdio-intercept-service.

chmanie avatar chmanie commented on May 29, 2024

Maybe I can try to help you here. What exactly are you trying to achieve?

from wdio-intercept-service.

qatestingresearcher avatar qatestingresearcher commented on May 29, 2024

@anbusivam : Did it resolve, if so could you kindly let me know?

@chmanie: I was trying the similar scenario,browser is making API calls but only for some executions browser.getRequests is returning the values rest it is returning [], basically results are inconsistent

Tried the below options, but not having the consistency in results. So I assume it should be something with the pause.

  1. With the version wdio-intercept-service version 4.2.1 and 4.2.2
  2. With browser.getRequest({includingPending:true})
    Any thoughts?

from wdio-intercept-service.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.