File tree Expand file tree Collapse file tree 5 files changed +23
-33
lines changed
test/unit/selenium/webdriver Expand file tree Collapse file tree 5 files changed +23
-33
lines changed Original file line number Diff line number Diff line change @@ -165,7 +165,10 @@ def get_options(driver_class, config):
165
165
if not options :
166
166
options = getattr (webdriver , f"{ driver_class } Options" )()
167
167
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" )
169
172
return options
170
173
171
174
Original file line number Diff line number Diff line change @@ -141,15 +141,26 @@ def headless(self) -> bool:
141
141
"""
142
142
:Returns: True if the headless argument is set, else False
143
143
"""
144
+ warnings .warn (
145
+ "headless property is deprecated, instead check for '--headless' in arguments" ,
146
+ DeprecationWarning , stacklevel = 2
147
+ )
144
148
return "--headless" in self ._arguments
145
149
146
150
@headless .setter
147
151
def headless (self , value : bool ) -> None :
148
152
"""
149
153
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`
150
157
:Args:
151
158
value: boolean value indicating to set the headless option
152
159
"""
160
+ warnings .warn (
161
+ "headless property is deprecated, instead use add_argument('--headless') or add_argument('--headless=new')" ,
162
+ DeprecationWarning , stacklevel = 2
163
+ )
153
164
args = {"--headless" }
154
165
if value is True :
155
166
self ._arguments .extend (args )
Original file line number Diff line number Diff line change @@ -106,6 +106,10 @@ def headless(self) -> bool:
106
106
"""
107
107
:Returns: True if the headless argument is set, else False
108
108
"""
109
+ warnings .warn (
110
+ "headless property is deprecated, instead check for '-headless' in arguments" ,
111
+ DeprecationWarning , stacklevel = 2
112
+ )
109
113
return "-headless" in self ._arguments
110
114
111
115
@headless .setter
@@ -115,6 +119,10 @@ def headless(self, value: bool) -> None:
115
119
Args:
116
120
value: boolean value indicating to set the headless option
117
121
"""
122
+ warnings .warn (
123
+ "headless property is deprecated, instead use add_argument('-headless')" ,
124
+ DeprecationWarning , stacklevel = 2
125
+ )
118
126
if value :
119
127
self ._arguments .append ("-headless" )
120
128
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):
112
112
assert options .experimental_options ["foo" ] == "bar"
113
113
114
114
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
-
131
115
def test_creates_capabilities (options ):
132
116
options ._arguments = ["foo" ]
133
117
options ._binary_location = "/bar"
Original file line number Diff line number Diff line change @@ -127,22 +127,6 @@ def test_set_log_level(options):
127
127
assert options .log .level == "debug"
128
128
129
129
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
-
146
130
def test_creates_capabilities (options ):
147
131
profile = FirefoxProfile ()
148
132
options ._arguments = ["foo" ]
You can’t perform that action at this time.
0 commit comments