Acquiring the console log data from Firefox version 43 using Selenium, all without the use of any

Can Selenium retrieve the console.log from browsers like Firefox 43? If so, how can it be done?

My settings are as follows:

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
LoggingPreferences logs = new LoggingPreferences();
logs.enable(LogType.BROWSER, Level.ALL);
logs.enable(LogType.DRIVER, Level.ALL);
logs.enable(LogType.CLIENT, Level.ALL);
logs.enable(LogType.PERFORMANCE, Level.ALL);
logs.enable(LogType.PROFILER, Level.ALL);
logs.enable(LogType.SERVER, Level.ALL);
capabilities.setCapability(CapabilityType.LOGGING_PREFS, logs);

FirefoxBinary binary = new FirefoxBinary(new File(...));
FirefoxProfile profile = new FirefoxProfile();
WebDriver driver = new FirefoxDriver(binary, profile, capabilities);

//...performing actions with the driver ...

driver.manage().logs().get(LogType.BROWSER) // tried every LogType

The current output I receive looks something like this:

1450878255029   addons.xpi  DEBUG   startup
...
Error in parsing value for 'display'.  Declaration dropped.

However, I am not able to see the output that is written in the browser's JavaScript console log.

I have experimented with various Firefox profile settings such as:

profile.setPreference("extensions.sdk.console.logLevel", "all");
profile.setPreference("webdriver.log.file",tempfile.getAbsolutePath());
profile.setPreference("webdriver.firefox.logfile", othertempfile.getAbsolutePath());
profile.setPreference("webdriver.log.driver", "ALL");

Unfortunately, none of these attempts have helped solve the issue. The same process works perfectly fine with Chrome.

Selenium version: 2.48.2 Firefox version: 43.0.2

Answer №1

Dealing with the same issue, I found myself inundated with excessive log noise regarding CSS, security, and network matters, but lacking the actual logs generated by the application using console.log. Despite using identical versions of WebDriver and Firefox as you, this issue did not present itself with other browsers.

To address this, I took it upon myself to enhance my client code with a custom log recording solution. In terms of wire protocol communication:

  • Utilize execute to incorporate the following script into the client:
window.recordedLogs = [];

console.log = function (message) {

    if (typeof message === 'object') {
        message = JSON.stringify(message);
    }

    window.recordedLogs.push(message);
};
  • Use execute to retrieve window.recordedLogs

Caution: The provided code is rudimentary and does not account for handling multiple messages passed to the log method or other logging functions such as info, error, etc.

Nevertheless, it serves as a viable cross-browser alternative to the wire protocol's log method.

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

Using canvas transformation changes the way drawImage is applied

I have been working on a game as a hobby and you can find it at . I have managed to get most aspects of the game working well, such as transformation, selection, movement, and objects. However, there is one particular challenge that I am struggling with. ...

What could be the reason behind the absence of the definition for "console" in an inline function responsible for handling an event from a component?

A component called my-component was created by me, which sends the message my-message using this.$emit('my-message'). To respond to this message, I attempted to utilize <my-component @my-message="()=>console.log('hello')&quo ...

Javascript Library Issue: "Implicitly Declared Type 'Any' Error"

I am currently in the process of developing a JavaScript library that will interact with an API. My goal is to create a module that can be easily published on npm and utilized across various frameworks such as Angular or React. Below is the code snippet fo ...

Using a PHP array as a parameter in a link for an AJAX function

I am attempting to pass a PHP array to an AJAX function in order to populate dynamically created tables. To achieve this, I need to pass the values in an array all at once to avoid the issue where only the last dynamic table is populated. However, it see ...

"Embrace the power of Ajax and JSON with no regrets

