Я пытаюсь использовать/usr/bin/firefox, но я продолжаю получать ошибку, пытаясь установить SnapPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Я пытаюсь использовать/usr/bin/firefox, но я продолжаю получать ошибку, пытаясь установить Snap

Сообщение Anonymous »

Написание сценария с использованием селена для открытия URL: < /p>
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.firefox.service import Service as FirefoxService
from selenium.webdriver.firefox.options import Options as FirefoxOptions
import json

# create a Firefox service and options object
firefox_service = FirefoxService(executable_path='/usr/local/bin/geckodriver')
firefox_options = FirefoxOptions()

# set the binary location for Firefox
firefox_options.binary_location = '/usr/bin/firefox'

# enable network logging
firefox_options.set_preference("devtools.netmonitor.har.enableAutoExportToFile", True)
firefox_options.set_preference("devtools.netmonitor.har.autoConnect", True)
firefox_options.set_preference("devtools.netmonitor.har.forceExport", True)
firefox_options.set_preference("devtools.netmonitor.har.fileName", "network_logs")

# create a Firefox driver instance with the specified service and options
driver = webdriver.Firefox(service=firefox_service, options=firefox_options)

# navigate to the lambdatest website
driver.get("https://www.lambdatest.com/")

# find the header navigation elements and click on each one
header_nav_elements = driver.find_elements_by_css_selector('.navbar-nav .nav-link')
for element in header_nav_elements:
element.click()

# wait for 5 seconds
driver.implicitly_wait(5)

# close the browser window and quit the driver
driver.close()
driver.quit()

# read the network logs from the HAR file
with open('network_logs.har', 'r') as f:
network_logs = json.load(f)

# print the network logs
print(json.dumps(network_logs, indent=2))
< /code>
Но когда я запускаю его, я получаю ошибку: < /p>
Traceback (most recent call last):
File "/mnt/c/Users/HP/Desktop/Newstuff/Lambdatest/main.py", line 21, in
driver = webdriver.Firefox(service=firefox_service, options=firefox_options)
File "/home/riley/.local/lib/python3.10/site-packages/selenium/webdriver/firefox/webdriver.py", line 199, in __init__
super().__init__(command_executor=executor, options=options, keep_alive=True)
File "/home/riley/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 286, in __init__
self.start_session(capabilities, browser_profile)
File "/home/riley/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 378, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/home/riley/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py", line 440, in execute
self.error_handler.check_response(response)
File "/home/riley/.local/lib/python3.10/site-packages/selenium/webdriver/remote/errorhandler.py", line 245, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: binary is not a Firefox executable

Я пытался использовать/usr/bin/firefox , чтобы проверить, смогу ли я открыть Firefox с этой командой, но я получил
Command '/usr/bin/firefox' requires the firefox snap to be installed.
Please install it with:

snap install firefox

И когда я попробую Snap установить Firefox Я получаю
snap install firefox
error: cannot communicate with server: Post "http://localhost/v2/snaps/firefox": dial unix /run/snapd.socket: connect: no such file or directory


Подробнее здесь: https://stackoverflow.com/questions/759 ... to-install
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»