Compare commits

..

77 Commits

Author SHA1 Message Date
54091c05b9 Update .gitea/workflows/chrome-tests.yml
All checks were successful
EdgeTests / build (3.12) (push) Successful in 1m3s
Pylint / build (3.12) (push) Successful in 11s
2024-07-24 17:40:36 +00:00
896a4880b0 switch back to the default run env
Some checks failed
ChromeTests / build (3.12) (push) Failing after 1m2s
EdgeTests / build (3.12) (push) Successful in 1m6s
Pylint / build (3.12) (push) Successful in 12s
2024-07-24 16:05:44 +01:00
fd9ede1054 try a back-leveled version of the gitea image
Some checks failed
ChromeTests / build (3.12) (push) Failing after 4s
EdgeTests / build (3.12) (push) Successful in 58s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 13:16:32 +01:00
ab11976ec5 try a back-leveled version of the gitea image
All checks were successful
EdgeTests / build (3.12) (push) Successful in 1m5s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 13:14:57 +01:00
24a30789b3 Im just about ready to give up
Some checks failed
ChromeTests / build (3.12) (push) Failing after 56s
EdgeTests / build (3.12) (push) Successful in 1m0s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 13:00:04 +01:00
519c7ab538 Im just about ready to give up
Some checks failed
ChromeTests / build (3.12) (push) Failing after 55s
EdgeTests / build (3.12) (push) Successful in 53s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 12:58:00 +01:00
76764c7c82 Im just about ready to give up
Some checks failed
ChromeTests / build (3.12) (push) Failing after 0s
EdgeTests / build (3.12) (push) Successful in 55s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 12:55:40 +01:00
58a09446da Im just about ready to give up
Some checks failed
ChromeTests / build (3.12) (push) Failing after 9s
EdgeTests / build (3.12) (push) Successful in 59s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 12:50:46 +01:00
01a515fcd0 Im just about ready to give up
Some checks failed
Pylint / build (3.12) (push) Waiting to run
ChromeTests / build (3.12) (push) Failing after 3s
EdgeTests / build (3.12) (push) Has been cancelled
2024-07-24 12:49:43 +01:00
a68bf6391a Im just about ready to give up
Some checks failed
ChromeTests / build (3.12) (push) Failing after 2s
EdgeTests / build (3.12) (push) Successful in 58s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 12:44:52 +01:00
62d7ab3f9c lets try that again
Some checks failed
ChromeTests / build (3.12) (push) Failing after 3s
EdgeTests / build (3.12) (push) Successful in 54s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 12:42:17 +01:00
9de744e0fe update to include node installation
Some checks failed
ChromeTests / build (3.12) (push) Failing after 3s
EdgeTests / build (3.12) (push) Successful in 58s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 12:39:37 +01:00
8340e192c9 trying yet another docker image
Some checks failed
ChromeTests / build (3.12) (push) Failing after 2s
EdgeTests / build (3.12) (push) Successful in 56s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 12:32:49 +01:00
cf6ed41183 maybe some xorg library?
Some checks failed
ChromeTests / build (3.12) (push) Failing after 57s
EdgeTests / build (3.12) (push) Successful in 53s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 12:04:09 +01:00
dbfebe3f4a maybe some x11 library?
Some checks failed
ChromeTests / build (3.12) (push) Failing after 48s
EdgeTests / build (3.12) (push) Successful in 59s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 11:56:29 +01:00
63ea391728 looks like I'll have to just figure out what's missing
Some checks failed
ChromeTests / build (3.12) (push) Failing after 54s
EdgeTests / build (3.12) (push) Successful in 54s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 11:50:38 +01:00
29249c0151 try running directly on the host?
Some checks failed
ChromeTests / build (3.12) (push) Failing after 1s
EdgeTests / build (3.12) (push) Successful in 54s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 11:48:38 +01:00
b717315401 try running on a different ci image
Some checks are pending
ChromeTests / build (3.12) (push) Waiting to run
EdgeTests / build (3.12) (push) Successful in 57s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 11:46:51 +01:00
32236a73a0 expanded verbose logging
Some checks failed
ChromeTests / build (3.12) (push) Failing after 52s
EdgeTests / build (3.12) (push) Successful in 53s
Pylint / build (3.12) (push) Successful in 9s
2024-07-24 10:52:33 +01:00
74af52c464 try putting chrome and chromedriver in the same dir
Some checks failed
ChromeTests / build (3.12) (push) Failing after 54s
EdgeTests / build (3.12) (push) Successful in 54s
Pylint / build (3.12) (push) Successful in 10s
2024-07-24 10:40:41 +01:00
b1081bb5b0 pytests should really be a package
All checks were successful
EdgeTests / build (3.12) (push) Successful in 1m10s
Pylint / build (3.12) (push) Successful in 11s
2024-07-24 10:10:01 +01:00
ea601a566f disable chrome tests
All checks were successful
EdgeTests / build (3.12) (push) Successful in 1m7s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 23:03:56 +01:00
ac34730080 adding xvfb to the build
Some checks failed
ChromeTests / build (3.12) (push) Failing after 1m1s
EdgeTests / build (3.12) (push) Successful in 1m3s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 23:00:37 +01:00
39d5d96b6a sigh. typo
Some checks failed
ChromeTests / build (3.12) (push) Failing after 59s
EdgeTests / build (3.12) (push) Successful in 1m3s
Pylint / build (3.12) (push) Successful in 12s
2024-07-23 22:55:45 +01:00
5866721964 fix the binary pathing for chrome
Some checks failed
ChromeTests / build (3.12) (push) Failing after 1m0s
EdgeTests / build (3.12) (push) Successful in 1m8s
Pylint / build (3.12) (push) Successful in 12s
2024-07-23 22:52:24 +01:00
2a3722b585 apparently, the point releases are different
Some checks failed
ChromeTests / build (3.12) (push) Failing after 1m1s
EdgeTests / build (3.12) (push) Successful in 1m5s
Pylint / build (3.12) (push) Successful in 12s
2024-07-23 22:34:57 +01:00
2265e364c2 trying to match up the version numbers
Some checks failed
ChromeTests / build (3.12) (push) Failing after 50s
EdgeTests / build (3.12) (push) Successful in 1m10s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 22:31:16 +01:00
a8623e8eff can I wrap with this syntax?
All checks were successful
EdgeTests / build (3.12) (push) Successful in 1m10s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 22:24:26 +01:00
721292e0cc nearly there?
Some checks failed
ChromeTests / build (3.12) (push) Failing after 1m1s
EdgeTests / build (3.12) (push) Successful in 1m8s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 22:19:37 +01:00
da3cb6ca62 nearly there?
Some checks failed
Pylint / build (3.12) (push) Waiting to run
ChromeTests / build (3.12) (push) Failing after 1m1s
EdgeTests / build (3.12) (push) Has been cancelled
2024-07-23 22:17:33 +01:00
7e98896f81 nearly there?
Some checks failed
ChromeTests / build (3.12) (push) Failing after 1m6s
EdgeTests / build (3.12) (push) Successful in 1m10s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 22:14:01 +01:00
66544d9ac0 where are we?
Some checks failed
ChromeTests / build (3.12) (push) Failing after 40s
EdgeTests / build (3.12) (push) Successful in 1m2s
Pylint / build (3.12) (push) Successful in 12s
2024-07-23 22:11:37 +01:00
4ef52c4352 what about runner workspace?
Some checks failed
ChromeTests / build (3.12) (push) Failing after 38s
EdgeTests / build (3.12) (push) Successful in 1m9s
Pylint / build (3.12) (push) Successful in 11s
2024-07-23 22:03:16 +01:00
6c34ae43c1 lets just get a clean chrome first
Some checks failed
ChromeTests / build (3.12) (push) Failing after 39s
EdgeTests / build (3.12) (push) Successful in 1m5s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 21:57:30 +01:00
a9ecf5c0d4 just friggin install it
Some checks failed
ChromeTests / build (3.12) (push) Failing after 56s
EdgeTests / build (3.12) (push) Successful in 1m10s
Pylint / build (3.12) (push) Successful in 12s
2024-07-23 21:39:33 +01:00
b175d496f2 just friggin install it
Some checks failed
ChromeTests / build (3.12) (push) Failing after 50s
EdgeTests / build (3.12) (push) Successful in 1m3s
Pylint / build (3.12) (push) Successful in 12s
2024-07-23 21:33:11 +01:00
8ed3e7ceb7 just friggin install it
Some checks failed
ChromeTests / build (3.12) (push) Failing after 33s
EdgeTests / build (3.12) (push) Successful in 1m6s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 21:19:37 +01:00
ffd919d3c9 actually, do use them
Some checks failed
ChromeTests / build (3.12) (push) Failing after 27s
EdgeTests / build (3.12) (push) Successful in 1m4s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 21:08:35 +01:00
eb580220a1 don't use the debian repositories
Some checks failed
ChromeTests / build (3.12) (push) Failing after 18s
EdgeTests / build (3.12) (push) Successful in 1m3s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 21:04:51 +01:00
035db22d63 trouble finding the binaries
Some checks failed
ChromeTests / build (3.12) (push) Failing after 30s
EdgeTests / build (3.12) (push) Successful in 1m12s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 20:48:53 +01:00
8c821b3c08 trying to fix the chromedriver link
Some checks failed
ChromeTests / build (3.12) (push) Failing after 28s
EdgeTests / build (3.12) (push) Successful in 1m15s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 20:46:26 +01:00
f7b81266fc adding psuedonyms for chromium
Some checks failed
ChromeTests / build (3.12) (push) Failing after 32s
EdgeTests / build (3.12) (push) Successful in 1m14s
Pylint / build (3.12) (push) Successful in 13s
:
2024-07-23 20:40:39 +01:00
c2543f8cac find out where its installed
Some checks failed
ChromeTests / build (3.12) (push) Failing after 29s
EdgeTests / build (3.12) (push) Successful in 1m12s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 20:37:33 +01:00
bd63e6464c first attempt at a chrome workflow
Some checks failed
ChromeTests / build (3.12) (push) Failing after 39s
EdgeTests / build (3.12) (push) Successful in 1m13s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 20:33:29 +01:00
5a617830e9 customize for ONLY edge for now
All checks were successful
EdgeTests / build (3.12) (push) Successful in 1m13s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 19:38:29 +01:00
7d6d640bc1 remove the behave tests from the stack
All checks were successful
Execute / build (3.12) (push) Successful in 1m10s
Pylint / build (3.12) (push) Successful in 12s
2024-07-23 19:32:41 +01:00
f1165d0fad add the behave tests to the stack
Some checks failed
Execute / build (3.12) (push) Failing after 1m42s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 19:29:48 +01:00
82a4fcbc35 this could be it!
All checks were successful
Execute / build (3.12) (push) Successful in 1m12s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 19:27:07 +01:00
c052005a2d this could be it!
All checks were successful
Execute / build (3.12) (push) Successful in 1m9s
Pylint / build (3.12) (push) Successful in 11s
2024-07-23 19:24:05 +01:00
19d81da8a8 one more try
Some checks failed
Execute / build (3.12) (push) Failing after 1m7s
Pylint / build (3.12) (push) Successful in 12s
2024-07-23 19:19:16 +01:00
31db23ac5e one more try
Some checks failed
Execute / build (3.12) (push) Failing after 1m5s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 19:13:55 +01:00
4078d2430b I give up
Some checks failed
Execute / build (3.12) (push) Failing after 11s
Pylint / build (3.12) (push) Successful in 10s
2024-07-23 19:10:28 +01:00
be9aa45e18 minus why
Some checks failed
Execute / build (3.12) (push) Failing after 41s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 18:58:48 +01:00
d23296309d force an install of edge on the host
Some checks failed
Execute / build (3.12) (push) Failing after 13s
Pylint / build (3.12) (push) Successful in 11s
2024-07-23 18:57:27 +01:00
28a47af395 try to find an edge version in the debian repos
Some checks failed
Execute / build (3.12) (push) Failing after 8s
Pylint / build (3.12) (push) Successful in 13s
2024-07-23 18:51:40 +01:00
895d189302 debugging messages
Some checks failed
Execute / build (3.12) (push) Failing after 9s
Pylint / build (3.12) (push) Successful in 11s
2024-07-23 18:42:36 +01:00
bea18afa60 conditionals in runner scripts
Some checks failed
Execute / build (3.12) (push) Failing after 8s
Pylint / build (3.12) (push) Failing after 11s
2024-07-23 18:29:17 +01:00
9928ecd510 conditionals in runner scripts
Some checks failed
Execute / build (3.12) (push) Failing after 9s
Pylint / build (3.12) (push) Failing after 10s
2024-07-23 18:26:12 +01:00
358f169efb conditionals in runner scripts
Some checks failed
Execute / build (3.12) (push) Failing after 9s
Pylint / build (3.12) (push) Failing after 10s
2024-07-23 18:24:43 +01:00
3413629d6c conditionals in runner scripts
Some checks failed
Execute / build (3.12) (push) Failing after 11s
Pylint / build (3.12) (push) Failing after 11s
2024-07-23 18:22:11 +01:00
c33ed44780 attempted fix for msedge driver
Some checks failed
Execute / build (3.12) (push) Failing after 8s
Pylint / build (3.12) (push) Failing after 11s
2024-07-23 18:08:11 +01:00
0f8388e08c Update .gitea/workflows/execute.yml
Some checks failed
Execute / build (3.12) (push) Failing after 24s
Pylint / build (3.12) (push) Successful in 9s
2024-07-23 16:26:08 +00:00
5cc7b5e520 Update .gitea/workflows/execute.yml
Some checks failed
Execute / build (3.12) (push) Failing after 7s
Pylint / build (3.12) (push) Successful in 10s
2024-07-23 16:24:55 +00:00
93d74bcde1 Update .gitea/workflows/execute.yml
Some checks failed
Execute / build (3.12) (push) Failing after 7s
Pylint / build (3.12) (push) Successful in 11s
2024-07-23 16:23:35 +00:00
7908af7f95 try downloading the edgedriver during build
Some checks failed
Execute / build (3.12) (push) Failing after 6s
Pylint / build (3.12) (push) Successful in 10s
2024-07-23 17:21:29 +01:00
842ddb4399 remove apt searches in execute workflow
Some checks failed
Execute / build (3.12) (push) Failing after 21s
Pylint / build (3.12) (push) Successful in 9s
2024-07-23 16:22:39 +01:00
a7ff39f053 Merge branch 'master' of repos.gmgauthier.com:gmgauthier/behave-framework 2024-07-23 16:22:00 +01:00
dbede2bc6a update driver references for selenium 4 2024-07-23 16:21:49 +01:00
c1c3fd1f28 Update .gitea/workflows/execute.yml
Some checks failed
Execute / build (3.12) (push) Failing after 25s
Pylint / build (3.12) (push) Successful in 10s
2024-07-23 14:58:08 +00:00
49cbb9cfb1 Update .gitea/workflows/execute.yml
Some checks failed
Execute / build (3.12) (push) Failing after 5s
Pylint / build (3.12) (push) Successful in 10s
2024-07-23 14:56:16 +00:00
b396819bac Update .gitea/workflows/execute.yml
Some checks failed
Execute / build (3.12) (push) Failing after 4s
Pylint / build (3.12) (push) Successful in 10s
2024-07-23 14:54:26 +00:00
4e3c267656 run the tests
Some checks failed
Execute / build (3.12) (push) Failing after 24s
Pylint / build (3.12) (push) Successful in 10s
2024-07-23 15:48:03 +01:00
63fcdbc922 fix code, update pylint, other goodies
All checks were successful
Pylint / build (3.12) (push) Successful in 9s
2024-07-23 15:00:35 +01:00
fb4af8ac47 add pylintrc
Some checks failed
Pylint / build (3.12) (push) Failing after 9s
2024-07-23 13:07:24 +00:00
1d8d467a4d add requirements.txt
Some checks failed
Pylint / build (3.12) (push) Failing after 15s
2024-07-23 13:05:54 +00:00
766e1c0f5b add pylint workflow
Some checks failed
Pylint / build (3.12) (push) Failing after 7s
2024-07-23 13:00:38 +00:00
6138d655b2 Add .gitea/workflows/build.yml 2024-07-23 12:59:20 +00:00
19 changed files with 252 additions and 100 deletions

