Prerun scripts allow you to configure the TestDriver virtual machine (VM) to launch specific browsers before running your tests. This is particularly useful for testing your application across multiple browsers and ensuring compatibility.
By using prerun scripts, you can:
Install and launch different browsers based on your test requirements.
Customize the test environment for specific scenarios.
Ensure consistent browser configurations across operating systems.
prerun: | if [ "${{ matrix.browser }}" == "chrome" ]; then if [ "${{ matrix.os }}" == "windows" ]; then # Install and launch Google Chrome on Windows $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -Uri "https://dl.google.com/chrome/install/latest/chrome_installer.exe" -OutFile "$env:TEMP\chrome_installer.exe" Start-Process -FilePath "$env:TEMP\chrome_installer.exe" -ArgumentList "/silent", "/install" -Wait Start-Process -FilePath "C:\Program Files\Google\Chrome\Application\chrome.exe" elif [ "${{ matrix.os }}" == "mac" ]; then # Install and launch Google Chrome on macOS brew install --cask google-chrome open -a "Google Chrome" else # Install and launch Google Chrome on Linux wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb sudo apt install ./google-chrome-stable_current_amd64.deb -y google-chrome & fi else if [ "${{ matrix.os }}" == "windows" ]; then # Install and launch Firefox on Windows $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -Uri "https://download.mozilla.org/?product=firefox-latest&os=win64&lang=en-US" -OutFile "$env:TEMP\firefox_installer.exe" Start-Process -FilePath "$env:TEMP\firefox_installer.exe" -ArgumentList "/S" -Wait Start-Process -FilePath "C:\Program Files\Mozilla Firefox\firefox.exe" elif [ "${{ matrix.os }}" == "mac" ]; then # Install and launch Firefox on macOS brew install --cask firefox open -a "Firefox" else # Install and launch Firefox on Linux sudo apt update sudo apt install firefox -y firefox & fi fi