Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
prusse-martin committed Nov 7, 2023
1 parent 165b994 commit edf1e1b
Show file tree
Hide file tree
Showing 5 changed files with 1,652 additions and 1,651 deletions.
10 changes: 9 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,19 @@ jobs:
fail-fast: false
matrix:
PYTHON_VERSION: ["3.10"]
# CHROME_VERSION: ["114.0.5735.90.0"]

steps:
- uses: actions/checkout@v2
- uses: browser-actions/setup-chrome@latest
- run: chrome --version
# with:
# chrome-version: ${{ matrix.CHROME_VERSION }}
- name: Check chrome
run: |
set -x
chrome --version
chromedriver --version
chromeDriver --version
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
Expand Down
8 changes: 5 additions & 3 deletions environment.devenv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,21 @@ includes:
environment:
# Tip: Use `--driver <driver_name>` to change driver for a single run
{% if TEST_QMXGRAPH %}
PYTEST_ADDOPTS: --driver PhantomJS
PYTEST_ADDOPTS: --driver Chrome
{% endif %}

dependencies:
- python ={{ PYTHON_VERSION }}

{% if TEST_QMXGRAPH %}
- cherrypy
- cherrypy >=18.0.0
- pytest-mock
- pytest-qt
- pytest-rerunfailures
- pytest-selenium
- pytest-selenium >2
- pytest-timeout
# - python-chromedriver-binarys
- selenium >=4.0.0, <4.10.0
{% if sys.platform != 'win32' %}
- pytest-xvfb
{% endif %}
Expand Down
29 changes: 5 additions & 24 deletions esss_environment.devenv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,9 @@ includes:
- {{ root }}/_base_environment.devenv.yml

environment:
# PhantomJS
# pros:
# * doesn't open a browser (i.e. known as headless)
# * as consequence, doesn't interfere with developer GUI
# * uses Webkit, same web browser engine used by Qt
#
# cons:
# * seems slower than Firefox driver
# * harder to debug (can't put a breakpoint and take a look at web driver's
# browser, for instance)
#
# Firefox
# pros:
# * easier to debug (Firefox [and Chrome] already come with developer tools
# builtin nowadays)
#
# cons:
# * pops up a Firefox instance for each test
# * it is not the same web browser engine as used by Qt
#
# Tip: Use `--driver <driver_name>` to change driver for a single run
{% if TEST_QMXGRAPH %}
PYTEST_ADDOPTS: --driver PhantomJS
PYTEST_ADDOPTS: --driver Chrome
{% else %}
PYTEST_ADDOPTS: ""
{% endif %}
Expand All @@ -49,13 +29,14 @@ dependencies:
{% if TEST_QMXGRAPH %}
- conda-wrappers

- cherrypy==7.1.0
- phantomjs>=2.1
- cherrypy>=18.0.0
- pytest-mock>=1.4.0
- pytest-qt>=2.1.0
- pytest-selenium>=1.2.1,<2
- pytest-selenium>2
- pytest-timeout>=1.0.0
- pytest-xdist>=1.15
# - python-chromedriver-binarys
- selenium >=4.0.0, <4.10.0
{% if sys.platform != 'win32' %}
- pytest-xvfb
{% endif %}
Expand Down
48 changes: 29 additions & 19 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,36 @@ def pytest_configure(config):
# Fixtures --------------------------------------------------------------------


@pytest.fixture
def phantomjs_driver(capabilities, driver_path, port):
"""
Overrides default `phantomjs_driver` driver from pytest-selenium.
Default implementation uses ephemeral ports just as our tests but
it doesn't provide any way to configure them, for this reason we basically
recreate the driver fixture using port fixture.
"""
kwargs = {}
if capabilities:
kwargs['desired_capabilities'] = capabilities
if driver_path is not None:
kwargs['executable_path'] = driver_path
# @pytest.fixture
# def phantomjs_driver(capabilities, driver_path, port):
# """
# Overrides default `phantomjs_driver` driver from pytest-selenium.
#
# Default implementation uses ephemeral ports just as our tests but
# it doesn't provide any way to configure them, for this reason we basically
# recreate the driver fixture using port fixture.
# """
# kwargs = {}
# if capabilities:
# kwargs['desired_capabilities'] = capabilities
# if driver_path is not None:
# kwargs['executable_path'] = driver_path
#
# kwargs['port'] = port.get()
#
# from selenium.webdriver import PhantomJS
#
# return PhantomJS(**kwargs)

kwargs['port'] = port.get()

from selenium.webdriver import PhantomJS

return PhantomJS(**kwargs)
@pytest.fixture
def chrome_options(chrome_options):
from selenium.webdriver.chrome.options import Options
assert isinstance(chrome_options, Options)
chrome_options.binary_location = r'C:\Program Files\Google\Chrome\Application\chrome.exe'
chrome_options.add_argument("--no-sandbox")
# chrome_options.addArguments("--disable-dev-shm-usage")
chrome_options.add_argument("--headless")
return chrome_options


@pytest.fixture
Expand Down
Loading

0 comments on commit edf1e1b

Please sign in to comment.