Skip to content

Commit a231f80

Browse files
author
Dmitrii Misharov
authored
Merge pull request #220 from quarckster/selenium4
Bumped selenium minimal version
2 parents 91dff8e + 7ecbc27 commit a231f80

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

.github/workflows/test_suite.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141

4242
steps:
4343
- name: Pull selenium-standalone:latest
44-
run: podman pull quay.io/redhatqe/selenium-standalone:latest
44+
run: podman pull quay.io/redhatqe/selenium-standalone:ff_91.8.0esr_chrome_101.0.4951.41
4545

4646
- name: Pull docker.io/library/nginx:alpine
4747
run: podman pull docker.io/library/nginx:alpine

setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
name = widgetastic.core
33
author = Milan Falesnik
44
author_email = [email protected]
5-
maintainer = Pete Savage
6-
maintainer_email = psavage@redhat.com
5+
maintainer = Dmitrii Misharov
6+
maintainer_email = misharov@redhat.com
77
description = Making testing of UIs fantastic
88
long_description = file: README.rst
99
license = Apache license
@@ -27,6 +27,7 @@ install_requires =
2727
anytree
2828
cached_property
2929
pytest
30+
selenium >= 4.0.0
3031
selenium-smart-locator
3132
typing_extensions
3233
wait_for

src/widgetastic/browser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,9 @@ def browser_type(self) -> str:
257257

258258
@property
259259
def browser_version(self) -> int:
260-
version = self.selenium.desired_capabilities.get("browserVersion")
261-
if not version:
262-
version = self.selenium.desired_capabilities.get("version")
260+
version = self.selenium.capabilities.get(
261+
"browserVersion"
262+
) or self.selenium.capabilities.get("version")
263263
return int(version.split(".")[0])
264264

265265
@property

testing/conftest.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
import pytest
55
from podman import PodmanClient
66
from selenium import webdriver
7-
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
87
from wait_for import wait_for
98

109
from widgetastic.browser import Browser
1110

1211

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

1614

1715
def pytest_addoption(parser):
@@ -53,13 +51,13 @@ def browser_name(pytestconfig):
5351

5452

5553
@pytest.fixture(scope="session")
56-
def selenium_url(pytestconfig, worker_id, podman, pod):
54+
def selenium_url(worker_id, podman, pod):
5755
"""Yields a command executor URL for selenium, and a port mapped for the test page to run on"""
5856
# use the worker id number from gw# to create hosts on loopback
5957
last_oktet = 1 if worker_id == "master" else int(worker_id.lstrip("gw")) + 1
6058
localhost_for_worker = f"127.0.0.{last_oktet}"
6159
container = podman.containers.create(
62-
image="quay.io/redhatqe/selenium-standalone:latest",
60+
image="quay.io/redhatqe/selenium-standalone:ff_91.8.0esr_chrome_101.0.4951.41",
6361
pod=pod.id,
6462
remove=True,
6563
name=f"selenium_{worker_id}",
@@ -92,14 +90,7 @@ def testing_page_url(worker_id, podman, pod):
9290
@pytest.fixture(scope="session")
9391
def selenium_webdriver(browser_name, selenium_url, testing_page_url):
9492
wait_for(urlopen, func_args=[selenium_url], timeout=180, handle_exception=True)
95-
if browser_name == "firefox":
96-
desired_capabilities = DesiredCapabilities.FIREFOX.copy()
97-
else:
98-
desired_capabilities = DesiredCapabilities.CHROME.copy()
99-
desired_capabilities["chromeOptions"] = {"args": ["--no-sandbox"]}
100-
driver = webdriver.Remote(
101-
command_executor=selenium_url, desired_capabilities=desired_capabilities
102-
)
93+
driver = webdriver.Remote(command_executor=selenium_url, options=OPTIONS[browser_name.lower()])
10394
driver.maximize_window()
10495
driver.get(testing_page_url)
10596
yield driver

0 commit comments

Comments
 (0)