Eu instalei o driver firefox no Ubuntu 16.04.3 LTS e ele está instalado em
$ which firefox
/usr/bin/firefox
Estou usando o seguinte script python simples para testar o selênio
#!/usr/bin/env python
from pyvirtualdisplay import Display
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
display = Display(visible=0, size=(1024, 768))
display.start()
#binary = FirefoxBinary('/usr/bin/firefox')
browser = webdriver.Firefox()
browser.get('http://www.ubuntu.com/')
print(browser.page_source)
browser.close()
display.stop()
Estou recebendo os seguintes erros:
File "tests.py", line 16, in <module>
browser = webdriver.Firefox()
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 162, in __init__
keep_alive=True)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 1
Informações completas sobre a versão:
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
Este é um problema de 100% do sistema operacional porque em outros sistemas operacionais como o Windows e o macOS eu testei e o código funciona. Qualquer ajuda será apreciada.
Qual leitura do encadeamento duplicado sugerido, desde que uma das soluções foi procurar geckodriver.log
. Meu geckodriver.log
afirmou
1524778083599 geckodriver INFO geckodriver 0.20.1
1524778083603 geckodriver INFO Listening on 127.0.0.1:58448
1524778084607 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.xBi1jOarZ06h"
Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Na linha de comando, eu exportei a tela como
$ export DISPLAY=:0
Após a exportação, geckodriver.log está dizendo
1524778146749 geckodriver INFO geckodriver 0.20.1
1524778146753 geckodriver INFO Listening on 127.0.0.1:55524
1524778147756 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-profile" "/tmp/rust_mozprofile.nWOzb0ngG3gm"
Mas agora estou recebendo o seguinte erro na linha de comando
Traceback (most recent call last):
File "tests.py", line 16, in <module>
browser = webdriver.Firefox()
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 162, in __init__
keep_alive=True)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 154, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 243, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: Failed to start browser /usr/bin/firefox: other os error