Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7e8ea3f

Browse files
committedOct 30, 2022
build: Run tests using Grid
1 parent 47f4ef3 commit 7e8ea3f

23 files changed

+330
-107
lines changed
 

‎.github/workflows/test.yml

+19-17
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,25 @@ jobs:
4444
python -m pip install --upgrade pip
4545
pip install tox
4646
47-
- name: Setup Firefox
48-
if: matrix.os == 'ubuntu-latest'
49-
uses: browser-actions/setup-firefox@latest
50-
with:
51-
firefox-version: latest
52-
53-
- name: Setup Geckodriver
54-
if: matrix.os == 'ubuntu-latest'
55-
uses: browser-actions/setup-geckodriver@latest
56-
57-
- name: Setup Chrome
58-
uses: browser-actions/setup-chrome@latest
59-
with:
60-
chrome-version: stable
61-
62-
- name: Setup Chromedriver
63-
uses: nanasess/setup-chromedriver@master
47+
- name: Spin up Grid
48+
run: ./start
49+
# - name: Setup Firefox
50+
# if: matrix.os == 'ubuntu-latest'
51+
# uses: browser-actions/setup-firefox@latest
52+
# with:
53+
# firefox-version: latest
54+
#
55+
# - name: Setup Geckodriver
56+
# if: matrix.os == 'ubuntu-latest'
57+
# uses: browser-actions/setup-geckodriver@latest
58+
#
59+
# - name: Setup Chrome
60+
# uses: browser-actions/setup-chrome@latest
61+
# with:
62+
# chrome-version: stable
63+
#
64+
# - name: Setup Chromedriver
65+
# uses: nanasess/setup-chromedriver@master
6466

6567
- name: Cache tox environments
6668
uses: actions/cache@v3

‎docker-compose.arm.yml

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# To execute this docker-compose yml file use `docker-compose -f docker-compose.intel.yml up`
2+
# Add the `-d` flag at the end for detached execution
3+
# To stop the execution, hit Ctrl+C, and then `docker-compose -f docker-compose-v3.yml down`
4+
version: "3"
5+
6+
services:
7+
8+
chromium:
9+
image: seleniarm/node-chromium:latest
10+
container_name: selenium-chromium
11+
shm_size: 2gb
12+
ports:
13+
- "7901:7900"
14+
depends_on:
15+
- selenium-hub
16+
environment:
17+
- SE_EVENT_BUS_HOST=selenium-hub
18+
- SE_EVENT_BUS_PUBLISH_PORT=4442
19+
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
20+
networks:
21+
- grid
22+
23+
firefox:
24+
image: seleniarm/node-firefox:latest
25+
container_name: selenium-firefox
26+
shm_size: 2gb
27+
ports:
28+
- "7903:7900"
29+
depends_on:
30+
- selenium-hub
31+
environment:
32+
- SE_EVENT_BUS_HOST=selenium-hub
33+
- SE_EVENT_BUS_PUBLISH_PORT=4442
34+
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
35+
networks:
36+
- grid
37+
38+
selenium-hub:
39+
image: seleniarm/hub:latest
40+
container_name: selenium-hub
41+
ports:
42+
- "4442:4442"
43+
- "4443:4443"
44+
- "4444:4444"
45+
networks:
46+
- grid
47+
48+
webserver:
49+
container_name: webserver
50+
build:
51+
context: docker/
52+
environment:
53+
- PYTHONDONTWRITEBYTECODE=1
54+
networks:
55+
- grid
56+
depends_on:
57+
- firefox
58+
- chromium
59+
60+
networks:
61+
grid:

‎docker-compose.intel.yml

