question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

interceptRequest fails with "The arguments passed to a command are either invalid or malformed"

See original GitHub issue

[//]: # NOTE: This repository only maintains packages that are listed in the Readme. Please make sure that your issue is directly caused by one of these packages and if not file an issue in the correct 3rd party package repository.

Environment (please complete the following information):

  • WebdriverIO version: [6.1.25]
  • Mode: [WDIO Testrunner]
  • If WDIO Testrunner, running sync/async: [sync]
  • Node.js version: [10.17.0]
  • NPM version: [6.13.4]
  • Browser name and version: [Chrome 79]
  • Platform name and version: [Windows 10]
  • Additional wdio packages used (if applicable): [@wdio/sauce-service]

Config of WebdriverIO N/A

Describe the bug Using interceptRequest() fails on SauceLabs with error: The arguments passed to a command are either invalid or malformed.

To Reproduce Use this

     browser.interceptRequest({
        url: 'https://saucelabs.com',
        redirect: 'https://google.com'
      })

[Include code or an example repository that can easily be set up]

Expected behavior This request should intercept the URL request for foo and send to bar. It should not error out.

Log If applicable, add logs to help explain your problem. Create a gist which is a paste of your full Selenium/WebdriverIO logs, and link them here. Do not paste your full Appium logs here, as it will make this issue very long and hard to read! If you are reporting a bug, always include Selenium/WebdriverIO logs!

Additional context Add any other context about the problem here.

Please use the correct markdown

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:28 (21 by maintainers)

github_iconTop GitHub Comments

2reactions
wswebcreationcommented, Jul 19, 2022

Tnx @christian-bromann Will prepare a PR for it later today

1reaction
wswebcreationcommented, Sep 29, 2022

Sorry, no not really.

This is the endpoint

"/session/:sessionId/sauce/ondemand/intercept": {
    "POST": [{
      "command": "interceptRequest",
      "description": "Allows modifying any request made by the browser. You can blacklist, modify, or redirect these as required for your tests.",
      "ref": "https://wiki.saucelabs.com/display/DOCS/Custom+Sauce+Labs+WebDriver+Extensions+for+Network+and+Log+Commands#CustomSauceLabsWebDriverExtensionsforNetworkandLogCommands-InterceptNetworkRequests",
      "examples": [
        [
          "// redirect a request",
          "await browser.interceptRequest({",
          "  'https://saucelabs.com',",
          "  'https://google.com'",
          "})"
        ],
        [
          "// Modify requests to REST API (Mock REST API response)",
          "await browser.interceptRequest({",
          "  'http://sampleapp.appspot.com/api/todos',",
          "  null,",
          "  {",
          "    headers: {",
          "      'x-custom-headers': 'foobar'",
          "    },",
          "    body: [{",
          "      title: 'My custom todo',",
          "      order: 1,",
          "      completed: false,",
          "      url: 'http://todo-backend-express.herokuapp.com/15727'",
          "    }]",
          "  }",
          "})"
        ],
        [
          "// Blacklist requests to 3rd party vendors",
          "await browser.interceptRequest({",
          "  'https://api.segment.io/v1/p',",
          "   null,",
          "  'Failed'",
          "})"
        ]
      ],
      "parameters": [{
        "name": "url",
        "type": "string",
        "description": "An outgoing request URL. Wildcards are supported, for example https://saucelabs.com/rest/v1/* would redirect any v1 rest API requests.",
        "required": true
      },{
         "name": "redirect",
        "type": "string",
        "description": "An absolute URL to where the original request is redirected.",
        "required": false

      }]
    }]
  },
  • having 3 commands in here seems to be impossible
  • having 3 times the same endpoint is also not a thing
  • adding optional arguments also gives issues

seems like I’m stuck here, any ideas would be appreciated.

Temporary workaround would be not to use the API provided by the service but the “normal” options that Sauce Labs offers with extendedDebugging

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid argument - WebDriver - MDN Web Docs
The invalid argument error is a WebDriver error that occurs when the arguments passed to a command are either invalid or malformed.
Read more >
Issues · webdriverio/webdriverio · GitHub
interceptRequest fails with "The arguments passed to a command are either invalid or malformed" Bug Driver Releated issues that are cause by browser ......
Read more >
selenium-webdriver/lib/error.InvalidArgumentError
The arguments passed to a command are either invalid or malformed. new InvalidArgumentError( opt_error ). Parameters. opt_error, (string|undefined).
Read more >
Message: invalid argument error invoking get() with urls read ...
This error message... Traceback (most recent call last): . driver.get(link) . self.execute(Command.GET, {'url': url}) . raise ...
Read more >
Running Genome STRiP SVPreprocess, but I got error ... - GATK
UserException$MalformedWalkerArgumentsException: Invalid command line: Malformed walker argument: Could not find walker with name: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found