14
14
# KIND, either express or implied. See the License for the
15
15
# specific language governing permissions and limitations
16
16
# under the License.
17
- import typing
18
17
from typing import Union
19
18
19
+ from typing_extensions import deprecated
20
+
20
21
from selenium .webdriver .common .desired_capabilities import DesiredCapabilities
21
22
from selenium .webdriver .common .options import ArgOptions
22
23
from selenium .webdriver .firefox .firefox_binary import FirefoxBinary
@@ -38,35 +39,37 @@ class Options(ArgOptions):
38
39
39
40
def __init__ (self ) -> None :
40
41
super ().__init__ ()
41
- self ._binary : typing . Optional [ FirefoxBinary ] = None
42
+ self ._binary_location = ""
42
43
self ._preferences : dict = {}
43
44
self ._profile = None
44
45
self .log = Log ()
45
46
46
47
@property
48
+ @deprecated ("use binary_location instead" )
47
49
def binary (self ) -> FirefoxBinary :
48
50
"""Returns the FirefoxBinary instance."""
49
- return self ._binary
51
+ return FirefoxBinary ( self ._binary_location )
50
52
51
53
@binary .setter
54
+ @deprecated ("use binary_location instead" )
52
55
def binary (self , new_binary : Union [str , FirefoxBinary ]) -> None :
53
56
"""Sets location of the browser binary, either by string or
54
57
``FirefoxBinary`` instance."""
55
- if not isinstance (new_binary , FirefoxBinary ):
56
- new_binary = FirefoxBinary ( new_binary )
57
- self ._binary = new_binary
58
+ if isinstance (new_binary , FirefoxBinary ):
59
+ new_binary = new_binary . _start_cmd
60
+ self .binary_location = new_binary
58
61
59
62
@property
60
63
def binary_location (self ) -> str :
61
64
""":Returns: The location of the binary."""
62
- return self .binary . _start_cmd
65
+ return self ._binary_location
63
66
64
67
@binary_location .setter # noqa
65
68
def binary_location (self , value : str ) -> None :
66
69
"""Sets the location of the browser binary by string."""
67
70
if not isinstance (value , str ):
68
71
raise TypeError (self .BINARY_LOCATION_ERROR )
69
- self .binary = value
72
+ self ._binary_location = value
70
73
71
74
@property
72
75
def preferences (self ) -> dict :
@@ -102,8 +105,8 @@ def to_capabilities(self) -> dict:
102
105
caps = self ._caps
103
106
opts = {}
104
107
105
- if self ._binary :
106
- opts ["binary" ] = self ._binary . _start_cmd
108
+ if self ._binary_location :
109
+ opts ["binary" ] = self ._binary_location
107
110
if self ._preferences :
108
111
opts ["prefs" ] = self ._preferences
109
112
if self ._profile :
0 commit comments