+77
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# To execute this docker-compose yml file use `docker-compose -f docker-compose.intel.yml up`
2+
# Add the `-d` flag at the end for detached execution
3+
# To stop the execution, hit Ctrl+C, and then `docker-compose -f docker-compose-v3.yml down`
4+
version: "3"
5+
6+
services:
7+
8+
chrome:
9+
image: selenium/node-chrome:latest
10+
container_name: selenium-chrome
11+
shm_size: 2gb
12+
ports:
13+
- "5901:5900"
14+
depends_on:
15+
- selenium-hub
16+
environment:
17+
- SE_EVENT_BUS_HOST=selenium-hub
18+
- SE_EVENT_BUS_PUBLISH_PORT=4442
19+
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
20+
networks:
21+
- grid
22+
23+
edge:
24+
image: selenium/node-edge:latest
25+
container_name: selenium-edge
26+
shm_size: 2gb
27+
ports:
28+
- "5902:5900"
29+
depends_on:
30+
- selenium-hub
31+
environment:
32+
- SE_EVENT_BUS_HOST=selenium-hub
33+
- SE_EVENT_BUS_PUBLISH_PORT=4442
34+
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
35+
networks:
36+
- grid
37+
38+
firefox:
39+
image: selenium/node-firefox:latest
40+
container_name: selenium-firefox
41+
shm_size: 2gb
42+
ports:
43+
- "5903:5900"
44+
depends_on:
45+
- selenium-hub
46+
environment:
47+
- SE_EVENT_BUS_HOST=selenium-hub
48+
- SE_EVENT_BUS_PUBLISH_PORT=4442
49+
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
50+
networks:
51+
- grid
52+
53+
selenium-hub:
54+
image: selenium/hub:latest
55+
container_name: selenium-hub
56+
ports:
57+
- "4442:4442"
58+
- "4443:4443"
59+
- "4444:4444"
60+
networks:
61+
- grid
62+
63+
webserver:
64+
container_name: webserver
65+
build:
66+
context: docker/
67+
environment:
68+
- PYTHONDONTWRITEBYTECODE=1
69+
networks:
70+
- grid
71+
depends_on:
72+
- firefox
73+
- chrome
74+
- edge
75+
76+
networks:
77+
grid:

‎docker/Dockerfile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM python:3.10-slim-buster
2+
3+
WORKDIR /usr/src/app
4+
5+
ENV FLASK_APP=webserver.py
6+
ENV FLASK_RUN_HOST=0.0.0.0
7+
ENV FLASK_RUN_PORT=80
8+
9+
RUN python -m pip install --upgrade pip && \
10+
pip install flask
11+
12+
COPY webserver.py .
13+
14+
CMD ["flask", "run"]

‎docker/webserver.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from flask import Flask
2+
3+
app = Flask(__name__)
4+
5+
6+
@app.route("/")
7+
def home():
8+
return """<h1>Success!</h1><a href="#">Link</a><p>Ё</p>"""

‎pyproject.toml

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ black = ">=22.1.0"
6161
flake8 = ">=4.0.1"
6262
tox = ">=3.24.5"
6363
pre-commit = ">=2.17.0"
64-
pytest-localserver = ">=0.5.0"
6564
pytest-xdist = ">=2.4.0"
6665
pytest-mock = ">=3.6.1"
6766

‎src/pytest_selenium/drivers/browserstack.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def job_access(self):
4848
return field
4949

5050

51-
@pytest.mark.optionalhook
51+
@pytest.hookimpl(optionalhook=True)
5252
def pytest_selenium_runtest_makereport(item, report, summary, extra):
5353
provider = BrowserStack()
5454
if not provider.uses_driver(item.config.getoption("driver")):

‎src/pytest_selenium/drivers/crossbrowsertesting.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def key(self):
3333
)
3434

3535

36-
@pytest.mark.optionalhook
36+
@pytest.hookimpl(optionalhook=True)
3737
def pytest_selenium_capture_debug(item, report, extra):
3838
provider = CrossBrowserTesting()
3939
if not provider.uses_driver(item.config.getoption("driver")):
@@ -57,7 +57,7 @@ def pytest_selenium_capture_debug(item, report, extra):
5757
extra.append(pytest_html.extras.html(_video_html(videos[0])))
5858

5959

60-
@pytest.mark.optionalhook
60+
@pytest.hookimpl(optionalhook=True)
6161
def pytest_selenium_runtest_makereport(item, report, summary, extra):
6262
provider = CrossBrowserTesting()
6363
if not provider.uses_driver(item.config.getoption("driver")):

‎src/pytest_selenium/drivers/remote.py

+7
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
import os
66

7+
# from selenium.webdriver.chrome.options import Options
8+
79
HOST = os.environ.get("SELENIUM_HOST", "localhost")
810
PORT = os.environ.get("SELENIUM_PORT", 4444)
911

@@ -12,8 +14,13 @@ def driver_kwargs(capabilities, host, port, **kwargs):
1214
host = host if host.startswith("http") else f"http://{host}"
1315
executor = f"{host}:{port}/wd/hub"
1416

