The removal of all cookies using `driver.manage().deleteAllCookies()` with Selenium does not function properly in conjunction with browser options

There seems to be an issue with the browser Options in Selenium where

driver.manage().deleteAllCookies()
is not working as expected. Here is a snippet of the code showcasing this problem.

var profile = new firefox.Profile('./fProfile');
profile.setPreference("browser.privatebrowsing.autostart",true);
var fOptions = new firefox.Options();
fOptions.setProfile(profile); 

var driver = new Builder()
    .withCapabilities({'browserName': 'firefox'})
    .setFirefoxOptions(fOptions)    
    .build();
driver.get("https://google.com");

In the above setup, both

driver.manage().deleteAllCookies()
and
driver.manage().getCookies().then((cookies)=>{console.log(cookies)})
return unexpected results, with the latter returning an empty array.

It's interesting to note that when using a simpler driver creation method, such as:

driver= new Builder()
    .withCapabilities({'browserName': 'firefox'})    
    .build();

Everything seems to work fine. However, this approach cannot be used in my case as I must utilize a Firefox profile.

Platform: Node.Js Selenium utilizing geckodriver

Answer №1

Instead of focusing on finding a solution, consider working in reverse.

You have identified that removing .setFirefoxOptions(fOptions) resolves the issue, but there are alternative approaches such as manually configuring preferences or using a pre-set profile.

  • Experiment with a fresh profile to observe the outcome.
  • Disable private browsing mode and observe the results.

By narrowing down the source of the problem, you position yourself to receive more accurate guidance.

Answer №2

It seems that disabling private browsing solved the issue. Another solution is to simply remove the line causing the problem.

profile.setPreference("browser.privatebrowsing.autostart",false);

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

Why isn't JMeter's JUnit request sampler wait conditions functioning as expected?

Hello, I am currently working on conducting JUnit load tests with JMeter. My approach involves using Selenium WebDriver and executing it with Selenium JUnit testing. The code runs smoothly when tested with JUnit on Selenium WebDriver. However, when attempt ...

having issues uploading files to mongodb using GridFsStorage

File Storage Configuration const mongoose = require('mongoose'); const multer = require('multer') const {GridFsStorage} = require('multer-gridfs-storage') const Grid = require('gridfs-stream'); const path = require(& ...

Leveraging passport and OAuth in conjunction with connect-redis

I am facing a challenge with implementing passport-twitter and passport-facebook for authentication in an app that utilizes Redis for Express sessions. When I remove connect-redis to store sessions in express, everything runs smoothly. However, when using ...

Using Express4 in Node.js, what is the easiest way to retrieve the request body?

Recently, express made changes and no longer includes middleware that automatically populates the req.body variable. I am struggling to find a solution to fill req.body once again. I have a POST request going to /xyz/:object/feedback. Here is my code: ap ...

Hiding screenshot using display:none in Extent Reports

I have integrated the AventStack Extent Report library version 4.1.5 into my project and configured the after method as follows: <!-- https://mvnrepository.com/artifact/com.aventstack/extentreports --> <dependency> <groupId> ...

Navigating to the item's webpage is a crucial task and can be easily accomplished by extracting the

How can I extract a URL from a webpage using "find_element_by_css_selector"? The item I want contains a URL. However, when I try to extract it, I am getting "None" as output even though there are similar items on the page with the attribute 'div.col-l ...

Accessing my Next JS /api endpoint through getStaticProps will not create a cookie

When fetching data from a remote API, I utilize a JS Web Token for access. In my getStaticProps function, I make a call to my local /api endpoint where I check if there is a cookie already set with the last valid token. If not, I fetch a fresh token from t ...

What could be the reason that images are not being loaded when using

Why are the images not loading in res.sendFile? Below is the server.js file along with the red.html file. Strangely, when I load the red.html file on its own, the picture displays correctly. server.js var express = require('express'); var app = ...

Python: Issue with defining global variable

I'm attempting to execute the following code: import unittest import wd.parallel from selenium import webdriver from selenium.webdriver.support.ui import WebDriverWait from selenium.common.exceptions import WebDriverException import copy class Selen ...

Leveraging Datalabels and ChartJS in combination with Chartjs-node-canvas

Using NodeJS in conjunction with ChartJS, I am able to render graphs directly to a file successfully. This is achieved by installing the npm module ChartjsNodeCanvas. To display labels on the graph, I utilize the official ChartJS plugin ChartJS-plugin-da ...

Specflow tests failing to start

I've encountered an error while trying to execute my Specflow tests. Despite various attempts like deleting the bin, removing all NuGet packages and reinstalling them, and making changes to the app.config file, this error continues to persist. Test N ...

Although XPath is displaying all elements in the selector hub from the expected div, Selenium is not able to capture them fully

I am looking to extract all the headers from a table using Selenium. I am utilizing XPath to locate the web element. Here is the XPath: "//div[@class='dataTables_scrollHeadInner']//tr[@id='report-data-table-header-0']/th" Whe ...

The element within the iframe is elusive to Selenium

Having trouble locating the element beneath an iframe even after switching to the frame. see screenshot here The HTML code can be found at: http://pastebin.com/AShYrdxQ ...

Swipe down to view all the links

Out of 3821 links, only 103 were provided to me. I tried applying the condition `window.scroll` to retrieve all the links, but unfortunately, it did not work as expected. from selenium.webdriver.common.by import By from selenium.webdriver.common. ...

Am I using Node.js, Express, and Promises correctly in my code?

In my Express route, I initially encountered an issue where input data passed through 3 different functions was being queued and returned one at a time. After some testing, I discovered this bottleneck and decided to refactor my code. I modified the functi ...

What could be causing the "module not found" error even after ensuring multiple times that the module is present?

Currently, I am attempting to perform a Google search programmatically using the node module google-search-results-nodejs. Despite my efforts, I continuously encounter the error "not found." My development environment is Gitpod's online workspace, and ...

How to incorporate a routing file within another routing file in Node.js

I have structured my routes as follows: / /business /business/stuff1 /business/stuff2 /business/admin For /business, I am using a separate file for the routing and functions. And similarly, for /business/admin, I also want to use a separate file f ...

Is there a way to combine multiple incoming WebRTC audio streams into one cohesive stream on a server?

I am currently working on developing an audio-conferencing application for the web that utilizes a WebSocket server to facilitate connections between users and enables streaming of audio. However, I am looking to enhance the system by transforming the serv ...

Scripts in iframes within webviews are not preloading and executing properly

When using the <webview> tag in the renderer process within the <body> of a web page, the following code is used: <webview src="http://somewebpage.com" preload="somescript.js"> The script somescript.js will be execute ...

The issue at hand is a 'Pro.find' function error that is occurring within the mongoose

In my server.js file, I have the code to start my server on localhost:7000 and I am using the product.js route: Product Route: const express = require('express'); const router = express.Router(); const Product = require('../model/Product& ...