Skip to content

Commit 1bdda87

Browse files
chore: streamline Python Selenium CI workflow by adding Chrome and ChromeDriver setup
1 parent d62b8bd commit 1bdda87

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

.github/workflows/python-selenium-ci-workflow.yaml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ jobs:
4747
- name: Checkout code
4848
uses: actions/checkout@v3
4949

50+
- name: Setup Chrome and ChromeDriver
51+
uses: nanasess/setup-chromedriver@v2
52+
5053
- name: Setup Xvfb
5154
run: |
5255
sudo apt-get update
@@ -84,22 +87,6 @@ jobs:
8487
python-version: '3.12'
8588
cache: 'pip'
8689

87-
- name: Install Chrome
88-
run: |
89-
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
90-
echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list
91-
sudo apt-get update
92-
sudo apt-get install -y google-chrome-stable
93-
94-
- name: Install ChromeDriver
95-
run: |
96-
CHROME_VERSION=$(google-chrome --version | awk '{print $3}' | cut -d. -f1)
97-
wget -N https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION -O - | xargs -I{} wget -N https://chromedriver.storage.googleapis.com/{}/chromedriver_linux64.zip
98-
unzip chromedriver_linux64.zip
99-
chmod +x chromedriver
100-
sudo mv chromedriver /usr/local/bin/
101-
chromedriver --version
102-
10390
- name: Install Python dependencies
10491
run: |
10592
# Check if tests directory exists, if not create it
@@ -108,16 +95,20 @@ jobs:
10895
python -m pip install --upgrade pip
10996
# Check if requirements.txt exists, if not create one
11097
if [ ! -f requirements.txt ]; then
111-
echo "pytest\nselenium\nwebdriver-manager" > requirements.txt
98+
echo -e "pytest\nselenium\nwebdriver-manager" > requirements.txt
11299
fi
113100
pip install -r requirements.txt
114101
115102
- name: Run Selenium tests
116103
run: |
104+
# Create screenshots directory if it doesn't exist
105+
mkdir -p tests/screenshots
106+
117107
cd tests
118-
pytest -v test_home_page.py
108+
python -m pytest -v test_home_page.py
119109
env:
120110
APP_URL: http://localhost:3000
111+
PYTHONPATH: ${{ github.workspace }}
121112

122113
- name: Upload test results
123114
if: always()

0 commit comments

Comments
 (0)