17+
# options = Options()
18+
# options.add_argument("--log-path=foo.log")
19+
# print(options.to_capabilities())
20+
1521
kwargs = {
1622
"command_executor": executor,
1723
"desired_capabilities": capabilities,
24+
# "options": options,
1825
}
1926
return kwargs

‎src/pytest_selenium/drivers/saucelabs.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def uses_driver(self, driver):
5252
return driver.lower() == self.name.lower()
5353

5454

55-
@pytest.mark.optionalhook
55+
@pytest.hookimpl(optionalhook=True)
5656
def pytest_selenium_capture_debug(item, report, extra):
5757
provider = SauceLabs(item.config.getini("saucelabs_data_center"))
5858
if not provider.uses_driver(item.config.getoption("driver")):
@@ -62,7 +62,7 @@ def pytest_selenium_capture_debug(item, report, extra):
6262
extra.append(pytest_html.extras.html(_video_html(item._driver.session_id)))
6363

6464

65-
@pytest.mark.optionalhook
65+
@pytest.hookimpl(optionalhook=True)
6666
def pytest_selenium_runtest_makereport(item, report, summary, extra):
6767
provider = SauceLabs(item.config.getini("saucelabs_data_center"))
6868
if not provider.uses_driver(item.config.getoption("driver")):

‎src/pytest_selenium/drivers/testingbot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def secret(self):
4242
return self.get_credential("secret", ["TESTINGBOT_SECRET", "TESTINGBOT_PSW"])
4343

4444

45-
@pytest.mark.optionalhook
45+
@pytest.hookimpl(optionalhook=True)
4646
def pytest_selenium_capture_debug(item, report, extra):
4747
provider = TestingBot()
4848
if not provider.uses_driver(item.config.getoption("driver")):
@@ -56,7 +56,7 @@ def pytest_selenium_capture_debug(item, report, extra):
5656
extra.append(pytest_html.extras.html(_video_html(auth_url, session_id)))
5757

5858

59-
@pytest.mark.optionalhook
59+
@pytest.hookimpl(optionalhook=True)
6060
def pytest_selenium_runtest_makereport(item, report, summary, extra):
6161
provider = TestingBot()
6262
if not provider.uses_driver(item.config.getoption("driver")):

‎src/pytest_selenium/pytest_selenium.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ def pytest_report_header(config, startdir):
253253
return "driver: {0}".format(driver)
254254

255255

256-
@pytest.mark.hookwrapper
256+
@pytest.hookimpl(hookwrapper=True)
257257
def pytest_runtest_makereport(item, call):
258258
outcome = yield
259259
report = outcome.get_result()

‎start

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if [[ $(uname -m) == "arm64" ]]; then
6+
arch="arm"
7+
else
8+
arch="intel"
9+
fi
10+
11+
docker-compose -f "docker-compose.${arch}.yml" up -d

‎stop

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
if [[ $(uname -m) == "arm64" ]]; then
6+
arch="arm"
7+
else
8+
arch="intel"
9+
fi
10+
11+
docker-compose -f "docker-compose.${arch}.yml" down

‎testing/conftest.py

+21-6
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
pytest_plugins = "pytester"
1010

1111

12-
def base_url(httpserver):
13-
return httpserver.url
12+
def base_url():
13+
return "http://webserver"
1414

1515

1616
@pytest.fixture
17-
def httpserver_base_url(httpserver):
18-
return "--base-url={0}".format(base_url(httpserver))
17+
def httpserver_base_url():
18+
return "--base-url={0}".format(base_url())
1919

2020

2121
@pytest.fixture(autouse=True)
@@ -59,21 +59,36 @@ def chrome_options(chrome_options):
5959

6060
def runpytestqa(*args, **kwargs):
6161
return testdir.runpytest(
62-
httpserver_base_url, "--driver", "Firefox", *args, **kwargs
62+
httpserver_base_url,
63+
"--driver",
64+
"remote",
65+
"--capability",
66+
"browserName",
67+
"firefox",
68+
*args,
69+
**kwargs,
6370
)
6471

6572
testdir.runpytestqa = runpytestqa
6673

