Ошибка установки Selnium Сервер Python Debian 9 - PullRequest
0 голосов
/ 10 июня 2019

Я пытаюсь научиться работать с Интернетом с селеном, но продолжаю получать ошибки с простым кодом и настройкой. Я следовал многим инструкциям, но, похоже, все еще получаю те же ошибки на сервере растяжения Debian 9.7

НАСТРОЙКА ХРОМА:

CHROME:

            sudo apt-get install python-pip
            sudo pip install selenium

            LATEST=$(wget -q -O - http://chromedriver.storage.googleapis.com/LATEST_RELEASE)
            wget http://chromedriver.storage.googleapis.com/$LATEST/chromedriver_linux64.zip
            unzip chromedriver_linux64.zip && sudo ln -s $PWD/chromedriver /usr/local/bin/chromedriver
            export PATH=$PATH:/usr/local/bin/

SCRIPT:

            #!/usr/bin/env python
            from selenium import webdriver

            browser = webdriver.Chrome()
            browser.get('http://www.ubuntu.com/')

Ошибка:

            python3 testchrome.py
            Traceback (most recent call last):
              File "testchrome.py", line 4, in <module>
                browser = webdriver.Chrome()
              File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
                self.service.start()
              File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 98, in start
                self.assert_process_still_running()
              File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/common/service.py", line 111, in assert_process_still_running
                % (self.path, return_code)
            selenium.common.exceptions.WebDriverException: Message: Service chromedriver unexpectedly exited. Status code was: 127

(также пробовал с python2.7)

УСТАНОВКА ДЛЯ ПОЖАРОТОКСА:

FIREFOX:

            wget https://github.com/mozilla/geckodriver/releases/download/v0.11.1/geckodriver-v0.11.1-linux64.tar.gz
            tar -xvzf geckodriver-v0.11.1-linux64.tar.gz
            rm geckodriver-v0.11.1-linux64.tar.gz
            chmod +x geckodriver
            cp geckodriver /usr/local/bin/
            export PATH=$PATH:/usr/local/bin/

SCRIPT:

            #!/usr/bin/env python

            from selenium import webdriver

            browser = webdriver.Firefox()
            browser.get('http://www.ubuntu.com/')

Ошибка:

            python3 test.py 
            Traceback (most recent call last):
              File "test.py", line 5, in <module>
                browser = webdriver.Firefox()
              File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/firefox/webdriver.py", line 174, in __init__
                keep_alive=True)
              File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
                self.start_session(capabilities, browser_profile)
              File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
                response = self.execute(Command.NEW_SESSION, parameters)
              File "/usr/local/lib/python3.5/dist-packages/selenium/webdriver/remote/webdriver.py", line 321, 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: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line

Я попытался установить firefox-esr с помощью apt -y install firefox-esr, но с той же ошибкой.

Любая помощь приветствуется, так как я хотел бы перейти к созданию кода. Спасибо

...