Coder Social home page Coder Social logo

Comments (6)

christian-bromann avatar christian-bromann commented on July 2, 2024

@MubarakGj thanks for raising the issue.

I have to verify if this may already work in v9 our upcoming major release. I will get back to you on that.

from webdriverio.

thecotne avatar thecotne commented on July 2, 2024

// switch to Puppeteer
const puppeteerBrowser = await browser.getPuppeteer()
const page = (await puppeteerBrowser.pages())[0]
await page.setRequestInterception(true)
page.on('request', interceptedRequest => {
if (interceptedRequest.url().endsWith('webdriverio.png')) {
return interceptedRequest.continue({
url: 'https://user-images.githubusercontent.com/10379601/29446482-04f7036a-841f-11e7-9872-91d1fc2ea683.png'
})
}
interceptedRequest.continue()
})

from webdriverio.

wdio-bot avatar wdio-bot commented on July 2, 2024

Thanks for reporting!

We greatly appreciate any contributions that help resolve the bug. While we understand that active contributors have their own priorities, we kindly request your assistance if you rely on this bug being fixed. We encourage you to take a look at our contribution guidelines or join our friendly Discord development server, where you can ask any questions you may have. Thank you for your support, and cheers!

from webdriverio.

christian-bromann avatar christian-bromann commented on July 2, 2024

In v9 this is currently not possible but can be implemented right here. What type of user interface would you like to see? How would you like to modify request data?

from webdriverio.

MubarakGj avatar MubarakGj commented on July 2, 2024

if we have a method somthing like, browser.intercept(params...) to modify the requests sent to a specific destination, calling the method should modify all the requests sent to the URL after this point.
for simple modifications . ex: if we want to modify an header and add one extra header to the request then,

 browser.intercept("URL to intercept", {
    headers:{
  'header1':'value1', // modifies the value, if header already exists in request else adds the header
  'header2':'value2' 
  }
});

this can directly add those headers to all the intercepted requests or modify them if they already exist.
for complex modifications, if we have sth like the below would be helpful:

 browser.intercept("url to intercept", (req)=>{
    req.headers = {'header1':'value1'} //replacing the whole header section
    req.body['productId'] = '23456';
})

We can do even more things if we can intercept all the requests going out of the browser by giving a generic target URL value. something like "**/*" or "".
Also If we can have a way to set these interceptions at the browser session level (setting the interception once for all pages), we can avoid setting these on each page we navigate. This will help us to add the interception at the beginning of the script and we can intercept all requests till the execution is completed.

from webdriverio.

christian-bromann avatar christian-bromann commented on July 2, 2024

@MubarakGj this will be possible in v9, please follow #13055 for details!

from webdriverio.

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.