View File

@ -1,21 +0,0 @@
version: 2.1
orbs:
python: circleci/python@0.2.1
jobs:
build-and-test:
executor: python/default
steps:
- checkout
- python/load-cache
- python/install-deps
- python/save-cache
- run:
command: ./manage.py test
name: Test
workflows:
main:
jobs:
- build-and-test

View File

@ -0,0 +1,65 @@
# DISABLED
name: ChromeTests
on: [ push ]
jobs:
build:
runs-on: ubuntu-gitea
strategy:
matrix:
python-version: [ "3.12" ]
env:
CHROMEDRIVER_VERSION: 113.0.5672.63
CHROME_VERSION: 113.0.5672.0
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
mkdir drivers
- name: Prep the host environment for Chrome
run: |
apt update -y
apt upgrade -y
apt install -y fonts-liberation libasound2 libatk-bridge2.0-0 libatk1.0-0 libu2f-udev libcups2 libdrm2\
libgbm1 libgtk-3-0 libgtk-4-1 libnspr4 libnss3 libu2f-udev libvulkan1 libxcomposite1 libxdamage1 libxfixes3\
libxkbcommon0 libxrandr2 xdg-utils xvfb libx11-6 libx11-dev libice6 xorg xorg-dev
- name: Install Chrome and Chromedriver for Linux
if: runner.os == 'Linux'
run: |
wget https://storage.googleapis.com/chrome-for-testing-public/${CHROME_VERSION}/linux64/chrome-linux64.zip
wget https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION}/chromedriver_linux64.zip
unzip chrome-linux64.zip
unzip chromedriver_linux64.zip
mv chromedriver chrome-linux64
- name: Verify Installation
run: |
export PATH=$PATH:${{gitea.workspace}}/chrome-linux64
which chrome
which chromedriver
chrome --version
chromedriver --version
- name: Run the pytests
run: |
export PATH=$PATH:${{gitea.workspace}}/chrome-linux64
export PATH=$PATH:${{gitea.workspace}}/drivers
pytest -vv -c pytest.ini -m chrome
- name: Run the behave tests
run: behave --tags=mark.chrome

