Skip to content

Commit 98bb108

Browse files
authored
Merge pull request #136 from mshriver/update-tests-deps-gha
Update for selenium4 endpoint
2 parents a2f1117 + 94dcedf commit 98bb108

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

testing/conftest.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
import pytest
66
from podman import PodmanClient
77
from selenium import webdriver
8-
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
98
from wait_for import wait_for
109
from widgetastic.browser import Browser
1110

1211

1312
selenium_browser = None
1413

14+
OPTIONS = {"firefox": webdriver.FirefoxOptions(), "chrome": webdriver.ChromeOptions()}
15+
1516
# Begging, borrowing, and stealing from @quarkster
1617
# https://github.com/RedHatQE/widgetastic.patternfly4/blob/master/testing/conftest.py#L21
1718

@@ -42,6 +43,7 @@ def pod(podman, worker_id):
4243
portmappings=[
4344
{"host_ip": localhost_for_worker, "container_port": 5999, "host_port": 5999},
4445
{"host_ip": localhost_for_worker, "container_port": 4444, "host_port": 4444},
46+
{"host_ip": localhost_for_worker, "container_port": 80, "host_port": 8080},
4547
],
4648
)
4749
pod.start()
@@ -59,15 +61,21 @@ def selenium_url(pytestconfig, worker_id, podman, pod):
5961
"""Yields a command executor URL for selenium, and a port mapped for the test page to run on"""
6062
# use the worker id number from gw# to create hosts on loopback
6163
last_oktet = 1 if worker_id == "master" else int(worker_id.lstrip("gw")) + 1
62-
localhost_for_worker = f"127.0.0.{last_oktet}"
64+
driver_url = f"http://127.0.0.{last_oktet}:4444"
6365
container = podman.containers.create(
6466
image="quay.io/redhatqe/selenium-standalone:latest",
6567
pod=pod.id,
6668
remove=True,
6769
name=f"selenium_{worker_id}",
6870
)
6971
container.start()
70-
yield f"http://{localhost_for_worker}:4444/wd/hub"
72+
wait_for(
73+
urlopen,
74+
func_args=[driver_url],
75+
timeout=180,
76+
handle_exception=True,
77+
)
78+
yield driver_url
7179
container.remove(force=True)
7280

7381

@@ -87,21 +95,13 @@ def testing_page_url(worker_id, podman, pod):
8795
],
8896
)
8997
container.start()
90-
yield "http://127.0.0.1/testing_page.html"
98+
yield "http://localhost:80/testing_page.html"
9199
container.remove(force=True)
92100

93101

94102
@pytest.fixture(scope="session")
95103
def selenium_webdriver(browser_name, selenium_url, testing_page_url):
96-
wait_for(urlopen, func_args=[selenium_url], timeout=180, handle_exception=True)
97-
if browser_name == "firefox":
98-
desired_capabilities = DesiredCapabilities.FIREFOX.copy()
99-
else:
100-
desired_capabilities = DesiredCapabilities.CHROME.copy()
101-
desired_capabilities["chromeOptions"] = {"args": ["--no-sandbox"]}
102-
driver = webdriver.Remote(
103-
command_executor=selenium_url, desired_capabilities=desired_capabilities
104-
)
104+
driver = webdriver.Remote(command_executor=selenium_url, options=OPTIONS[browser_name.lower()])
105105
driver.maximize_window()
106106
driver.get(testing_page_url)
107107
global selenium_browser

testing/test_data_visualization.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
BAR_LEGENDS = ["Q1", "Q3", "Q2", "Q4"]
4747

4848

49-
class TestDataVisualization(View):
49+
class DataVisualization(View):
5050
spark = SparkLineChart(id="sparklineChart")
5151

5252
single_line = SingleLineChart(id="singleLineChart")
@@ -65,7 +65,7 @@ class TestDataVisualization(View):
6565

6666

6767
def test_spark_line_chart(browser):
68-
view = TestDataVisualization(browser)
68+
view = DataVisualization(browser)
6969

7070
assert view.spark.is_displayed
7171
data = view.spark.read()
@@ -77,7 +77,7 @@ def test_spark_line_chart(browser):
7777
"graph", ["single_line", "single_spline", "vertical_bar_chart", "horizontal_bar_chart"]
7878
)
7979
def test_single_legend_charts(browser, graph):
80-
view = TestDataVisualization(browser)
80+
view = DataVisualization(browser)
8181
chart = getattr(view, graph)
8282
data = LINE_DATA_1 if "line" in graph else BAR_DATA_1
8383

@@ -103,7 +103,7 @@ def test_single_legend_charts(browser, graph):
103103
],
104104
)
105105
def test_multi_legend_charts(browser, graph):
106-
view = TestDataVisualization(browser)
106+
view = DataVisualization(browser)
107107
chart = getattr(view, graph)
108108

109109
data = LINE_DATA if "line" in graph else BAR_DATA

0 commit comments

Comments
 (0)