6774
def inline_runqa(*args, **kwargs):
6875
return testdir.inline_run(
69-
httpserver_base_url, "--driver", "Firefox", *args, **kwargs
76+
httpserver_base_url,
77+
"--driver",
78+
"remote",
79+
"--capability",
80+
"browserName",
81+
"firefox",
82+
*args,
83+
**kwargs,
7084
)
7185

7286
testdir.inline_runqa = inline_runqa
7387

7488
def quick_qa(*args, **kwargs):
7589
reprec = inline_runqa(*args)
7690
outcomes = reprec.listoutcomes()
91+
print(f"outcomes: {outcomes}")
7792
names = ("passed", "skipped", "failed")
7893
for name, val in zip(names, outcomes):
7994
wantlen = kwargs.get(name)

‎testing/test_chrome.py

+23-5
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010

1111

1212
@pytest.mark.chrome
13-
def test_launch(testdir, httpserver):
14-
httpserver.serve_content(content="<h1>Success!</h1>")
13+
def test_launch(testdir):
1514
file_test = testdir.makepyfile(
1615
"""
1716
import pytest
@@ -20,7 +19,15 @@ def test_pass(webtext):
2019
assert webtext == u'Success!'
2120
"""
2221
)
23-
testdir.quick_qa("--driver", "Chrome", file_test, passed=1)
22+
testdir.quick_qa(
23+
"--driver",
24+
"Remote",
25+
"--capability",
26+
"browserName",
27+
"chrome",
28+
file_test,
29+
passed=1,
30+
)
2431

2532

2633
@pytest.mark.chrome
@@ -37,13 +44,16 @@ def chrome_options(chrome_options):
3744
def test_pass(selenium): pass
3845
"""
3946
)
40-
reprec = testdir.inline_run("--driver", "Chrome")
47+
reprec = testdir.inline_run(
48+
"--driver", "Remote", "--capability", "browserName", "chrome"
49+
)
4150
passed, skipped, failed = reprec.listoutcomes()
4251
assert len(failed) == 1
4352
out = failed[0].longrepr.reprcrash.message
4453
assert "no chrome binary at /foo/bar" in out
4554

4655

56+
@pytest.mark.xfail(reason="Remote driver currently doesn't support logs")
4757
@pytest.mark.chrome
4858
def test_args(testdir):
4959
file_test = testdir.makepyfile(
@@ -61,5 +71,13 @@ def driver_args():
6171
def test_pass(selenium): pass
6272
"""
6373
)
64-
testdir.quick_qa("--driver", "Chrome", file_test, passed=1)
74+
testdir.quick_qa(
75+
"--driver",
76+
"Remote",
77+
"--capability",
78+
"browserName",
79+
"chrome",
80+
file_test,
81+
passed=1,
82+
)
6583
assert os.path.exists(str(testdir.tmpdir.join("foo.log")))

‎testing/test_destructive.py

+12-13
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,30 @@ def test_skip_destructive_by_default(testdir):
1212
testdir.quick_qa(file_test, passed=0, failed=0, skipped=1)
1313

1414

15-
def test_warn_when_url_is_sensitive(testdir, httpserver, monkeypatch, capsys):
16-
monkeypatch.setenv("SENSITIVE_URL", r"127\.0\.0\.1")
15+
def test_warn_when_url_is_sensitive(testdir, monkeypatch, capsys):
16+
monkeypatch.setenv("SENSITIVE_URL", r"webserver")
1717
file_test = testdir.makepyfile("def test_pass(): pass")
1818
testdir.quick_qa(file_test, "--verbose", passed=0, failed=0, skipped=1)
1919
out, err = capsys.readouterr()
20-
msg = "*** WARNING: sensitive url matches {} ***".format(httpserver.url)
20+
msg = "*** WARNING: sensitive url matches http://webserver ***"
2121
assert msg in out
2222

2323

24-
def test_skip_destructive_when_sensitive_command_line(testdir, httpserver):
24+
def test_skip_destructive_when_sensitive_command_line(testdir):
2525
file_test = testdir.makepyfile("def test_pass(): pass")
26-
print(httpserver.url)
2726
testdir.quick_qa(
28-
"--sensitive-url", r"127\.0\.0\.1", file_test, passed=0, failed=0, skipped=1
27+
"--sensitive-url", "webserver", file_test, passed=0, failed=0, skipped=1
2928
)
3029