View File

@ -0,0 +1,57 @@
name: EdgeTests
on: [ push ]
jobs:
build:
runs-on: ubuntu-gitea
strategy:
matrix:
python-version: [ "3.12" ]
env:
EDGEDRIVER_VERSION: 126.0.2592.102
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
mkdir drivers
- name: Prep the Debian repositories
run: |
apt update -y
apt upgrade -y
- name: Install Edge and EdgeDriver for Linux
if: runner.os == 'Linux'
run: |
wget https://msedgedriver.azureedge.net/${EDGEDRIVER_VERSION}/edgedriver_linux64.zip
unzip edgedriver_linux64.zip
mv msedgedriver drivers
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
install -o root -g root -m 644 microsoft.gpg /etc/apt/trusted.gpg.d/
sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/edge stable main" > /etc/apt/sources.list.d/microsoft-edge-dev.list'
sudo rm microsoft.gpg
apt update
apt install -y microsoft-edge-stable
- name: EdgeDriver for Windows
if: runner.os == 'Windows'
run: |
wget https://msedgedriver.azureedge.net/${EDGEDRIVER_VERSION}/edgedriver_win64.zip
unzip edgedriver_win64.zip
mv msedgedriver.exe drivers
List-Item -Recurse drivers
- name: Run the pytests
run: pytest -c pytest.ini -m edge
- name: Run the behave tests
run: behave --tags=mark.edge

