1414# KIND, either express or implied. See the License for the
1515# specific language governing permissions and limitations
1616# under the License.
17-
17+ from selenium .common .exceptions import InvalidArgumentException
18+ from selenium .webdriver .common .proxy import Proxy
1819from selenium .webdriver .firefox .firefox_binary import FirefoxBinary
1920from selenium .webdriver .firefox .firefox_profile import FirefoxProfile
2021
@@ -36,6 +37,7 @@ def __init__(self):
3637 self ._binary = None
3738 self ._preferences = {}
3839 self ._profile = None
40+ self ._proxy = None
3941 self ._arguments = []
4042 self .log = Log ()
4143
@@ -71,6 +73,17 @@ def set_preference(self, name, value):
7173 """Sets a preference."""
7274 self ._preferences [name ] = value
7375
76+ @property
77+ def proxy (self ):
78+ """ returns Proxy if set otherwise None."""
79+ return self ._proxy
80+
81+ @proxy .setter
82+ def proxy (self , value ):
83+ if not isinstance (value , Proxy ):
84+ raise InvalidArgumentException ("Only Proxy objects can be passed in." )
85+ self ._proxy = value
86+
7487 @property
7588 def profile (self ):
7689 """Returns the Firefox profile to use."""
@@ -112,6 +125,8 @@ def to_capabilities(self):
112125 opts ["binary" ] = self ._binary ._start_cmd
113126 if len (self ._preferences ) > 0 :
114127 opts ["prefs" ] = self ._preferences
128+ if self ._proxy is not None :
129+ self ._proxy .add_to_capabilities (opts )
115130 if self ._profile is not None :
116131 opts ["profile" ] = self ._profile .encoded
117132 if len (self ._arguments ) > 0 :
0 commit comments