Skip to content

Commit 061d690

Browse files
committed
install chromedriver
1 parent 644083c commit 061d690

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

.github/workflows/background-tests.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,62 @@ jobs:
4545
- name: Install Node.js dependencies
4646
run: npm ci
4747

48+
- name: Install Google Chrome
49+
run: |
50+
sudo apt-get update
51+
# Attempt to install a specific recent, stable version or just google-chrome-stable
52+
# For more deterministic builds, you might consider a specific version if available via apt,
53+
# or using a Docker image with Chrome pre-installed if extreme consistency is needed.
54+
sudo apt-get install -y google-chrome-stable
55+
56+
- name: Install ChromeDriver
57+
run: |
58+
echo "Determining Chrome version..."
59+
CHROME_BROWSER_VERSION=$(google-chrome --version)
60+
echo "Installed Chrome Browser version: $CHROME_BROWSER_VERSION"
61+
# Extract the major version number (e.g., 124 from "Google Chrome 124.0.6367.207")
62+
CHROME_MAJOR_VERSION=$(echo "$CHROME_BROWSER_VERSION" | cut -f 3 -d ' ' | cut -f 1 -d '.')
63+
echo "Detected Chrome Major version: $CHROME_MAJOR_VERSION"
64+
65+
# For Chrome 115 and later, use the new Chrome for Testing (CfT) JSON endpoints
66+
if [ "$CHROME_MAJOR_VERSION" -ge 115 ]; then
67+
echo "Fetching ChromeDriver version for Chrome $CHROME_MAJOR_VERSION using CfT endpoint..."
68+
# Get the latest known good version of chromedriver for this major Chrome version
69+
CHROMEDRIVER_VERSION_STRING=$(curl -sS "https://googlechromelabs.github.io/chrome-for-testing/LATEST_RELEASE_${CHROME_MAJOR_VERSION}")
70+
if [ -z "$CHROMEDRIVER_VERSION_STRING" ]; then
71+
echo "Could not automatically find ChromeDriver version for Chrome $CHROME_MAJOR_VERSION via LATEST_RELEASE. Please check CfT endpoints."
72+
# As a fallback, attempt to fetch the known good versions and pick the latest chromedriver.
73+
# This is more complex and might require parsing JSON with jq.
74+
# For simplicity, we'll rely on LATEST_RELEASE_ for now.
75+
# If that fails consistently, you might need a more robust script or a fixed ChromeDriver version.
76+
# Alternative: List all known good versions
77+
# curl -sS "https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json"
78+
exit 1
79+
fi
80+
CHROMEDRIVER_URL="https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing/${CHROMEDRIVER_VERSION_STRING}/linux64/chromedriver-linux64.zip"
81+
else
82+
# For older Chrome versions (less common now)
83+
echo "Fetching ChromeDriver version for Chrome $CHROME_MAJOR_VERSION using older method..."
84+
CHROMEDRIVER_VERSION_STRING=$(curl -sS "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_${CHROME_MAJOR_VERSION}")
85+
CHROMEDRIVER_URL="https://chromedriver.storage.googleapis.com/${CHROMEDRIVER_VERSION_STRING}/chromedriver_linux64.zip"
86+
fi
87+
88+
echo "Using ChromeDriver version string: $CHROMEDRIVER_VERSION_STRING"
89+
echo "Downloading ChromeDriver from: $CHROMEDRIVER_URL"
90+
91+
wget -q -O chromedriver.zip "$CHROMEDRIVER_URL"
92+
unzip -o chromedriver.zip -d /tmp/ # Unzip to /tmp
93+
# The zip for CfT often contains a directory like chromedriver-linux64/
94+
sudo mv /tmp/chromedriver-linux64/chromedriver /usr/local/bin/chromedriver || sudo mv /tmp/chromedriver /usr/local/bin/chromedriver
95+
sudo chmod +x /usr/local/bin/chromedriver
96+
# Add /usr/local/bin to GITHUB_PATH to ensure chromedriver is found
97+
echo "/usr/local/bin" >> $GITHUB_PATH
98+
shell: bash
99+
100+
- name: Verify ChromeDriver Installation
101+
run: |
102+
chromedriver --version
103+
48104
- name: Set up Python ${{ matrix.python-version }}
49105
uses: actions/setup-python@v5
50106
with:

0 commit comments

Comments
 (0)