View File

@ -0,0 +1,24 @@
name: Pylint
on: [ push ]
jobs:
build:
runs-on: ubuntu-gitea
strategy:
matrix:
python-version: [ "3.12" ]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
python -m pip install -r requirements.txt
- name: Analysing the code with pylint
run: |
pylint $(git ls-files '*.py')

3
.gitignore vendored
View File

@ -6,3 +6,6 @@
**/__pycache/ **/__pycache/
.idea/ .idea/
.vscode/ .vscode/
.venv/
drivers/
chrome-linux64/

2
.pylintrc Normal file
View File

@ -0,0 +1,2 @@
[MASTER]
disable=C0114, C0115, C0116

23
Pipfile
View File

@ -1,23 +0,0 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
flask = "*"
pytest = "*"
behave = "*"
selenium = "*"
webdriver_manager = "*"
msedge-selenium-tools = "*"
[packages]
flask = "*"
pytest = "*"
behave = "*"
selenium = "*"
webdriver_manager = "*"
msedge-selenium-tools = "*"
[requires]
python_version = "3.6"

View File

@ -1,2 +1,5 @@
# behave-framework # behave-framework
basic python test framework basic python test framework

View File

@ -1,52 +1,69 @@
from selenium import webdriver # pylint: disable=too-few-public-methods
import os
import platform
from msedge.selenium_tools import Edge, EdgeOptions from selenium import webdriver
from webdriver_manager.firefox import GeckoDriverManager from selenium.webdriver.chrome.options import Options as ChromeOptions
from webdriver_manager.chrome import ChromeDriverManager from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.microsoft import EdgeChromiumDriverManager from selenium.webdriver.edge.options import Options as EdgeOptions
from selenium.webdriver.edge.service import Service as EdgeService
from selenium.webdriver.firefox.options import Options as FirefoxOptions
from conftest import CWD
class BrowserDriver: class BrowserDriver:
@staticmethod @staticmethod
def get(browser=None, headless=True): def get(browser=None, headless=True):
if browser == "chrome": valid_browsers = ['chrome', 'firefox', 'safari', 'edge']
return chrome(headless) if browser in valid_browsers:
elif browser == "firefox": browser_method = globals()[browser]
return firefox(headless) return browser_method(headless)
elif browser == "edge":
return edge(headless) raise ValueError(f"'{browser}' is not a supported browser")
elif browser == "safari":
return safari()
else:
raise ValueError("'{}' is not a supported browser".format(browser))
def chrome(headless=True): def chrome(headless=True):
options = webdriver.ChromeOptions() chrome_path = os.path.join(CWD, 'chrome-linux64', 'chrome')
options.headless = headless driver_path = os.path.join(CWD, 'chrome-linux64', 'chromedriver')
options = ChromeOptions()
options.binary_location = chrome_path
if headless:
options.add_argument("--headless")
options.add_argument('--ignore-certificate-errors') options.add_argument('--ignore-certificate-errors')
return webdriver.Chrome( chrome_service = ChromeService(executable_path=driver_path)
ChromeDriverManager().install(), return webdriver.Chrome(service=chrome_service, options=options)
options=options)
def firefox(headless=True): def firefox(headless=True):
options = webdriver.FirefoxOptions() options = FirefoxOptions()
if headless:
options.add_argument("--headless")
options.accept_insecure_certs = True options.accept_insecure_certs = True
options.headless = headless return webdriver.Firefox(options=options)
gecko_driver = GeckoDriverManager().install()
return webdriver.Firefox(
executable_path=gecko_driver,
options=options)
def edge(headless=True): def edge(headless=True):
options = EdgeOptions() options = EdgeOptions()
driver_name = "msedgedriver"
if platform.system() == 'Windows':
driver_name += ".exe"
edgedriver_loc = os.path.join(CWD, 'drivers', driver_name)
if os.path.isfile(edgedriver_loc):
print(f'\nThe file {edgedriver_loc} exists.\n')
else:
print(f'\nThe file {edgedriver_loc} does not exist!\n')
options.use_chromium = True options.use_chromium = True
options.headless = headless options.add_argument('disable-gpu')
edge_driver = EdgeChromiumDriverManager().install() options.add_argument("no-sandbox")
driver = Edge(edge_driver, options=options) options.add_argument("disable-dev-shm-usage")
return driver if headless:
options.add_argument('headless')
edge_service = EdgeService(executable_path=edgedriver_loc)
edge_driver = webdriver.Edge(service=edge_service, options=options)
return edge_driver
def safari(): def safari():

