Using Python3 and Selenium with Firefox, the FirefoxProfile.set_preference() method seems to be disreg

Attempting to configure specific preference values on a selenium 2.53.1 operated Firefox 45.0.1 using Python 3.4, such as deactivating JavaScript:

>>> from selenium import webdriver
>>> profile = webdriver.FirefoxProfile()
>>> profile.set_preference('javascript.enabled', False)
>>> driver = webdriver.Firefox(firefox_profile=profile)

Yet, this customization seems to be disregarded, as the about:config displays

javascript.enabled  true

and JavaScript functions continue to run normally. Despite the fact that about:config reflects it as user-configured. What could be the issue?

Answer №1

There is currently no way to do it globally through the User Interface.

However, there are still a few other options available. Depending on what you want to block, you may want to consider using a script blocker like

Answer №2

Although an old issue, there is a simple solution for it in Selenium 3.14 and Firefox version 63:

To disable JavaScript, utilize the Options() method:

from selenium.webdriver.firefox.options import Options
options = Options()
options.preferences.update({"javascript.enabled": False})
browser = webdriver.Firefox(options=options)
browser.get('about:config')

This problem was successfully addressed in this thread: How to disable Javascript when using Selenium?

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

A JavaScript function to separate a URL and eliminate the final segment

http://www.google.com/site!#656126.72367 Is there a way to split and remove the part after the exclamation mark in this URL using JavaScript when the page is loaded? I am looking to achieve http://www.google.com/site ...

Tips on shutting down all web browser instances before running a test in Selenium WebDriver

Is there a way to automatically close all previously opened browser windows before starting a new test in Selenium WebDriver? I attempted to use the code below to close any existing Chrome browser windows, however, instead of closing the old windows it is ...

Overlap of columns within a nested flexbox arrangement

While working with React and Styled Components, I encountered a problem of elements overlapping each other: https://i.stack.imgur.com/RuCYu.png There are a few instances of overlap, including: The padding below the <ul> element is colliding with ...

What are some ways I can integrate my Json object into my IONIC app rather than relying on a hardcoded object?

I stumbled upon this IONIC app's services.js file and found an example using a hardcoded object called "employees." Instead of using the hardcoded object, I wanted to use a JSON file. However, my attempt to make this change did not work as expected. I ...

Instructions on injecting 10 parameter values into a selenium test, and running them one after the other

In my SELENIUM base test, I have defined parameters and need to test with 10 different sets of values. It becomes tedious to manually change the test parameters each time to get results. Is there a way to create a file containing these 10 different values ...

Struggling with incorporating a search feature? Encounter the error message "TypeError: data.filter is not a function"?

UPDATE: here is what console.log(data) shows. The data appears correctly, but the filtering process seems to be malfunctioning.] !https://imgur.com/a/SsEDAKj! UPDATE 2: this.state.items represents an array. I am currently working on integrating a search ...

Can JavaScript be executed from the console while navigating between pages?

I am facing a challenge that I can't find any solutions for online or elsewhere. The task at hand seems straightforward. I am using the Chrome console and attempting to run Javascript code to navigate between pages with pauses in between. It feels lik ...

What are the best techniques for optimizing loops when inserting data into a database?

Hi there! Currently, I am facing a challenge in inserting data from an XML file into my MySql database using Sails.js and waterline for the queries. In my database schema, I have two tables named Users and Pets. A user can have multiple pets, and a pet can ...

Unable to locate module in Node.js - module.js

I encountered an error while running the node server which states: $ node server.js module.js:339 throw err; ^ Error: Cannot find module './server/routes' at Function.Module._resolveFilename (module.js:337:15) at Function.Module ...

Is there a way to imitate a method that initiates an AJAX request?

I am currently working on writing tests for my Angular application and I need to mock a method in order to avoid making actual requests to the server. Within my grid.service.ts file, here is the method I am trying to mock: loadAccountListPromise(id: str ...

What is the process for attaching the stack when initializing and throwing errors separately in JavaScript?

In all the documentation I've read, it consistently advises to both throw and initialize errors on the same line. For example: throw new Error("My error"); But what if you were to first initialize the error and then throw it on separate lines? For ...

Placing a Fresh Item into a Designated Slot within an Array

Imagine having a MongoDB collection that consists of an array of objects being retrieved from an Angular Resource. [{_id: "565ee3582b8981f015494cef", button: "", reference: "", text: "", title: "", …}, {_id: "565ee3582b8981f015494cf0", button: "", ref ...

Dealing with an Incorrect Date in JavaScript

After working on a JavaScript logic to extract date and time from certain values, I realized that my approach needed some adjustments. Initially, I parsed the DateTime and converted it to a string. Then, I split the string to retrieve the date component. ...

java.io.IOException: An error occurred while trying to attach a screenshot to the extent report - media not found

Encountered an issue when attempting to attach a screenshot captured and saved in a Selenium project to the Extent test automation report. An error message stating java.io.IOException: Media was not found at [C:\Users\Suresh\git\BasicFu ...

How to generate a prop with an ID-value pair in Vue using JavaScript

When working with TypeScript in Vue components, I have come across the following way to initialize props: @Prop({ type: Object }) tabDetails: tabDetailsTypes The structure of the tabDetailsTypes looks like this: export interface tabDetailsTypes { ...

The MVC 5 view is unable to display an HTML image when adding it within an appended div

Currently, I am working with ASP.net MVC5 at a novice level. I'm faced with the challenge of creating a div that displays an image using a JavaScript function. Here is the code snippet I have: function showLoadingImage() { $('#submit_Em ...

Exploring the functionality of multiple index pages in angularjs

I am trying to access the localhost:3000/admin which is located in my views. The index.html and admin.html are two separate base files, one for users and the other for the admin dashboard respectively. Here is a snippet from my app.routes.js file: angul ...

Issue with loading Three.js asynchronously

My attempt to determine the maximum value of a point cloud data using the following code proved unsuccessful. import { PLYLoader } from "three/examples/jsm/loaders/PLYLoader"; let max_x = -Infinity; function initModel() { new PLYLoader().load ...

A guide on organizing items with matching property values in NodeJS

I have 3 separate JSON arrays that contain error details categorized by type 1, 2, and 3. const data1 = [ { "ErrorType": "Error-1A", "Error": "wrong ip address for 1A", "SERVER_COUNT": 9 }, ...

Tips for utilizing date objects instead of date 'strings' while still obtaining the desired outcome

Below is a schema that I am working with: var MySchema = new Schema ({ event: { full: String, date: String, name: String, } }); To illustrate, here are some examples of the values: event.date = '16/02/20 ...