[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Using IceCat/geckodriver with Selenium (Python)
From: |
Luis Felipe |
Subject: |
Re: Using IceCat/geckodriver with Selenium (Python) |
Date: |
Fri, 05 Nov 2021 22:19:33 +0000 |
Hi, Maxim :)
On Friday, November 5th, 2021 at 6:48 PM, Maxim Cournoyer
<maxim.cournoyer@gmail.com> wrote:
> 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.
Thanks, good to know about the options and that geckodriver is there now.
> If you use chromedriver (included with) our ungoogled-chromium instead,
>
> it is more straightforward as there is nothing to rename/monkey patch:
Yeah, this one just works.
publickey - luis.felipe.la@protonmail.com - 0x12DE1598.asc
Description: application/pgp-keys
signature.asc
Description: OpenPGP digital signature