View File

@ -1,13 +1,18 @@
import configparser import configparser
import os
import pytest import pytest
CWD = os.path.dirname(os.path.realpath(__file__))
config = configparser.ConfigParser() config = configparser.ConfigParser()
@pytest.fixture(scope="session", autouse=True) @pytest.fixture(scope="session", autouse=True)
def headless(): def headless():
return _str_to_bool(_read_config_section("fixtures.ini", "dev")["headless"]) config_file = os.path.join(CWD, "fixtures.ini")
dev_config = _read_config_section(config_file, 'dev')
return _str_to_bool(dev_config["headless"])
def _read_config_section(source, section): def _read_config_section(source, section):

View File

@ -1,4 +1,5 @@
Feature: Browser Demo Feature: Browser Demo
Scenario: Load test.io web page with chrome Scenario: Load test.io web page with chrome
Given I have a chrome driver Given I have a chrome driver
When I navigate to test.io When I navigate to test.io
@ -9,12 +10,13 @@ Feature: Browser Demo
When I navigate to test.io When I navigate to test.io
Then The page is displayed Then The page is displayed
@skip @mark.edge
Scenario: Load test.io web page with edge Scenario: Load test.io web page with edge
Given I have an edge driver Given I have an edge driver
When I navigate to test.io When I navigate to test.io
Then The page is displayed Then The page is displayed
@skip
Scenario: Load test.io web page with safari Scenario: Load test.io web page with safari
Given I have a safari driver Given I have a safari driver
When I navigate to test.io When I navigate to test.io

