Configuring Firefox settings in Nightwatch

Is there a way to set Firefox preferences in nightwatch? I am trying to achieve the same thing in Java using nightwatch.

To set Firefox preferences in nightwatch, you can use the following code snippet:
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("intl.accept_languages", "de");
WebDriver driver = new FirefoxDriver(profile);

I have successfully implemented this in Chrome, but I'm struggling to do the same in Firefox.

For setting preferences in Chrome, you can use the following desired capabilities in your nightwatch configuration:
"desiredCapabilities": {
  "browserName": "chrome",
  "javascriptEnabled": true,
  "acceptSslCerts": true,
  "chromeOptions" :{
    "prefs": {
      "intl.accept_languages":"fr"
    }
  }
}

Any help on how to set Firefox preferences would be greatly appreciated! Thank you.

Answer №1

If you're facing issues with your Nightwatch test on Firefox, here's a solution for you:

1) Setting up a new Firefox profile:

To start, open a terminal and run the command: "firefox -p"
Then, create a new profile named "webdriver".

2) Customizing the new profile:

Access the configuration page by entering "about:config" in the URL bar.
Look for the setting "intl.accept_languages" and make necessary changes.
Close Firefox for now.

3) Configuring Nightwatch to use the new profile:

  1. "webdriver.firefox.profile" : "webdriver"

  2. List item "browserName" : "firefox"

Note that this is not a "desiredCapability" parameter.

Approach 1: (test configuration)

{
   "yourTest" : {
      "default" : {
        ...
        "webdriver.firefox.profile" : "webdriver",
        "launch_url": "http://localhost:3000",
        "desiredCapabilities" : {
          "browserName" : "firefox",
          "javascriptEnabled" : true,
          "acceptSslCerts" : true
        }
     }
   }
}

Approach 2: (global configuration)

{
  ...
  "selenium" : {
    "start_process" : false,
    "server_path" : "",
    "log_path" : "",
    "host" : "127.0.0.1",
    "port" : 4444,
    "cli_args" : {
      "webdriver.chrome.driver" : "",
      "webdriver.ie.driver" : "",
      "webdriver.firefox.profile" : "webdriver"
    }
  },
  ...
  "yourTest": {
    "default": {
        "launch_url": "http://localhost:3000",
        "desiredCapabilities" : {
            "browserName" : "firefox",
            "javascriptEnabled" : true,
            "acceptSslCerts" : true
        }
    },
  ...
  }
  ...
}

For more details on selenium settings, visit:

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

Tips for preventing the need to create a function within a loop

Currently, I am in the process of collecting data through REST calls. I have created a function that accesses a "directory" endpoint to retrieve a list of individuals. While I can easily obtain details about their children, I need to make individual AP ...

Error encountered when asynchronously iterating over an object in TypeScript

