[py] add headless convenience method for Chrome Options
@@ -151,6 +151,26 @@ class Options(object):
"""
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