3130

32-
def test_skip_destructive_when_sensitive_config_file(testdir, httpserver):
33-
testdir.makefile(".ini", pytest="[pytest]\nsensitive_url=127\\.0\\.0\\.1")
31+
def test_skip_destructive_when_sensitive_config_file(testdir):
32+
testdir.makefile(".ini", pytest="[pytest]\nsensitive_url=webserver")
3433
file_test = testdir.makepyfile("def test_pass(): pass")
3534
testdir.quick_qa(file_test, passed=0, failed=0, skipped=1)
3635

3736

38-
def test_skip_destructive_when_sensitive_env(testdir, httpserver, monkeypatch):
39-
monkeypatch.setenv("SENSITIVE_URL", r"127\.0\.0\.1")
37+
def test_skip_destructive_when_sensitive_env(testdir, monkeypatch):
38+
monkeypatch.setenv("SENSITIVE_URL", "webserver")
4039
file_test = testdir.makepyfile("def test_pass(): pass")
4140
testdir.quick_qa(file_test, passed=0, failed=0, skipped=1)
4241

@@ -52,18 +51,18 @@ def test_pass(): pass
5251
testdir.quick_qa(file_test, passed=1)
5352

5453

55-
def test_run_destructive_when_not_sensitive_command_line(testdir, httpserver):
54+
def test_run_destructive_when_not_sensitive_command_line(testdir):
5655
file_test = testdir.makepyfile("def test_pass(): pass")
5756
testdir.quick_qa("--sensitive-url", "foo", file_test, passed=1)
5857

5958

60-
def test_run_destructive_when_not_sensitive_config_file(testdir, httpserver):
59+
def test_run_destructive_when_not_sensitive_config_file(testdir):
6160
testdir.makefile(".ini", pytest="[pytest]\nsensitive_url=foo")
6261
file_test = testdir.makepyfile("def test_pass(): pass")
6362
testdir.quick_qa(file_test, passed=1, failed=0, skipped=0)
6463

6564

66-
def test_run_destructive_when_not_sensitive_env(testdir, httpserver, monkeypatch):
65+
def test_run_destructive_when_not_sensitive_env(testdir, monkeypatch):
6766
monkeypatch.setenv("SENSITIVE_URL", "foo")
6867
file_test = testdir.makepyfile("def test_pass(): pass")
6968
testdir.quick_qa(file_test, passed=1, failed=0, skipped=0)

‎testing/test_driver.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ def test_provider_naming(name):
203203
assert provider.name == name
204204

205205

206+
@pytest.mark.xfail(reason="Remote driver currently doesn't support logs")
206207
def test_service_log_path(testdir):
207208
file_test = testdir.makepyfile(
208209
"""
@@ -212,9 +213,10 @@ def test_pass(driver_kwargs):
212213
assert driver_kwargs['service_log_path'] is not None
213214
"""
214215
)
215-
testdir.quick_qa("--driver", "Firefox", file_test, passed=1)
216+
testdir.quick_qa(file_test, passed=1)
216217

217218

219+
@pytest.mark.xfail(reason="Remote driver currently doesn't support logs")
218220
def test_no_service_log_path(testdir):
219221
file_test = testdir.makepyfile(
220222
"""
@@ -228,7 +230,7 @@ def test_pass(driver_kwargs):
228230
assert driver_kwargs['service_log_path'] is None
229231
"""
230232
)
231-
testdir.quick_qa("--driver", "Firefox", file_test, passed=1)
233+
testdir.quick_qa(file_test, passed=1)
232234

233235

234236
def test_driver_retry_pass(testdir, mocker):
@@ -248,7 +250,7 @@ def test_pass(driver):
248250
"""
249251
)
250252

251-
testdir.quick_qa("--driver", "Firefox", file_test, passed=1)
253+
testdir.quick_qa(file_test, passed=1)
252254
assert mock_retrying.spy_return.statistics["attempt_number"] == 1
253255

254256

@@ -296,4 +298,4 @@ def test_xdist(driver):
296298
pass
297299
"""
298300
)
299-
testdir.quick_qa("--driver", "firefox", "-n", "2", file_test, passed=1)
301+
testdir.quick_qa("-n", "2", file_test, passed=1)

‎testing/test_driver_log.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
LOG_REGEX = '<a class="text" href=".*" target="_blank">Driver Log</a>'
1313

