Skip to content

Commit

Permalink
[py] add headless convenience method for Chrome Options
Browse files Browse the repository at this point in the history
  • Loading branch information
lmtierney committed Nov 16, 2017
1 parent 2c023b6 commit a70ab21
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions py/selenium/webdriver/chrome/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,26 @@ def add_experimental_option(self, name, value):
"""
self._experimental_options[name] = value

@property
def headless(self):
"""
Returns whether or not the headless argument is set
"""
return '--headless' in self._arguments

def set_headless(self, headless=True):
"""
Sets the headless argument
Args:
headless: boolean value indicating to set the headless option
"""
args = {'--headless', '--disable-gpu'}
if headless:
self._arguments.extend(args)
else:
self._arguments = list(set(self._arguments) - args)

def to_capabilities(self):
"""
Creates a capabilities with all the options that have been set and
Expand Down

0 comments on commit a70ab21

Please sign in to comment.