I am trying to use headless web browser(such as headless chrome) for our selenium tests.Should I have to use selenium WebDriver(for python or c# bindings)?
2 Answers
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import os
Before we set up a Chrome web driver instance, we have to create an Options object that allows us to specify how exactly we want to launch Chrome. Let’s tell it that we want the browser to launch headless and that the window size should be set to 1920x1080. We also need ChromeDriver to be able to run Chrome at all
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--window-size=1920x1080")
# download the chrome driver from https://sites.google.com/a/chromium.org/chromedriver/downloads and put it in the
# current directory
chrome_driver = os.getcwd() +"\\chromedriver.exe"
driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=chrome_driver)
driver.get("https://www.google.com")

- 297
- 2
- 16
Headless Chrome
As per Getting Started with Headless Chrome
the Headless Chrome
is the server environment where you don't need a visible UI shell.
If you've got Chrome 59+ installed, you start Chrome with the --headless
flag as follows:
chrome \
--headless \ # Runs Chrome in headless mode.
--disable-gpu \ # Temporarily needed if running on Windows.
chrome
should always point to your installation of Chrome
. The exact location of-coarse varies from platform to platform.
ChromeDriver
As per ChromeDriver - WebDriver for Chrome, in simple words WebDriver is an open source tool for automated testing of webapps across many browsers which provides capabilities for navigating to web pages, user input, JavaScript execution, and much more. ChromeDriver is the standalone server which implements WebDriver's wire protocol for Chromium.
Conclusion
If you intend to use Chrome Browser in Headless Mode(i.e. Headless Chrome) for your selenium tests you have to mandatorily use ChromeDriver

- 183,867
- 41
- 278
- 352
-
thaks for your all directions. I mean Do i have to use selenium WebDriver? or can i use selenium RC? – mahdokht Jun 20 '18 at 13:54
-
@mahdokht If that is your real question, you should edit your question and update it with what you actually intended to ask. – JeffC Jun 20 '18 at 13:56
-
@mahdokht I have provided you a well documented answer. Go through the answer and the links and let me know if you have any counter questions. **No**, Selenium RC is **dead**. **WebDriver** is the future – undetected Selenium Jun 20 '18 at 13:57
-
@DebanjanB Is Chrome 59+ suitable for Windows OS? or Do I install Chrome 60? – mahdokht Jun 21 '18 at 07:21
-
@mahdokht Ideally, you must install a stable GA version of Chrome and use a compatible ChromeDriver to work with. Moving forward when ever a new release is available in the form of Chrome/ChromeDriver, keep updating your _Test Configuration_ with the newly released binaries as they are always compatible. So suggestion will be, go for _stable GA_ **Chrome v66.x**. The take autoupdate and move to current **Chrome v67.x** – undetected Selenium Jun 21 '18 at 07:24