Could someone please help me understand why I am getting an error with this code? var promise = new Promise((resolve, reject) => { resolve([1, 2, 3, 4, 5]); }); async function doSomethingAsync() { var data = await promise; data.forEach(v = ...

Unauthenticated user attempting to send a post request via React JS without proper authentication

Currently, I am working on a project where I am following a video tutorial that demonstrates how to authenticate a user using node and passport JS. The tutorial itself uses Hogan JS as its view engine, but I have decided to implement React as my front end ...

Transforming text elements into JSON format

My text contains a list of items formatted as follows: var text = "<li>M3-2200 (da2/M3-2200)</li><li>N3-2200 (da2/N3-2200)</li><li>Picasso (picasso/A500)</li><li>Picasso (picasso/A501)</li><li>Picasso ...

The functionality of the JavaScript Array Map function is not meeting our expectations

I am encountering an issue with the Array.map function that is not behaving as expected. Below is a simplified example to help me understand where I am going wrong. Here is the code snippet in question: console.log(this.reportTestData) let data = this.rep ...

Looking to create a format for displaying short comic strips in a grid pattern

I am struggling to create an image grid for my small comics. I want to have 2 columns and 3 rows, but all the divs end up in the same place. I tried using display: flex, but it didn't work as expected. Additionally, I want the grid to be responsive, b ...

What is the best way to handle mapping an array with uncertain levels of nesting?

My task involves rendering an array of comments in ReactJs, each of which can have nested comments at unknown levels. I am struggling to figure out how to display these comments with their respective nesting levels. comment 1 -- comment 2 -- comment 3 --- ...

Dreamweaver restricts my ability to utilize JavaScript for coding

My JavaScript isn't working in Dreamweaver. I have linked the script file correctly using the given code: <script src="file:///C:/Users/Matthew/Desktop/Untitled-2.js" type="text/script"></script> However, when I try to call it with scrip ...

Continuous scroll notification within the fixed menu until reaching the bottom

I'm looking to achieve a scrolling notification message that stays fixed at the bottom of a top-fixed menu while the body content continues to scroll normally. Here's an example in this fiddle: HTML: <div class="menu-fixed">I am a fixed me ...

Eliminate the prefixes of object keys in Node.js

This is my first time reaching out for help on a forum. I've been struggling with an issue for days and haven't been able to find a solution. It all started with a database query that returned the following data: { "prod_format": "400 ml", "pro ...

Error with the Knockout framework's inability to bind to the model

I seem to be encountering an issue with binding Knockout to a model in my code. Despite the code firing and returning a JSON object, the table appears empty. Any advice or suggestions would be greatly appreciated. HTML <table style="border: double"& ...

What is the best way to incorporate a formArray into a formGroup?

Before anything else, I want to apologize for any errors in my English. I seem to be having trouble adding an array field to a formGroup. My issue arises when attempting to use the push method to add a formArray to my rate formGroup. It appears that the ...

How can the test method name be obtained within TestNG listeners during the Configuration phase?

I am working with a TestNG listener that implements IInvokedMethodListener. During the @BeforeMethod annotation, I am setting up some test context. Here is an example of what I have: public class ThucydidesInvokedMethodListener implements IInvokedMethodLi ...

What's the best way to incorporate mouseenter() and mouseleave() into several elements sharing the same class?

I have a vision for a fun game where players must navigate from one platform to another without falling off the edges. The game starts when you hover over the initial platform, and success is achieved by reaching the final platform. However, failure occurs ...

Is there a way to programmatically retrieve files from a pop-up window using Selenium in Python?

I'm currently working on automating the process of downloading files from a pop-up dialog using selenium-python. Specifically, I need to programmatically click 'ok'. I attempted to create a profile but am unsure how to integrate it with the ...

Transfer only certain directories located within the primary directory

Imagine having a main-folder, which contains folders of type my-folder-x. Within these my-folder-x folders, there are subfolders and files. -main-folder -my-folder-a -build-folder -demo-folder dummy.js dummy.css my.json -dummy-folder - ...

Feed information into a Select element from the Material UI version 1 beta

Having trouble populating data from a < Select > component in Material UI version 1.0.0.0 beta. Snippet of my code: This section is located inside the render() method. <Select value={this.state.DivisionState} onChange={this.handleChang ...

Using HTML and JavaScript to create a link that appears as a URL but actually directs to a JavaScript function

I am working on an HTML page and I am trying to create a link that appears to go to 'example.html' but actually goes to 'javascript:ajaxLoad(example.html);'. Here is what I have tried: <a href="example" onclick="javascipt:ajaxLoad( ...

Troubleshooting the issue: Incompatibility between jQuery .focus() and dynamically generated list items from ng-repeat in AngularJS

I am currently working on enhancing the keyboard accessibility of a website, specifically focusing on making a dropdown menu accessible via keyboard. I am attempting to establish focus on the element with the id= list-0. Below is the HTML code snippet: & ...

NodeJs Importing a File

Currently working with NodeJS, I have encountered a challenge. Is it possible to require a JavaScript file in Node similar to how we do in browsers? When using the require() method, I noticed that the JavaScript file called does not have access to global v ...