Skip to content

Commit bb38fd0

Browse files
committed
Add Firefox test for stopping driver
1 parent 38028e1 commit bb38fd0

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

py/test/selenium/webdriver/chrome/chrome_service_tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import os
1919
import subprocess
2020
import time
21+
2122
from unittest.mock import patch
2223

2324
import pytest

py/test/selenium/webdriver/edge/edge_service_tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import os
1919
import subprocess
2020
import time
21+
2122
from unittest.mock import patch
2223

2324
import pytest

py/test/selenium/webdriver/firefox/firefox_service_tests.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
1718
import os
1819
import subprocess
20+
1921
from unittest.mock import patch
2022

2123
import pytest
2224

2325
from selenium.webdriver import Firefox
26+
from selenium.common.exceptions import SessionNotCreatedException
27+
from selenium.common.exceptions import WebDriverException
28+
from selenium.webdriver.firefox.options import Options
2429
from selenium.webdriver.firefox.service import Service
2530

2631

@@ -61,6 +66,21 @@ def test_log_output_as_stdout(capfd) -> None:
6166
driver.quit()
6267

6368

69+
def test_driver_is_stopped_if_browser_cant_start(clean_driver, driver_executable) -> None:
70+
options = Options()
71+
#options.set_preference('profile', "/no/such/location")
72+
options.add_argument("-profile==/no/such/location")
73+
service = Service()
74+
with pytest.raises(SessionNotCreatedException):
75+
driver = clean_driver(options=options, service=service)
76+
assert not service.is_connectable()
77+
assert service.process.poll() < 0
78+
try:
79+
driver.quit()
80+
except Exception:
81+
pass
82+
83+
6484
@pytest.fixture
6585
def service():
6686
return Service()

0 commit comments

Comments
 (0)