0

I knew and it is working fine also with headless mode on linux(python+selenium), for headless mode

        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument('--headless')
        chrome_options.add_argument('--no-sandbox')
        browser = webdriver.Chrome(webdriver_manager.chrome.ChromeDriverManager().install(),
                                   chrome_options=chrome_options)

My requirement: Want to run selenium/python script without headless chrome mode(i.e. non-headless) But when i comment or remove line (--headless),

        chrome_options = webdriver.ChromeOptions()
        #chrome_options.add_argument('--headless')
        chrome_options.add_argument('--no-sandbox')
        browser = webdriver.Chrome(webdriver_manager.chrome.ChromeDriverManager().install(),
                                   chrome_options=chrome_options)

or even (--no-headless)

        chrome_options = webdriver.ChromeOptions()
        chrome_options.add_argument('--no-sandbox')
        browser = webdriver.Chrome(webdriver_manager.chrome.ChromeDriverManager().install(),
                                   chrome_options=chrome_options)

it gave me error with above (non-headless) change while running python script,

Looking for [chromedriver 84.0.4147.30 linux64] driver in cache
File found in cache by path [/***/drivers/chromedriver/84.0.4147.30/linux64/chromedriver]
Error in UI Test: local variable 'browser' referenced before assignment

Can someone help me to achieve this requirement, if possible in linux?

Vinod
  • 1,234
  • 3
  • 21
  • 37

1 Answers1

1

If you aren't using --headless, ideally you should remove the following argument as well:

chrome_options.add_argument('--no-sandbox')
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • thanks for help but after commenting above line gave error, "Error while testing user interface: Message: unknown error: Chrome failed to start: exited abnormally. (unknown error: DevToolsActivePort file doesn't exist)" (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.) – Vinod Jul 28 '20 at 14:14
  • @Vinod This is the actual error `The process started from chrome location /usr/bin/google-chrome is no longer running`which you need to address. See: [Selenium: WebDriverException:Chrome failed to start: crashed as google-chrome is no longer running so ChromeDriver is assuming that Chrome has crashed](https://stackoverflow.com/questions/53073411/selenium-webdriverexceptionchrome-failed-to-start-crashed-as-google-chrome-is/53078276#53078276) – undetected Selenium Jul 28 '20 at 16:44