View File

@ -1,5 +1,9 @@
# pylint: disable=unused-argument
def before_all(context): def before_all(context):
# -- SET LOG LEVEL: behave --logging-level=ERROR ... # -- SET LOG LEVEL: behave --logging-level=ERROR ...
# on behave command-line or in "behave.ini". # on behave command-line or in "behave.ini".
context.config.setup_logging() context.config.setup_logging()
def after_scenario(context, scenario):
context.driver.quit()

View File

@ -1,34 +1,34 @@
# pylint: disable=no-name-in-module
from behave import then, when, given from behave import then, when, given
from browserdriver import BrowserDriver from browserdriver import BrowserDriver
@given('I have a firefox driver') @given('I have a firefox driver')
def step_impl(context): def get_firefox_driver(context):
context.driver = BrowserDriver.get("firefox") context.driver = BrowserDriver.get("firefox")
@given('I have a chrome driver') @given('I have a chrome driver')
def step_impl(context): def get_chrome_driver(context):
context.driver = BrowserDriver.get("chrome") context.driver = BrowserDriver.get("chrome")
@given(u'I have an edge driver') @given('I have an edge driver')
def step_impl(context): def get_edge_driver(context):
context.driver = BrowserDriver.get("edge") context.driver = BrowserDriver.get("edge")
@given(u'I have a safari driver') @given('I have a safari driver')
def step_impl(context): def get_safari_driver(context):
context.driver = BrowserDriver.get("safari") context.driver = BrowserDriver.get("safari")
@when('I navigate to test.io') @when('I navigate to test.io')
def step_impl(context): def navigate_to_testio(context):
context.driver.get("https://test.io") context.driver.get("https://test.io")
print(context.driver.title)
@then('The page is displayed') @then('The page is displayed')
def step_impl(context): def page_is_displayed(context):
assert context.driver.title == "QA Testing as a Service | test IO" assert context.driver.title == "Home | Test IO"

