How to pass command line arguments into Chrome using WebDriverIO Selenium from the config.js file

Is there a way to add the disable-web-security flag for Chrome in order to conduct UI tests? How can I incorporate commands into the wdio.config file () to achieve this?

  capabilities: [{
        browserName: 'chrome'
    }]

Answer №1

If you want to customize chrome flags, simply include them in the desired capabilities using goog:chromeOptions

capabilities: [{
    browserName: 'chrome',
    'goog:chromeOptions': {
        args: ['disable-web-security']
    }
}]

For further details on the chromeOptions object, refer to the chromedriver docs.

Answer №2

Huge shoutout to Christian for helping me with the correct syntax!

  configuration: [{
        browserType: 'chrome',
         'goog:chromePreferences': {
            options: ['--disable-web-security']
        }
    }]

Answer №3

Recently, a change has been made in @wdio/cli version 5.11.13 and chromedriver version 76.0.0. This change caused an issue where I was unable to pass the parameter chromeOptions, resulting in an error message saying:

invalid argument: unrecognized capability: chromeOptions
.

After doing some investigation, I found that passing goog:chromeOptions instead now works:

  capabilities: [{
    browserName: 'chrome',
    'goog:chromeOptions': {
      args: ['--disable-web-security'],
    },
  }]

Answer №4

To turn off javascript in the browser with webdriverio, within your wdio.config file you will have to include:

capabilities: [{
    browserName: 'chrome',
     'goog:chromeOptions': {
            "args" : ["start-fullscreen"],
            "prefs" : {
                    'profile.managed_default_content_settings.javascript': 2
            }
    }
}]

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Generating numerous checkboxes dynamically

Seeking assistance with a jQuery function that dynamically generates or clones checkboxes. The challenge is to display the sub_item checkbox when the main_item checkbox is checked. For a demonstration, you can visit this DEMO Jquery $('#btnAdd' ...

Arrow icon from Material UI for a smaller device

As I work on coding a tab bar, I have encountered an issue where the indicator arrow button () is not displaying when the width of the tab bar goes below 600px. I would like it to appear like this: https://i.stack.imgur.com/PDum9.png However, currently i ...

What steps can I take to stop a browser from triggering a ContextMenu event when a user performs a prolonged touch

While touch events are supported by browsers and may trigger mouse events, in certain industrial settings, it is preferred to handle all touch events as click events. Is there a way to globally disable context menu events generated by the browser? Alternat ...

Delaying navigation to the next URL until a distinct category name is identified

Within this section of JSP code, I am implementing JavaScript and AJAX to validate the uniqueness of a category name. When the submit button is pressed for the first time, it prompts the user to enter a category name. Subsequently, an AJAX call is made to ...

Incorporating the angular UI router effectively by reusing the same templateUrl and controller multiple times

Exploring the AngularUI Router framework for the first time, I am curious about how to enhance the code snippet below. Everything is functioning well at the moment, but as the project progresses, it will feature 20 questions or more. I want to avoid repea ...

Selenium can launch the browser, however, it seems to be having

My code opens Google Chrome, but it does not navigate to google.com. What could be the issue? from selenium import webdriver path = r'C:\Program Files\Google\Chrome\Application\chrome.exe' options = webdriver.ChromeOptio ...

Creating prototypes for objects starting from an empty state

Below is the custom code structure I have created: module.exports = (function() { Function.prototype.extend = function(obj) { for (var prop in obj) { this[prop] = obj[prop]; } } })(); var CustomHelpers = {}; CustomHelpers.prototype.get ...

Is it advisable to employ jQuery(this) in this specific scenario?

My PHP script generates HTML a:link divs with different $linkname and $pageid values. It also creates corresponding jQuery scripts for each link: $output = '<a class="sig_lightbox_link" id="' . $pageid . '">' . ...

Utilizing data in mongoose: A beginner's guide

I have two database models: User and Conversations. The User model has the following schema: const userSchema = mongoose.Schema({ username: String, logo: String, ..... }) and the Conversation schema is as follows: const conversationSchema = mongo ...

Encountering a "DOM Exception 11: InvalidStateError" when attempting to use websocket.send

I encountered the following error message: DOM Invalidate exception 11 This error is coming from the code snippet below, but I'm having trouble identifying the root cause. /*The coding style may appear pseudo-stylish with potential syntax errors*/ ...

Regular Expression designed specifically for detecting alternative clicks

When using ngpattern for validation, I have encountered an issue where my error message is displaying for a different reason than intended. The error message should only show if the field is empty or contains only special characters. <textarea name="ti ...

Unlocking the data within an object across all Components in Vue

Recently, I've started using Vue and encountered a problem. I'm trying to access data stored inside an Object within one of my components. To practice, I decided to create a cart system with hardcoded data for a few games in the app. Below is the ...

Does anyone have an idea of the origin of the item in this ajax .each function?

Currently, I am utilizing the Etsy API with JavaScript by calling this AJAX code: $.ajax({ url: etsyURL, dataType: 'jsonp', success: function(data) { This code returns an object array, if I'm not mistaken. It then proceeds to enter this . ...

ReactJS - What is the best way to output a string from a functional component?

Utilizing @apollo/client in my React project for handling backend APIs. Within the file appollo.js, I am attempting to make a call to the backend API link based on certain conditions. Currently, appollo.js consists solely of functions and is not considere ...

Frontend utilizing the Next-auth Github Provider for Profile Consumption

After following the official documentation for implementing SSO with the Next-auth Github provider in my App, I encountered an issue where the Client API documentation suggested using useSession() to retrieve session information, but it was not returning t ...

Issue: browser process sub thread took 57 milliseconds to wait for network service using Selenium ChromeDriver and Chrome on a Windows operating system

Our current project involves using Selenium in C# to manage Chrome browser. We are experiencing an issue that occurs in both Chrome v74 with the corresponding chromedriver, and also in Chrome v75 (beta) with its respective chromedriver. After approximatel ...

What is the process for implementing a third-party component in my web application?

After some experimentation, I've discovered that it's necessary to include the link to the css files in the header and then mention the link to the js files before the closing tag. However, I encountered difficulties when trying to use a compone ...

"Embedding a Highcharts web chart within a pop-up modal window

I am looking to incorporate a Highcharts web chart onto a specific part of a Bootstrap modal, while ensuring the size remains dynamic along with the modal itself. Here's what I have attempted so far: Sample HTML code: <td><a href="#">${ ...

Accessing public static files in Express by using the routes folder

I'm currently facing an issue with accessing a static file named 'home.html' located in the public directory of my app's architecture: public home.html routes index.js views myapp.js In myapp.js: var express = require('ex ...

What is the best way to have a form open upwards when hovered over or clicked on?

Attempting to create a button in the bottom right corner that will reveal a form when clicked or hovered over. The form should slide open slowly and close after clicking on login, but currently the button is moving down as the form opens. The button also ...