Skip to content

Commit a58e8e9

Browse files
authored
Merge branch 'trunk' into pinned-browser-updates
2 parents 441b1e7 + 0a724b1 commit a58e8e9

File tree

4 files changed

+147
-1
lines changed

4 files changed

+147
-1
lines changed

.github/workflows/ci-python.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ jobs:
112112
os: ${{ matrix.os }}
113113
cache-key: py-browser-${{ matrix.browser }}
114114
run: |
115-
bazel test --flaky_test_attempts 3 //py:common-${{ matrix.browser }}-bidi
115+
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:common-${{ matrix.browser }}-bidi
116116
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-${{ matrix.browser }}
117117
118118
safari-tests:

.skipped-tests

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
-//py:test-chrome-test/selenium/webdriver/chrome/chrome_launcher_tests.py
3232
-//py:test-chrome-test/selenium/webdriver/chrome/chrome_service_tests.py
3333
-//py:test-chrome-test/selenium/webdriver/chrome/proxy_tests.py
34+
-//py:test-edge-test/selenium/webdriver/edge/edge_launcher_tests.py
35+
-//py:test-edge-test/selenium/webdriver/edge/edge_service_tests.py
3436
-//rb/spec/integration/selenium/webdriver/chrome:service-chrome
3537
-//rb/spec/integration/selenium/webdriver/chrome:service-chrome-bidi
3638
-//rb/spec/integration/selenium/webdriver/chrome:service-chrome-remote
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
18+
19+
def pytest_generate_tests(metafunc):
20+
if "driver" in metafunc.fixturenames and metafunc.config.option.drivers:
21+
metafunc.parametrize("driver", metafunc.config.option.drivers, indirect=True)
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Licensed to the Software Freedom Conservancy (SFC) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The SFC licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
import os
18+
import subprocess
19+
import time
20+
21+
import pytest
22+
23+
from selenium.common.exceptions import WebDriverException
24+
from selenium.webdriver.edge.service import Service
25+
26+
27+
@pytest.mark.xfail_edge(raises=WebDriverException)
28+
@pytest.mark.no_driver_after_test
29+
def test_uses_edgedriver_logging(clean_driver, driver_executable) -> None:
30+
log_file = "msedgedriver.log"
31+
service_args = ["--append-log"]
32+
33+
service = Service(
34+
log_output=log_file,
35+
service_args=service_args,
36+
executable_path=driver_executable,
37+
)
38+
driver2 = None
39+
try:
40+
driver1 = clean_driver(service=service)
41+
with open(log_file) as fp:
42+
lines = len(fp.readlines())
43+
driver2 = clean_driver(service=service)
44+
with open(log_file) as fp:
45+
assert len(fp.readlines()) >= 2 * lines
46+
finally:
47+
driver1.quit()
48+
if driver2:
49+
driver2.quit()
50+
os.remove(log_file)
51+
52+
53+
@pytest.mark.no_driver_after_test
54+
def test_log_output_as_filename(clean_driver, driver_executable) -> None:
55+
log_file = "msedgedriver.log"
56+
service = Service(log_output=log_file, executable_path=driver_executable)
57+
try:
58+
assert "--log-path=msedgedriver.log" in service.service_args
59+
driver = clean_driver(service=service)
60+
with open(log_file) as fp:
61+
assert "Starting Microsoft Edge WebDriver" in fp.readline()
62+
finally:
63+
driver.quit()
64+
os.remove(log_file)
65+
66+
67+
@pytest.mark.no_driver_after_test
68+
def test_log_output_as_file(clean_driver, driver_executable) -> None:
69+
log_name = "msedgedriver.log"
70+
log_file = open(log_name, "w", encoding="utf-8")
71+
service = Service(log_output=log_file, executable_path=driver_executable)
72+
try:
73+
driver = clean_driver(service=service)
74+
time.sleep(1)
75+
with open(log_name) as fp:
76+
assert "Starting Microsoft Edge WebDriver" in fp.readline()
77+
finally:
78+
driver.quit()
79+
log_file.close()
80+
os.remove(log_name)
81+
82+
83+
@pytest.mark.no_driver_after_test
84+
def test_log_output_as_stdout(clean_driver, capfd, driver_executable) -> None:
85+
service = Service(log_output=subprocess.STDOUT, executable_path=driver_executable)
86+
driver = clean_driver(service=service)
87+
88+
out, err = capfd.readouterr()
89+
assert "Starting Microsoft Edge WebDriver" in out
90+
driver.quit()
91+
92+
93+
@pytest.mark.no_driver_after_test
94+
def test_log_output_null_default(driver, capfd) -> None:
95+
out, err = capfd.readouterr()
96+
assert "Starting Microsoft Edge WebDriver" not in out
97+
driver.quit()
98+
99+
100+
@pytest.fixture
101+
def service():
102+
return Service()
103+
104+
105+
@pytest.mark.usefixtures("service")
106+
class TestEdgeDriverService:
107+
service_path = "/path/to/msedgedriver"
108+
109+
@pytest.fixture(autouse=True)
110+
def setup_and_teardown(self):
111+
os.environ["SE_EDGEDRIVER"] = self.service_path
112+
yield
113+
os.environ.pop("SE_EDGEDRIVER", None)
114+
115+
def test_uses_path_from_env_variable(self, service):
116+
assert "msedgedriver" in service.path
117+
118+
def test_updates_path_after_setting_env_variable(self, service):
119+
new_path = "/foo/bar"
120+
os.environ["SE_EDGEDRIVER"] = new_path
121+
service.executable_path = self.service_path # Simulating the update
122+
123+
assert "msedgedriver" in service.executable_path

0 commit comments

Comments
 (0)