Skip to content

Commit

Permalink
Setup ChromeDriver CICD
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanglin-Tao committed May 13, 2024
1 parent 58d5a37 commit d8508d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ jobs:
run: |
pdm install
- name: Setup Chrome and ChromeDriver
run: |
sudo apt-get update
sudo apt-get install -y google-chrome-stable
CHROME_VERSION=$(google-chrome --version | cut -d ' ' -f 3 | cut -d '.' -f 1)
wget https://chromedriver.storage.googleapis.com/$(curl -s https://chromedriver.storage.googleapis.com/LATEST_RELEASE_$CHROME_VERSION)/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
sudo mv chromedriver /usr/local/bin/chromedriver
sudo chmod +x /usr/local/bin/chromedriver
- name: Check Code Formatting with Black
run: |
pdm run black --check src/ tests/
Expand Down
6 changes: 5 additions & 1 deletion tests/test_index.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest
import os
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
Expand All @@ -8,7 +9,10 @@
@pytest.fixture(scope="class")
def browser():
# Setup Selenium
service = Service(executable_path="/opt/homebrew/bin/chromedriver")
if os.getenv('CI'):
service = Service()
else:
service = Service(executable_path="/opt/homebrew/bin/chromedriver")
options = Options()
options.add_argument("--headless")
driver = webdriver.Chrome(service=service, options=options)
Expand Down

0 comments on commit d8508d4

Please sign in to comment.