'Problem with runnig of Firefox with Selenium on Linux

I have a next problem:

I'm using: Linux version 3.10.0--generic-shared-3.2-20160306 (gcc version 4.9.3 (Gentoo 4.9.3 p1.5, pie-0.6.4)) Before running of Python file with Selenium, i made a next steps:

  1. Create ENV and mkdir fireforx on the bin folder(.name_env/bin/firefox)

  2. Download Firefox

  • download wget -O FirefoxSetup.tar.bz2 "https://download.mozilla.org/?product=firefox-latest&os=linux64&lang=en-US"
  • unpack to '.name_env/bin/firefox' by tar jxvf FirefoxSetup.tar.bz2
  • check files on folder .name_env/bin/firefox by ls -al and saw a next result:
    drwxr-x--- 7 name customers      4096 May  3 23:55 .
    drwxr-x--- 4 name customers      4096 May  4 08:40 ..
    -rw-r----- 1 name customers       825 Apr 28 16:50 Throbber-small.gif
    -rw-r----- 1 name customers       891 Apr 28 23:14 application.ini
    drwxr-x--- 4 name customers      4096 May  3 23:55 browser
    -rwxr-x--- 1 name customers    249680 Apr 28 23:54 crashreporter
    -rw-r----- 1 name customers      3902 Apr 28 16:50 crashreporter.ini
    drwxr-x--- 3 name customers      4096 May  3 23:55 defaults
    -rw-r----- 1 name customers       174 Apr 28 23:54 dependentlibs.list
    -rwxr-x--- 1 name customers     14416 Apr 28 23:54 firefox
    -rwxr-x--- 1 name customers    757152 Apr 28 23:54 firefox-bin
    -rw-r----- 1 name customers      1449 Apr 28 23:59 firefox-bin.sig
    -rw-r----- 1 name customers      1449 Apr 28 23:59 firefox.sig
    drwxr-x--- 2 name customers      4096 May  3 23:55 fonts
    drwxr-x--- 3 name customers      4096 May  3 23:55 gmp-clearkey
    drwxr-x--- 2 name customers      4096 May  3 23:55 icons
    -rwxr-x--- 1 name customers    833912 Apr 28 23:54 libfreeblpriv3.so
    -rwxr-x--- 1 name customers    339000 Apr 28 23:54 libipcclientcerts.so
    -rwxr-x--- 1 name customers     43200 Apr 28 23:54 liblgpllibs.so
    -rwxr-x--- 1 name customers   3849656 Apr 28 23:54 libmozavcodec.so
    -rwxr-x--- 1 name customers    228136 Apr 28 23:54 libmozavutil.so
    -rwxr-x--- 1 name customers     14056 Apr 28 23:54 libmozgtk.so
    -rwxr-x--- 1 name customers    117384 Apr 28 23:54 libmozsandbox.so
    -rwxr-x--- 1 name customers   1179208 Apr 28 23:54 libmozsqlite3.so
    -rwxr-x--- 1 name customers     18224 Apr 28 23:54 libmozwayland.so
    -rwxr-x--- 1 name customers    223024 Apr 28 23:54 libnspr4.so
    -rwxr-x--- 1 name customers    711096 Apr 28 23:54 libnss3.so
    -rwxr-x--- 1 name customers    437448 Apr 28 23:54 libnssckbi.so
    -rwxr-x--- 1 name customers    187416 Apr 28 23:54 libnssutil3.so
    -rwxr-x--- 1 name customers     22656 Apr 28 23:54 libplc4.so
    -rwxr-x--- 1 name customers     14376 Apr 28 23:54 libplds4.so
    -rwxr-x--- 1 name customers    163456 Apr 28 23:54 libsmime3.so
    -rwxr-x--- 1 name customers    326088 Apr 28 23:54 libsoftokn3.so
    -rwxr-x--- 1 name customers    414344 Apr 28 23:54 libssl3.so
    -rwxr-x--- 1 name customers 148216472 Apr 28 23:54 libxul.so
    -rw-r----- 1 name customers      1449 Apr 28 23:59 libxul.so.sig
    -rwxr-x--- 1 name customers   1657584 Apr 28 23:54 minidump-analyzer
    -rw-r----- 1 name customers  30226627 Apr 29 00:00 omni.ja
    -rwxr-x--- 1 name customers    806288 Apr 28 23:54 pingsender
    -rw-r----- 1 name customers       165 Apr 28 23:54 platform.ini
    -rwxr-x--- 1 name customers    752976 Apr 28 23:54 plugin-container
    -rw-r----- 1 name customers      1449 Apr 28 23:59 plugin-container.sig
    -rw-r----- 1 name customers      2014 Apr 28 23:59 precomplete
    -rw-r----- 1 name customers         0 Apr 28 23:54 removed-files
    -rw-r----- 1 name customers       132 Apr 28 23:54 update-settings.ini
    -rwxr-x--- 1 name customers     97528 Apr 28 23:54 updater
    -rw-r----- 1 name customers       638 Apr 28 23:54 updater.ini
  1. Download Geckodriver
  • Download: wget https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz
  • Make a chmod +x geckodriver
  • Move geckodriver to folder (.name_env/bin/geckodriver_path): mv geckodriver /.name_env/bin/geckodriver_path/
  1. Install a Selenum by Pip: Selenium version = 4.1.3
  2. Run a next python script:
    from selenium.webdriver.firefox.options
    import Options as Options_FF from selenium.webdriver.firefox.service import Service as Service_FF
    import traceback
    import logging
    ###################################
    logging.basicConfig(level = logging.DEBUG)
    logging.basicConfig(format = '%(process)d-%(levelname)s-%(message)s')
    ################################################
    full_path_linux  = '/.name_env/bin/geckodriver_path'
    options_ff = Options_FF()
    options_ff.add_argument('--disable-gpu')
    options_ff.add_argument('--headless')
    service_webdriver = Service_FF(executable_path = full_path_linux + 'geckodriver')
    driver = webdriver.Firefox(service = service_webdriver, options = options_ff)
    driver.get("https://google.com")

And on the console a see this error:

Error: Traceback (most recent call last):
  File "test_driver.py", line 68, in <module>
    run_selenium()
  File "test_driver.py", line 53, in run_selenium
    driver = webdriver.Firefox(service = service_webdriver, options = options_ff)
  File "/path_to_env/.name_env/lib/python3.8/site-packages/selenium/webdriver/firefox/webdriver.py", line 176, in __init__
    self.service.start()
  File "/path_to_env/.name_env/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 98, in start
    self.assert_process_still_running()
  File "/path_to_env/.name_env/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 110, in assert_process_still_running
    raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service /path_to_env/.name_env/bin/geckodriver_path/geckodriver unexpectedly exited. Status code was: 1

So, pls could you tell me where is a problem?

Additional info: try to start a bin by ./firefox and see this problem:

XPCOMGlueLoad error for file /path_to_env/.name_env/bin/firefox/libmozgtk.so:
libgtk-3.so.0: cannot open shared object file: No such file or directory
Couldn't load XPCOM.

Why an archive does not have this file?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source