0

On Ubuntu 20.04 LTS server

Trying to run selenium on ANY browser in python.

Started just by running in headless mode in terminal but it complains

(environment) ubuntu@mail:~/xx/environment/bin$ firefox --headless
*** You are running in headless mode.
[GFX1-]: glxtest: libEGL initialize failed
[GFX1-]: glxtest: libEGL initialize failed
[GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt
[GFX1-]: RenderCompositorSWGL failed mapping default framebuffer, no dt

But hey i thought I'd try in python with no luck.

I've realised I probably should have Xvfb running so I've set like this

Xvfb :1 & export DISPLAY=:1

Same error as above.

Then we come to python, I'm trying to use selenium and its throwing this error

selenium.common.exceptions.WebDriverException: Message: Process unexpectedly closed with status 127

So then I've tried the xvfbwrapper (and pyvirtualdisplay) both with no luck.

with Xvfb() as xvfb:
    # launch stuff inside virtual display here.
    # It starts/stops in this code block.

    # display = Display(visible=0, size=(800, 600))
    # display.start()
    options = Options()
    # options.headless = True        #### SAME ERROR IF THIS IS ON OR NOT
    options.add_argument("--width=1200")
    options.add_argument("--height=630")
    options.binary_location = r'/usr/bin/firefox'


    driver = webdriver.Firefox(options=options, executable_path="/usr/bin/geckodriver")

    url = urllib.parse.unquote_plus(encoded_url)

    driver.get(url if "http" in url else "https://" + url)

still same error 127

(I've tried similar with chrome and its got an error also)

I think there must be something wrong with my config on the server but I'm at a point where I want to throw it out the window, please google is so light on details for this error. If any one can shed some light would be appreciated.

Lewis Morris
  • 1,916
  • 2
  • 28
  • 39
  • If chrome would be ok, try suggestions at https://stackoverflow.com/questions/49323099/webdriverexception-message-service-chromedriver-unexpectedly-exited-status-co – Jeremy Kahan Jun 24 '21 at 21:12

1 Answers1

0

well, try running without virtual display and use these if you want to use chrome

options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('window-size=1920x1080')
options.add_argument("disable-gpu")

alternatively you can place your browser out of the view

options.add_argument("--window-position=-32000,-32000")
CatChMeIfUCan
  • 569
  • 1
  • 7
  • 26