Skip to content

Commit 642f572

Browse files
committed
[py] Add tests for chrome and edge
1 parent ec33954 commit 642f572

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@
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
1920
import time
2021
from unittest.mock import patch
2122

2223
import pytest
2324

25+
from selenium.common.exceptions import SessionNotCreatedException
2426
from selenium.common.exceptions import WebDriverException
27+
from selenium.webdriver.chrome.options import Options
2528
from selenium.webdriver.chrome.service import Service
2629

2730

@@ -107,6 +110,21 @@ def test_log_output_null_default(driver, capfd) -> None:
107110
driver.quit()
108111

109112

113+
@pytest.mark.no_driver_after_test
114+
def test_driver_is_stopped_if_browser_cant_start(clean_driver, driver_executable) -> None:
115+
options = Options()
116+
options.add_argument("--user-data-dir=/no/such/location")
117+
service = Service()
118+
with pytest.raises(SessionNotCreatedException):
119+
driver = clean_driver(options=options, service=service)
120+
assert not service.is_connectable()
121+
assert service.process.poll() < 0
122+
try:
123+
driver.quit()
124+
except Exception:
125+
pass
126+
127+
110128
@pytest.fixture
111129
def service():
112130
return Service()

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@
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
1920
import time
2021
from unittest.mock import patch
2122

2223
import pytest
2324

25+
from selenium.common.exceptions import SessionNotCreatedException
2426
from selenium.common.exceptions import WebDriverException
27+
from selenium.webdriver.edge.options import Options
2528
from selenium.webdriver.edge.service import Service
2629

2730

@@ -107,6 +110,21 @@ def test_log_output_null_default(driver, capfd) -> None:
107110
driver.quit()
108111

109112

113+
@pytest.mark.no_driver_after_test
114+
def test_driver_is_stopped_if_browser_cant_start(clean_driver, driver_executable) -> None:
115+
options = Options()
116+
options.add_argument("--user-data-dir=/no/such/location")
117+
service = Service()
118+
with pytest.raises(SessionNotCreatedException):
119+
driver = clean_driver(options=options, service=service)
120+
assert not service.is_connectable()
121+
assert service.process.poll() < 0
122+
try:
123+
driver.quit()
124+
except Exception:
125+
pass
126+
127+
110128
@pytest.fixture
111129
def service():
112130
return Service()

0 commit comments

Comments
 (0)