1414

15-
def test_driver_log(testdir, httpserver):
16-
httpserver.serve_content(content="<h1>Success!</h1>")
15+
@pytest.mark.xfail(reason="Remote driver currently doesn't support logs")
16+
def test_driver_log(testdir):
1717
testdir.makepyfile(
1818
"""
1919
import pytest
@@ -26,13 +26,14 @@ def test_driver_log(webtext):
2626
testdir.runpytestqa("--html", path)
2727
with open(str(path)) as f:
2828
html = f.read()
29+
2930
assert re.search(LOG_REGEX, html) is not None
3031
log_path = testdir.tmpdir.dirpath("basetemp", "test_driver_log0", "driver.log")
3132
assert os.path.exists(str(log_path))
3233

3334

34-
def test_driver_log_fixture(testdir, httpserver):
35-
httpserver.serve_content(content="<h1>Success!</h1>")
35+
@pytest.mark.xfail(reason="Remote driver currently doesn't support logs")
36+
def test_driver_log_fixture(testdir):
3637
file_test = testdir.makepyfile(
3738
"""
3839
import pytest
@@ -49,8 +50,7 @@ def test_pass(webtext):
4950
assert os.path.exists(str(testdir.tmpdir.join("foo.log")))
5051

5152

52-
def test_no_driver_log(testdir, httpserver):
53-
httpserver.serve_content(content="<h1>Success!</h1>")
53+
def test_no_driver_log(testdir):
5454
testdir.makepyfile(
5555
"""
5656
import pytest

‎testing/test_edge.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
44

55
import pytest
6-
import sys
6+
7+
# import sys
78

89

910
pytestmark = pytest.mark.nondestructive
1011

1112

12-
@pytest.mark.skipif(sys.platform != "win32", reason="Edge only runs on Windows")
13+
# @pytest.mark.skipif(sys.platform != "win32", reason="Edge only runs on Windows")
1314
@pytest.mark.edge
14-
def test_launch_legacy(testdir, httpserver):
15-
httpserver.serve_content(content="<h1>Success!</h1>")
15+
def test_launch_legacy(testdir):
1616
file_test = testdir.makepyfile(
1717
"""
1818
import pytest
@@ -21,14 +21,15 @@ def test_pass(webtext):
2121
assert webtext == u'Success!'
2222
"""
2323
)
24-
testdir.quick_qa("--driver", "Edge", file_test, passed=1)
24+
testdir.quick_qa(
25+
"--driver", "remote", "--capability", "browserName", "edge", file_test, passed=1
26+
)
2527

2628

27-
@pytest.mark.skipif(sys.platform != "win32", reason="Edge only runs on Windows")
29+
# @pytest.mark.skipif(sys.platform != "win32", reason="Edge only runs on Windows")
2830
@pytest.mark.edge
2931
@pytest.mark.parametrize("use_chromium", [True, False], ids=["chromium", "legacy"])
30-
def test_launch(use_chromium, testdir, httpserver):
31-
httpserver.serve_content(content="<h1>Success!</h1>")
32+
def test_launch(use_chromium, testdir):
3233
file_test = testdir.makepyfile(
3334
"""
3435
import pytest
@@ -45,4 +46,6 @@ def edge_options(edge_options):
4546
use_chromium
4647
)
4748
)
48-
testdir.quick_qa("--driver", "Edge", file_test, passed=1)
49+
testdir.quick_qa(
50+
"--driver", "remote", "--capability", "browserName", "edge", file_test, passed=1
51+
)

‎testing/test_firefox.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
pytestmark = [pytest.mark.nondestructive, pytest.mark.firefox]
88

99

