Forums

Headless Chrome Selenium

Hello, i see that is possible to ask for enabling the use of headless chrome. Is it possible to have it enabled? many thanks

Sure! I've enabled the new feature; the next step is for you to upgrade Selenium for your account -- for example, if you're using Python 3.7, run this in Bash:

pip3.7 install --user --upgrade selenium

...and then you can run Selenium with Chrome using code like this:

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
browser = webdriver.Chrome(options=chrome_options)

try:
    browser.get("https://www.google.com")
    return "Page title was '{}'".format(browser.title)

finally:
    browser.quit()

many thanks! i am running it in a pipenv virtual enviroment how am i supposed to update selenium?

sorry, upgrade

I don't use pipenv myself, but for a normal virtualenv you would just activate it then run pip install --upgrade selenium

Hello, Could you please enable headless chrome for my account as well. Thank you

No problem. I have enabled it for your account.

Amazing, Thank you.

No problem :-)

Hi! Could you please enable headless Chrome for my account too. Thanks!

You have already new virtualization system enabled for your account. To use headless Chrome follow the steps mentioned above.

Can you please tell me what Chrome version is installed on my account? I don't know what chromedriver version I need to use.

The chrome and chromedriver that are already installed work together. You do not need to get a different chromedriver version.

I tried to run the code above but I got this two errors:

[Errno 2] No such file or directory: 'chromedriver': 'chromedriver'

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

Right, it appears that your system image has to be upgraded. One word of warning first -- because changing the system image upgrades a lot of the pre-installed Python packages, any code that you have that relies on those packages might break if it's not compatible with the new versions. Also, because the new image has newer versions of Python, if you have any virtualenvs, you may need to rebuild them. If you're happy to go ahead despite that, just let us know and we'll switch you over.

Yes, switch it on please.

OK, it's done. You're on the most recent system image now.

It works now, thank you very much!

Excellent, thanks for confirming!

Could I also this get enabled on my account? Running the code provided above (after including "from selenium import webdriver") produces the following exception:

selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally

No problem. It's done for you.