function register() { hideshow('loading', 1); //error(0); $.ajax({ type: 'POST', dataType: 'json', url: 'submit.php', data: $('#regForm').serialize(), su ...

How to add a subtle entrance animation to text (demonstration provided)

Apologies for the brevity, but I could really use some assistance with replicating an effect showcased on this particular website: My understanding is that a "fadeIn" can be achieved using jQuery, however, I am at a loss as to how to implement the 3D effe ...

Implement a T3 App Redirect in a TRPC middleware for unsigned users

Is there a way to implement a server-side redirect if a user who is signed in has not finished filling out their profile page? const enforceUserIsAuthed = t.middleware(({ ctx, next }) => { if (!ctx.session || !ctx.session.user) { throw new TRPCE ...

Function that activates traffic lights

Currently, I'm encountering errors while working on this project in Notepad. Can you help me figure out what's wrong with my code? I'm attempting to create an onload traffic light using an object array. The requirement is to implement this f ...

Peruse a spreadsheet for relevant information

I am currently facing an issue with a search bar that I implemented to filter through a table. However, for some reason, the filtering function does not seem to work on the tbody section of the table. The content in the tbody is generated dynamically usi ...

Tips for eliminating the menu bar in the external window generated by an Electron application's URL

Looking for a solution to remove the menu bar from a window that opens with an external URL in an Electron application? Check out the code snippet below: windowObject.webContents.setWindowOpenHandler(() => ({ action: 'allow', overrideBrows ...

Implementing property filtering on a recursive self-reference with Jackson

Consider the scenario where I need to serialize a class using Jackson. public class Product { int id; String name; List<Product> similarProducts; } How can I achieve the desired JSON output like this? { "id": 1, "name": "Produc ...

Updating style of element in EJS following POST request in Node.js using Express

I am working on a form page that is supposed to display a Success Alert (Boostrap) once the user fills out the form and clicks the Submit button. <form class="well form-horizontal" action="/contact" method="post" id="contact_form"> ... (input fiel ...

JavaScript JQuery alert popup fails to display

I have been attempting to create an alert pop-up using JQuery that will display when a user clicks on submit without filling out the form. However, when I test my code by leaving the form empty and clicking 'submit', the page just refreshes with ...

CSS and JavaScript dropdown malfunctioning due to a position swap in internal CSS

This example demonstrates functionality .c1 { background-color:red; position:relative; } .c2 { background-color:blue; position:absolute; height:50px; width:100px; display:none;} .show { display:block; } <body> <button ...

selenium problem: having trouble choosing an option from a dropdown menu when using thymeleaf

I am currently experiencing a dilemma when trying to select a value from a dropdown during a selenium test. I am retrieving my values from a properties file using thymeleaf in the following manner: <option th:each="medication : ${medications}" ...

Matching with Regex beyond the limits

Trying to extract a body tag using regex and then replace it with an appended string. However, encountering an issue where the regex is selecting more content than intended. regex: /<body.*[^>]>/i test string: <bla bla ><body class=&apo ...

I am unable to generate png maps using folium with the combination of selenium and firefox

I have been attempting to export a map that I created using folium in Python to a png file. I came across a post suggesting that this can be achieved by using selenium with the following code snippet: Export a folium map as a png import io from PIL import ...

Is there a method to retrieve the subdirectories and files currently present on a given URL?

Picture having a file on your system with the following URL: I am curious if there is any software, command, or script that can retrieve subfolders/files based on a given URL. For instance: Input parameter: http://my.page/folder_1/ Output: http://my.p ...

Encountering a User Agent error while trying to update Vue to the latest version using N

I was interested in experimenting with staging.vuejs. When I tried to install it using the command npm init vue@latest, I encountered an error. Here is the link for reference: https://i.stack.imgur.com/rCipP.png SPEC Node : v12.13.0 @vue/cli : v4.5.15 ...

Utilizing an Office App Ajax that includes an authentication header, the application connects to a secure Web API 2 backend with CORS

I am currently in the process of developing a content panel application for Office. As part of this project, I need to authenticate an account against a server. To accomplish this, I have implemented my own AuthorizationFilterAttribute on my web api 2 con ...