0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

selenium で firefox on ubuntu

Posted at

snap でインストールされている ubuntu の firefox

今週書いた記事でも言及しましたが snap でインストールされていると、Profileの場所も違うのですが、そもそも TMPDIRの設定が selenium/geckodriver で食い違ってくるということが判明したので書いておきます。

profileが作れない??

Selenium は 自動化ということもあり、通常はゲストに準じた起動状態です。個人のアカウントに紐付けるような設定は出来るのですが、認証テストに失敗しすぎてaka-BAN状態にされると個人的には苦労しますので、テストアカウントを作るくらいなら「匿名ログイン」即時profileによるテストになります。

Profile_missing.png

TMPDIR を設定・定義しよう

で解決するようです。

geckodriver.png

ProfileManager なしにはやっぱり動かない・・・

import tempfile
from selenium import webdriver

# Set the path to the GeckoDriver executable
custom_gecko_path = '/snap/bin/geckodriver'

# Set the path using the executable_path argument in FirefoxOptions
custom_profile_path = tempfile.mkdtemp(prefix="selenium_custom_profile_")

いろいろ動かないというので、上のようなサンプルコードを探してきましたが、

selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable
  • snap での PATH は定義すればいい。
firefox_bin = "/snap/firefox/current/usr/lib/firefox/firefox"
firefoxdriver_bin = "/snap/firefox/current/usr/lib/firefox/geckodriver"

from: https://github.com/SeleniumHQ/selenium/issues/13252#issuecomment-1845021270

本日のハンティング終了

  • これ以外の定形業務は適当にこなれて・・・
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?