View File

@ -1,2 +1,2 @@
[dev] [dev]
headless = True headless=true

View File

@ -1,3 +1,7 @@
[pytest] [pytest]
addopts = -s -v --durations=0
testpaths = pytests testpaths = pytests
markers =
chrome: chrome tests only.
firefox: firefox tests only.
edge: msedge tests only.

0
pytests/__init__.py Normal file
View File

View File

@ -1,31 +1,35 @@
from browserdriver import BrowserDriver
import pytest import pytest
from browserdriver import BrowserDriver
@pytest.mark.firefox
def test_firefox_browser(headless): def test_firefox_browser(headless):
bd = BrowserDriver().get("firefox", headless=headless) bd = BrowserDriver().get("firefox", headless=headless)
bd.get('https://test.io') bd.get('https://test.io')
assert "QA Testing as a Service | test IO" == bd.title assert bd.title == "Home | Test IO"
bd.quit() bd.quit()
@pytest.mark.chrome
def test_chrome_browser(headless): def test_chrome_browser(headless):
bd = BrowserDriver().get("chrome", headless=headless) bd = BrowserDriver().get("chrome", headless=headless)
bd.get('https://test.io') bd.get('https://test.io')
assert "QA Testing as a Service | test IO" == bd.title assert bd.title == "Home | Test IO"
bd.quit() bd.quit()
def test_safari_browser(headless): @pytest.mark.skip(reason="Safari is not available")
def test_safari_browser():
bd = BrowserDriver().get("safari", headless=False) bd = BrowserDriver().get("safari", headless=False)
bd.get('https://test.io') bd.get('https://test.io')
assert "QA Testing as a Service | test IO" == bd.title assert bd.title == "Home | Test IO"
bd.quit() bd.quit()
@pytest.mark.skip(reason="Edge has inconsistent implementations across platforms") @pytest.mark.edge
def test_edge_browser(headless): def test_edge_browser(headless):
bd = BrowserDriver().get("edge", headless=headless) bd = BrowserDriver().get("edge", headless=headless)
bd.get('https://test.io') bd.get('https://test.io')
assert "QA Testing as a Service | test IO" == bd.title assert bd.title == "Home | Test IO"
bd.quit() bd.quit()

6
requirements.txt Normal file
View File

@ -0,0 +1,6 @@
flask~=3.0.3
pytest~=8.3.1
pylint~=3.2.6
behave~=1.2.6
selenium~=4.23.0
webdriver-manager~=4.0.1