Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't work out how to get a geckodriver trace in Python #816

Closed
1 task done
djowett opened this issue Jul 10, 2017 · 5 comments
Closed
1 task done

Can't work out how to get a geckodriver trace in Python #816

djowett opened this issue Jul 10, 2017 · 5 comments
Labels

Comments

@djowett
Copy link

djowett commented Jul 10, 2017

In order to help us efficiently investigate your issue, please provide the following information:

Platform and application details

  • Platform: Ubuntu 16.04
  • Firefox: 54.0
  • Selenium: 3.4.3

Steps to reproduce

This works prefectly until I try to add a firefox_options parameter as below:

import os.path

from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from easyprocess import EasyProcessCheckInstalledError
from pyvirtualdisplay import Display
from selenium import webdriver
from selenium.common.exceptions import WebDriverException
from selenium.webdriver.firefox.options import Log, Options


class SeleniumTestCase(StaticLiveServerTestCase):

	def setUp(self):
		# setUp is where you instantiate the selenium webdriver and load the browser.
		try:
			self.display = Display(visible=0, size=self.virtualscreensize)
			self.display.start()
		except EasyProcessCheckInstalledError:
			print "xfvb not installed ... continuing assuming physical display available"
			self.display = None

		log_file = os.path.expanduser('~/geckodriver.log')
                    
		options = Options()
		log = Log()
		log.level = 'trace'
		options.set_preference("log", log)

		self.selenium = webdriver.Firefox(log_path=log_file, firefox_options=options)
  • A trace level log:
    This is what I can't produce!
@andreastt
Copy link
Contributor

You’re setting the log level as preference, not a capability. In any case, please raise this issue with the maintainers of the Selenium Python client.

@whimboo
Copy link
Collaborator

whimboo commented Jul 17, 2017

Capabilities in the Python binding are getting set via:

        capabilities = DesiredCapabilities.FIREFOX.copy()
        capabilities["moz:firefoxOptions"] = {
            "log": {
                "level": "trace",
            },
        }
        self.driver = webdriver.Firefox(capabilities=capabilities)

@djowett
Copy link
Author

djowett commented Jul 18, 2017

Thanks @whimboo, that's very helpful. I found that the below also worked, but went with your suggestion in the end (the to_capabilities() method doesn't add much it seems)

        capabilities = DesiredCapabilities.FIREFOX.copy()
        log = Log()
        log.level = 'trace'
        capabilities['moz:firefoxOptions'] = log.to_capabilities()

        self.selenium = webdriver.Firefox(log_path=self.log_file, capabilities=capabilities)

@davehunt
Copy link
Member

FWIW another approach is to use the Options class, which can be passed independently from capabilties. You shouldn't need to hard-code the moz:firefoxOptions key:

from selenium.webdriver import Firefox
from selenium.webdriver.firefox.options import Options

options = Options()
options.log.level = 'trace'
selenium = Firefox(firefox_options=options)

@lock
Copy link

lock bot commented Aug 17, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. If you have run into an issue you think is related, please open a new issue.

@lock lock bot locked and limited conversation to collaborators Aug 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants