1

I am running Selenium python on server where I need to hide chrome display. Python script runs most of time but sometimes it stucks when it creates new chromedriver session. Don't have any idea why it stucks sometimes.

Snippet Code:

from selenium import webdriver
from pyvirtualdisplay import Display

chromedriver = '/usr/local/bin/chromedriver'
os.environ['webdriver.chrome.driver'] = chromedriver
display = Display(visible=0, size=(800,600))
display.start()


driver = webdriver.Chrome("/usr/local/bin/chromedriver")  => Stuck here 
driver.get("example.com")
iNikkz
  • 3,729
  • 5
  • 29
  • 59

1 Answers1

1

I just currently set up Selenium on my server. If you get your permission right, try to put this line.

options = webdriver.ChromeOptions()
options.add_argument("--no-sandbox")
driver = webdriver.Chrome(desired_capabilities=options.to_capabilities())

to turn off the sandbox.

Joey Jiao
  • 91
  • 2
  • 10