10-
def test_launch(testdir, httpserver):
11-
httpserver.serve_content(content="<h1>Success!</h1>")
10+
def test_launch(testdir):
1211
file_test = testdir.makepyfile(
1312
"""
1413
import pytest
@@ -20,8 +19,7 @@ def test_pass(webtext):
2019
testdir.quick_qa(file_test, passed=1)
2120

2221

23-
def test_launch_case_insensitive(testdir, httpserver):
24-
httpserver.serve_content(content="<h1>Success!</h1>")
22+
def test_launch_case_insensitive(testdir):
2523
file_test = testdir.makepyfile(
2624
"""
2725
import pytest
@@ -30,16 +28,15 @@ def test_pass(webtext):
3028
assert webtext == u'Success!'
3129
"""
3230
)
33-
testdir.quick_qa("--driver", "firefox", file_test, passed=1)
31+
testdir.quick_qa(file_test, passed=1)
3432

3533

36-
def test_profile(testdir, httpserver):
34+
def test_profile(testdir):
3735
"""Test that specified profile is used when starting Firefox.
3836
3937
The profile changes the colors in the browser, which are then reflected
4038
when calling value_of_css_property.
4139
"""
42-
httpserver.serve_content(content='<h1>Success!</h1><a href="#">Link</a>')
4340
file_test = testdir.makepyfile(
4441
"""
4542
import pytest
@@ -96,9 +93,8 @@ def test_extension(selenium):
9693
testdir.quick_qa("--firefox-extension", extension, file_test, passed=1)
9794

9895

99-
def test_preferences_marker(testdir, httpserver):
96+
def test_preferences_marker(testdir):
10097
"""Test that preferences can be specified using the marker."""
101-
httpserver.serve_content(content='<h1>Success!</h1><a href="#">Link</a>')
10298
file_test = testdir.makepyfile(
10399
"""
104100
import pytest

‎testing/test_report.py

+28-28
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ def test_fail(webtext):
3838

3939

4040
@pytest.mark.parametrize("when", ["always", "failure", "never"])
41-
def test_capture_debug_env(testdir, httpserver, monkeypatch, when):
42-
httpserver.serve_content(content="<h1>Success!</h1><p>Ё</p>")
41+
def test_capture_debug_env(testdir, monkeypatch, when):
42+
# httpserver.serve_content(content="<h1>Success!</h1><p>Ё</p>")
4343
monkeypatch.setenv("SELENIUM_CAPTURE_DEBUG", when)
4444
testdir.makepyfile(
4545
"""
@@ -53,22 +53,22 @@ def test_capture_debug(webtext):
5353
)
5454
result, html = run(testdir)
5555
if when in ["always", "failure"]:
56-
assert URL_LINK.format(httpserver.url) in html
56+
assert URL_LINK.format("http://webserver") in html
5757
assert re.search(SCREENSHOT_LINK_REGEX, html) is not None
5858
assert re.search(SCREENSHOT_REGEX, html) is not None
59-
assert re.search(LOGS_REGEX, html) is not None
59+
# assert re.search(LOGS_REGEX, html) is not None
6060
assert re.search(HTML_REGEX, html) is not None
6161
else:
62-
assert URL_LINK.format(httpserver.url) not in html
62+
assert URL_LINK.format("http://webserver") not in html
6363
assert re.search(SCREENSHOT_LINK_REGEX, html) is None
6464
assert re.search(SCREENSHOT_REGEX, html) is None
65-
assert re.search(LOGS_REGEX, html) is None
65+
# assert re.search(LOGS_REGEX, html) is None
6666
assert re.search(HTML_REGEX, html) is None
6767

6868

6969
@pytest.mark.parametrize("when", ["always", "failure", "never"])
70-
def test_capture_debug_config(testdir, httpserver, when):
71-
httpserver.serve_content(content="<h1>Success!</h1><p>Ё</p>")
70+
def test_capture_debug_config(testdir, when):
71+
# httpserver.serve_content(content="<h1>Success!</h1><p>Ё</p>")
7272
testdir.makefile(
7373
".ini",
7474
pytest="""
@@ -90,30 +90,30 @@ def test_capture_debug(webtext):
9090
)
9191
result, html = run(testdir)
9292
if when in ["always", "failure"]:
93-
assert URL_LINK.format(httpserver.url) in html
93+
assert URL_LINK.format("http://webserver") in html
9494
assert re.search(SCREENSHOT_LINK_REGEX, html) is not None
9595
assert re.search(SCREENSHOT_REGEX, html) is not None
96-
assert re.search(LOGS_REGEX, html) is not None
96+
# assert re.search(LOGS_REGEX, html) is not None
9797
assert re.search(HTML_REGEX, html) is not None
9898
else:
99-
assert URL_LINK.format(httpserver.url) not in html
99+
assert URL_LINK.format("http://webserver") not in html
100100
assert re.search(SCREENSHOT_LINK_REGEX, html) is None
101101
assert re.search(SCREENSHOT_REGEX, html) is None
102-
assert re.search(LOGS_REGEX, html) is None
102+
# assert re.search(LOGS_REGEX, html) is None
103103
assert re.search(HTML_REGEX, html) is None
104104

105105

106106
@pytest.mark.parametrize("exclude", ["url", "screenshot", "html", "logs"])
107-
def test_exclude_debug_env(testdir, httpserver, monkeypatch, exclude):
108-
httpserver.serve_content(content="<h1>Success!</h1><p>Ё</p>")
107+
def test_exclude_debug_env(testdir, monkeypatch, exclude):
108+
# httpserver.serve_content(content="<h1>Success!</h1><p>Ё</p>")
109109
monkeypatch.setenv("SELENIUM_EXCLUDE_DEBUG", exclude)
110110
result, html = run(testdir)
111111
assert result.ret
112112

113113
if exclude == "url":
114-
assert URL_LINK.format(httpserver.url) not in html
114+
assert URL_LINK.format("http://webserver") not in html
115115
else:
116-
assert URL_LINK.format(httpserver.url) in html
116+
assert URL_LINK.format("http://webserver") in html
117117

118118
if exclude == "screenshot":
119119
assert re.search(SCREENSHOT_LINK_REGEX, html) is None
@@ -122,10 +122,10 @@ def test_exclude_debug_env(testdir, httpserver, monkeypatch, exclude):
122122
assert re.search(SCREENSHOT_LINK_REGEX, html) is not None
123123
assert re.search(SCREENSHOT_REGEX, html) is not None
124124

125-
if exclude == "logs":
126-
assert re.search(LOGS_REGEX, html) is None
127-
else:
128-
assert re.search(LOGS_REGEX, html) is not None
125+
# if exclude == "logs":
126+
# assert re.search(LOGS_REGEX, html) is None
127+
# else:
128+
# assert re.search(LOGS_REGEX, html) is not None
129129

130130
if exclude == "html":
131131
assert re.search(HTML_REGEX, html) is None
@@ -134,8 +134,8 @@ def test_exclude_debug_env(testdir, httpserver, monkeypatch, exclude):
134134

135135

136136
@pytest.mark.parametrize("exclude", ["url", "screenshot", "html", "logs"])
137-
def test_exclude_debug_config(testdir, httpserver, exclude):
138-
httpserver.serve_content(content="<h1>Success!</h1><p>Ё</p>")
137+
def test_exclude_debug_config(testdir, exclude):
138+
# httpserver.serve_content(content="<h1>Success!</h1><p>Ё</p>")
139139
testdir.makefile(
140140
".ini",
141141
pytest="""
@@ -149,9 +149,9 @@ def test_exclude_debug_config(testdir, httpserver, exclude):
149149
assert result.ret
150150

151151
if exclude == "url":
152-
assert URL_LINK.format(httpserver.url) not in html
152+
assert URL_LINK.format("http://webserver") not in html
153153
else:
154-
assert URL_LINK.format(httpserver.url) in html
154+
assert URL_LINK.format("http://webserver") in html
155155

156156
if exclude == "screenshot":
157157
assert re.search(SCREENSHOT_LINK_REGEX, html) is None
@@ -160,10 +160,10 @@ def test_exclude_debug_config(testdir, httpserver, exclude):
160160
assert re.search(SCREENSHOT_LINK_REGEX, html) is not None
161161
assert re.search(SCREENSHOT_REGEX, html) is not None
162162

163-
if exclude == "logs":
164-
assert re.search(LOGS_REGEX, html) is None
165-
else:
166-
assert re.search(LOGS_REGEX, html) is not None
163+
# if exclude == "logs":
164+
# assert re.search(LOGS_REGEX, html) is None
165+
# else:
166+
# assert re.search(LOGS_REGEX, html) is not None
167167

168168
if exclude == "html":
169169
assert re.search(HTML_REGEX, html) is None

‎testing/test_webdriver.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
pytestmark = pytest.mark.nondestructive
99

1010

11-
def test_event_listening_webdriver(testdir, httpserver):
11+
def test_event_listening_webdriver(testdir):
1212
file_test = testdir.makepyfile(
1313
"""
1414
import pytest

0 commit comments

Comments
 (0)
Please sign in to comment.