Skip to content

Commit

Permalink
Merge pull request #220 from quarckster/selenium4
Browse files Browse the repository at this point in the history
Bumped selenium minimal version
  • Loading branch information
Dmitrii Misharov authored Apr 29, 2022
2 parents 91dff8e + 7ecbc27 commit a231f80
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_suite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:

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

- name: Pull docker.io/library/nginx:alpine
run: podman pull docker.io/library/nginx:alpine
Expand Down
5 changes: 3 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
name = widgetastic.core
author = Milan Falesnik
author_email = [email protected]
maintainer = Pete Savage
maintainer_email = psavage@redhat.com
maintainer = Dmitrii Misharov
maintainer_email = misharov@redhat.com
description = Making testing of UIs fantastic
long_description = file: README.rst
license = Apache license
Expand All @@ -27,6 +27,7 @@ install_requires =
anytree
cached_property
pytest
selenium >= 4.0.0
selenium-smart-locator
typing_extensions
wait_for
Expand Down
6 changes: 3 additions & 3 deletions src/widgetastic/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,9 @@ def browser_type(self) -> str:

@property
def browser_version(self) -> int:
version = self.selenium.desired_capabilities.get("browserVersion")
if not version:
version = self.selenium.desired_capabilities.get("version")
version = self.selenium.capabilities.get(
"browserVersion"
) or self.selenium.capabilities.get("version")
return int(version.split(".")[0])

@property
Expand Down
17 changes: 4 additions & 13 deletions testing/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
import pytest
from podman import PodmanClient
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
from wait_for import wait_for

from widgetastic.browser import Browser


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


def pytest_addoption(parser):
Expand Down Expand Up @@ -53,13 +51,13 @@ def browser_name(pytestconfig):


@pytest.fixture(scope="session")
def selenium_url(pytestconfig, worker_id, podman, pod):
def selenium_url(worker_id, podman, pod):
"""Yields a command executor URL for selenium, and a port mapped for the test page to run on"""
# use the worker id number from gw# to create hosts on loopback
last_oktet = 1 if worker_id == "master" else int(worker_id.lstrip("gw")) + 1
localhost_for_worker = f"127.0.0.{last_oktet}"
container = podman.containers.create(
image="quay.io/redhatqe/selenium-standalone:latest",
image="quay.io/redhatqe/selenium-standalone:ff_91.8.0esr_chrome_101.0.4951.41",
pod=pod.id,
remove=True,
name=f"selenium_{worker_id}",
Expand Down Expand Up @@ -92,14 +90,7 @@ def testing_page_url(worker_id, podman, pod):
@pytest.fixture(scope="session")
def selenium_webdriver(browser_name, selenium_url, testing_page_url):
wait_for(urlopen, func_args=[selenium_url], timeout=180, handle_exception=True)
if browser_name == "firefox":
desired_capabilities = DesiredCapabilities.FIREFOX.copy()
else:
desired_capabilities = DesiredCapabilities.CHROME.copy()
desired_capabilities["chromeOptions"] = {"args": ["--no-sandbox"]}
driver = webdriver.Remote(
command_executor=selenium_url, desired_capabilities=desired_capabilities
)
driver = webdriver.Remote(command_executor=selenium_url, options=OPTIONS[browser_name.lower()])
driver.maximize_window()
driver.get(testing_page_url)
yield driver
Expand Down

0 comments on commit a231f80

Please sign in to comment.