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

When utilizing an object as state in React, the `setState` function will only set

Currently, I am working on developing a React form that utilizes a custom Input component which I have created multiple times. The objective is to gather all the names and values from the form in the parent component: {inputName: value, inputName2: valu ...

Discover the best method for extracting server error pages with selenium Web driver

Encountered a problem handling server errors with Selenium Web Driver. The webpage crashed while transitioning from one page to another, causing the code I wrote to fetch Web Elements to become unresponsive. //Function Call by passing the arguments comm ...

Utilizing <Cucumber-JVM>, sharing data between steps within cucumber

How can I transfer values between two steps in cucumber JVM? In this particular scenario, I need to retrieve the username entered in the When step for use in the Then step. Currently, I am achieving this by storing the value in a public variable. Is this ...

Adjusting the width of the rail in Material UI's vertical Slider component in React

After attempting to adjust the width and height of the rail property on the material ui slider I obtained from their website demo, I have encountered an issue with changing the thickness. import React from "react"; import { withStyles, makeStyles } from " ...

Adjust the column count in mat-grid-list upon the initial loading of the component

My goal is to implement a mat-grid-list of images with a dynamic number of columns based on the screen size. Everything works perfectly except for one small glitch – when the grid first loads, it defaults to 3 columns regardless of the screen size until ...

Encountering the issue of "unable to retrieve" when attempting to create an API in Express.js

I am currently developing a REST API using express js, but I encountered an issue with the error message "Cannot GET /api/bears". Here is my code snippet: server.js var express = require('express'); var app = express(); var bodyParser = require ...

Using ReactJS to trigger a timer function on a button click

Kindly Note: This is a unique query and not related to ReactJS - Need to click twice to set State and run function. The suggested solution there does not resolve my issue. This represents my original state: constructor(props) { super(props) this. ...

Utilize jQuery/AJAX to extract a specific value from JSON data and transform it into a different value within the same

Hello everyone, I've been coding all day to try and solve this issue but my code doesn't seem to be working. Can anyone help me with this problem? I'm trying to convert selected JSON data into a different value. Let's take an example: ...

The React application is experiencing difficulty in rendering SVG images exclusively on Windows operating systems

My react app runs smoothly on OSX, but encounters issues on Windows due to SVG files: Module parse failed: Unexpected token (2:0) You may need an appropriate loader to handle this file type. <svg xmlns="http://www.w3.org/2000/svg" viewBox="..."> I ...

Is Local Storage compatible with phonegap?

I am looking to integrate local storage into my phonegap application in order to store an array of data. Here is a snippet of my code: <div data-role="collapsibleset"> <div data-role="collapsible"> <h3>LOG ...

The best practices for coding Jquery plugins to adhere to style guidelines

I have been grappling with this issue for quite some time now, and I am seeking feedback from others. I am in the process of creating a personalized library to expedite web app development, and I want to ensure that I adopt the correct approach. My intenti ...

Java Stream is experiencing significant latency in disk read operations

I am currently working on a project that involves reading images from a folder and generating checksums for them. The folder contains approximately 330760 images. Below is the code snippet I have been using: package com.test; import java.io.FileInputStr ...

Rendering an Angular page with data using Node.js

I have a scenario for my website where users need to input a URL with a parameter (an ID) and receive back the corresponding page containing information from the database. I am using Angular4 but I am unsure of how to achieve this. It's straightforwa ...

Output is not being displayed by Ajax

I created a basic PHP code that populates rows and columns with an asterisk (*). To test the PHP code, I entered the URL localhost/squareService.php?rows=3&cols=3 However, when I asked a user to input the number of rows and columns using HTML and Java ...

What could be causing an error in a scroll handler when using React's setState function?

Upon reaching the bottom of the page and scrolling back up, an error is thrown by React stating "TypeError: _this.setState is not a function" The scroll handler in question monitors the position of the client on the page. If the client is within the home ...

JavaScript: Developing an interactive Word Guessing Game

Here's some sample code: let ccdisplay = document.querySelector('.crrDisplay'); let incdisplay = document.querySelector('.incDisplay'); let guess = document.querySelector('#character'); let textForm = document.q ...

Analyzing values passed from Java using PHP

Currently, I am in the process of working on two PHP files: login.php and DB_Functions.php. Within these files, there is a particular script that receives a password and email from the application. It then locates the specific user using the provided emai ...

How can I turn off a state property?

My goal is to detect if the user is using a device with a screen width smaller than 768px, and if they are, I want to set isTop to false. However, I am encountering some difficulties. Everything seems fine, but I keep receiving this error: TypeError: _t ...

What is the best way to input information into my Google spreadsheet with React JS?

After using https://github.com/ruucm/react-google-sheets as a reference, I encountered a persistent gapi 404 error whenever I tried to run the code. It seems like the GitHub link might not exist, causing my app to fail. However, I could be mistaken. Is t ...

How can you utilize the Array submission syntax within HTML coding?

I currently have numerous input fields within a form, and some of them are structured like this: <input name="agents[]" type="file" /> Additionally, imagine there is a plus button next to this field as shown below: <img src="plus.jpg" id="some_ ...