all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Using IceCat/geckodriver with Selenium (Python)
@ 2021-11-05 18:48 Maxim Cournoyer
  2021-11-05 22:19 ` Luis Felipe
  0 siblings, 1 reply; 2+ messages in thread
From: Maxim Cournoyer @ 2021-11-05 18:48 UTC (permalink / raw)
  To: help-guix

Hello,

I'm sharing this bit of knowledge as it was not obvious at all.
Selenium is hard-coded to look for 'firefox' in a couple places, even in
the serialized settings it sends to the browser instance controlled by
geckodriver.

Here's the initialization that worked using Guix on the
core-updates-frozen-batched-changes branch (where 'geckodriver' was
recently added to IceCat):

--8<---------------cut here---------------start------------->8---
from selenium.webdriver import Firefox, FirefoxOptions
# Monkey patch the KEY string for IceCat.
FirefoxOptions.KEY = "moz:icecatOptions"
options = FirefoxOptions()
options.headless = False
options.binary = 'icecat'
options.set_capability('browserName', 'icecat')
self.driver = Firefox(options=options)# TODO:
--8<---------------cut here---------------end--------------->8---

The non-obvious was monkey patching the 'moz:icecatOptions' string of
the FirefoxOptions object, and having to set the 'browserName'
capability; otherwise a capability/invalid argument execption would be
raised.

If you use chromedriver (included with) our ungoogled-chromium instead,
it is more straightforward as there is nothing to rename/monkey patch:

--8<---------------cut here---------------start------------->8---
options = ChromeOptions()
options.headless = False
self.driver = Chrome(options=options)
--8<---------------cut here---------------end--------------->8---

I hope that helps someone else :-).

Maxim


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-05 22:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-05 18:48 Using IceCat/geckodriver with Selenium (Python) Maxim Cournoyer
2021-11-05 22:19 ` Luis Felipe

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.