File tree Expand file tree Collapse file tree
test/unit/selenium/webdriver Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,7 +165,10 @@ def get_options(driver_class, config):
165165 if not options :
166166 options = getattr (webdriver , f"{ driver_class } Options" )()
167167
168- options .headless = headless
168+ if driver_class == "Chrome" or driver_class == "Edge" :
169+ options .add_argument ("--headless=new" )
170+ if driver_class == "Firefox" :
171+ options .add_argument ("-headless" )
169172 return options
170173
171174
Original file line number Diff line number Diff line change @@ -141,15 +141,26 @@ def headless(self) -> bool:
141141 """
142142 :Returns: True if the headless argument is set, else False
143143 """
144+ warnings .warn (
145+ "headless property is deprecated, instead check for '--headless' in arguments" ,
146+ DeprecationWarning , stacklevel = 2
147+ )
144148 return "--headless" in self ._arguments
145149
146150 @headless .setter
147151 def headless (self , value : bool ) -> None :
148152 """
149153 Sets the headless argument
154+ Old headless uses a non-production browser and is set with `--headless`
155+ Native headless from v86 - v108 is set with `--headless=chrome`
156+ Native headless from v109+ is set with `--headless=new`
150157 :Args:
151158 value: boolean value indicating to set the headless option
152159 """
160+ warnings .warn (
161+ "headless property is deprecated, instead use add_argument('--headless') or add_argument('--headless=new')" ,
162+ DeprecationWarning , stacklevel = 2
163+ )
153164 args = {"--headless" }
154165 if value is True :
155166 self ._arguments .extend (args )
Original file line number Diff line number Diff line change @@ -106,6 +106,10 @@ def headless(self) -> bool:
106106 """
107107 :Returns: True if the headless argument is set, else False
108108 """
109+ warnings .warn (
110+ "headless property is deprecated, instead check for '-headless' in arguments" ,
111+ DeprecationWarning , stacklevel = 2
112+ )
109113 return "-headless" in self ._arguments
110114
111115 @headless .setter
@@ -115,6 +119,10 @@ def headless(self, value: bool) -> None:
115119 Args:
116120 value: boolean value indicating to set the headless option
117121 """
122+ warnings .warn (
123+ "headless property is deprecated, instead use add_argument('-headless')" ,
124+ DeprecationWarning , stacklevel = 2
125+ )
118126 if value :
119127 self ._arguments .append ("-headless" )
120128 elif "-headless" in self ._arguments :
Original file line number Diff line number Diff line change @@ -112,22 +112,6 @@ def test_get_experimental_options(options):
112112 assert options .experimental_options ["foo" ] == "bar"
113113
114114
115- def test_set_headless (options ):
116- options .headless = True
117- assert "--headless" in options ._arguments
118-
119-
120- def test_unset_headless (options ):
121- options ._arguments = ["--headless" ]
122- options .headless = False
123- assert "--headless" not in options ._arguments
124-
125-
126- def test_get_headless (options ):
127- options ._arguments = ["--headless" ]
128- assert options .headless is True
129-
130-
131115def test_creates_capabilities (options ):
132116 options ._arguments = ["foo" ]
133117 options ._binary_location = "/bar"
Original file line number Diff line number Diff line change @@ -127,22 +127,6 @@ def test_set_log_level(options):
127127 assert options .log .level == "debug"
128128
129129
130- def test_set_headless (options ):
131- options .headless = True
132- assert "-headless" in options ._arguments
133-
134-
135- def test_unset_headless (options ):
136- options ._arguments = ["-headless" ]
137- options .headless = False
138- assert "-headless" not in options ._arguments
139-
140-
141- def test_get_headless (options ):
142- options ._arguments = ["-headless" ]
143- assert options .headless
144-
145-
146130def test_creates_capabilities (options ):
147131 profile = FirefoxProfile ()
148132 options ._arguments = ["foo" ]
You can’t perform that action at this time.
0 commit comments