File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,7 +39,8 @@ def __init__(self,
3939 default_bridge_type = "" ,
4040 headless = False ,
4141 options = None ,
42- use_custom_profile = False
42+ use_custom_profile = False ,
43+ geckodriver_port = 0 # by default a random port will be used
4344 ):
4445
4546 # use_custom_profile: whether to launch from and *write to* the given
@@ -79,12 +80,14 @@ def __init__(self,
7980 tbb_service = Service (
8081 executable_path = executable_path ,
8182 log_path = tbb_logfile_path ,
82- service_args = ["--marionette-port" , "2828" ]
83+ service_args = ["--marionette-port" , "2828" ],
84+ port = geckodriver_port
8385 )
8486 else :
8587 tbb_service = Service (
8688 executable_path = executable_path ,
87- log_path = tbb_logfile_path
89+ log_path = tbb_logfile_path ,
90+ port = geckodriver_port
8891 )
8992 self .options .binary = self .tbb_fx_binary_path
9093 self .options .add_argument ('--class' )
Original file line number Diff line number Diff line change 1010from tbselenium import common as cm
1111from tbselenium .test import TBB_PATH
1212from tbselenium .test .fixtures import TBDriverFixture
13+ from selenium .webdriver .common .utils import free_port
14+ from tbselenium .utils import is_busy
1315
1416
1517class TBDriverTest (unittest .TestCase ):
@@ -126,5 +128,17 @@ def test_custom_profile_and_binary(self):
126128 self .assertEqual (mod_time_before , mod_time_after )
127129
128130
131+ class TBDriverCustomGeckoDriverPort (unittest .TestCase ):
132+
133+ def test_should_accept_custom_geckodriver_port (self ):
134+ """Make sure we accept a custom port number to run geckodriver on."""
135+ random_port = free_port ()
136+ with TBDriverFixture (TBB_PATH , geckodriver_port = random_port ) as driver :
137+ driver .load_url_ensure (cm .ABOUT_TOR_URL )
138+ self .assertTrue (is_busy (random_port )) # check if the port is used
139+ # check if the port is closed after we quit
140+ self .assertFalse (is_busy (random_port ))
141+
142+
129143if __name__ == "__main__" :
130144 unittest .main ()
You can’t perform that action at this time.
0 commit comments