question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if youā€™re still stuck at the end, weā€™re happy to hop on a call to see how we can help out.

does not pass args capability to geckodriver

See original GitHub issue

šŸ› Bug Report

I am unable to append options to the geckodriver args capability via the desired_capabilities parameter.

To Reproduce

I am running this:

#!/usr/bin/env python

from selenium.webdriver import Firefox, DesiredCapabilities
import time

capabilities = DesiredCapabilities.FIREFOX.copy()
capabilities['args'] = ["-headless"]

print(capabilities)

webdriver = Firefox(desired_capabilities=capabilities)
webdriver.get("https://google.com")

while 1:
    time.sleep(0.1)

Expected behavior

A headless instance visiting google.com, as I gather from the docs: the -headless string being one of the members of the args array should mandate that headlessness.

Actual behavior

A visible window.

Test script or set of commands reproducing this issue

Provided above.

Environment

OS: Linux x86_64 Browser: Firefox Browser version: Mozilla Firefox 88.0.1 Browser Driver version: geckodriver 0.29.0 Language Bindings version: Pythonā€™s selenium 3.141.0 package

Additional info

I have that other types of args are not passed either. For instance, capabilities['args'] = ["-profile", "<PATH-TO-EXISTING-PROFILE>"] does not result in geckodriver using that existing profile, as suggested by the docs that it should.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
AutomatedTestercommented, May 14, 2021

@AutomatedTester Incidentally, Iā€™m aware that one can pass firefox_profile=<whatever> or options.profile=<whatever>, but this does not do wat I want: I have checked that both create copies of that profile to a temporary location. If I end the driver cleanly whatever theyā€™ve gathered is wiped out.

For instance, if I delete the cookies.sqlite from <PROFILE> and then pass firefox_profile=<PROFILE> when building the driver, it will not leave behind a cookies.sqlite file in my original profile directory.

So: what I am after is a way to use a profile persistently with geckodriver. To save my life I cannot do this.

What you are after is going against how Selenium, and Geckodriver, do things in general. Selenium originally, and then geckodriver too, copy the profile so that if you pass it in that you get the same start point as always. We found that it was a major footgun to allow things to persist indefinitely as well as being a security issue if people share these profiles around.

If you want to get the resultant profile after running your automation code I suggest you do something like

from selenium.webdriver.firefox.options import Options
from selenium import webdriver
options = Options()
options.profile = "/path/to/profile"
driver = webdriver.Firefox(options=options)
# Do whatever you want
profile = driver.firefox_profile
# copy the profile somewhere
driver.quit()

The thing youā€™re trying to do is not how Selenium/Geckodriver was designed so youā€™re going to have to try be creative here.

0reactions
stuart-littlecommented, May 14, 2021

@AutomatedTester Thank you: confirming that Selenium does not make this easy by default is at least a sanity check of sorts. I thought it was me missing some easy persistence switch.

As to being creative, yes, I figured Iā€™d have to cobble something togetherā€¦ What Iā€™ve settled on for now, since Iā€™m specifically interested in cookies, is hard-linking the temp profileā€™s cookies.sqlite file to a location of my choosing. Then, when it exits, writes the cookies to that database, releases the lock and then deletes it, I have the copy.

Anyway, I think I can work with this. Thank you very much for all the help and the time you invested in this exchange.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Selenium node does not pass the command line arguments to ...
On versions 3.5.0 and higher, Selenium node does not pass the command line arguments to geckodriver. Expected Behavior -. If the node receivesĀ ......
Read more >
How to pass command line arguments to the browser driver ...
I'm currently using protractor for some tests. Unfortunately, I can't figure out a way to pass ...
Read more >
Configuring Selenium WebDriver | Serenity BDD Users Manual
The simplest way to configure the driver you want to use is in your project's serenity.conf file (which you will find in src/test/resources...
Read more >
WebDriverManager - Boni GarcĆ­a
WebDriverManager is an open-source Java library that carries out the management (i.e., download, setup, and maintenance) of the drivers requiredĀ ...
Read more >
Getting Started | Nightwatch.js
Everything you need in order to get started with Nightwatch.js, step-by-step, with configuration guides for various browsers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found