Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added macos for test #38

Open
wants to merge 35 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d0d1596
Update branch alias in composer.json
oleg-andreyev Jul 11, 2023
86b99e9
Bump actions/checkout from 3 to 4 (#82)
dependabot[bot] Sep 28, 2023
9d60129
Bump actions/upload-artifact from 3 to 4 (#84)
dependabot[bot] Dec 21, 2023
c5c2e31
Fix wait method to accept milliseconds (#81)
NoelDeMartin Jan 23, 2024
aad9b68
Bump actions/cache from 3 to 4 (#85)
dependabot[bot] Jan 23, 2024
80c03d5
Update README.md
oleg-andreyev Aug 6, 2024
b3c68c5
Reset driver connection even if stopping the driver fails (#87)
andrewnicols Aug 29, 2024
1e7d39c
Fixed a typo in a README (#86)
aik099 Aug 29, 2024
115a363
- fixing ci for 1.3 (#90)
oleg-andreyev Nov 13, 2024
1a8622f
Update ci.yml (#88)
oleg-andreyev Nov 13, 2024
8f12c29
updated mink/driver-testsuite to v2
oleg-andreyev Nov 13, 2024
b5db536
Update README.md
oleg-andreyev Nov 13, 2024
bb4ad79
added macos for test
oleg-andreyev Mar 7, 2021
153023d
- updated README
oleg-andreyev Oct 29, 2022
b354b89
- updated TimeoutTest for safari and others
oleg-andreyev Oct 29, 2022
179c6c0
- reverted TimeoutTest
oleg-andreyev Oct 29, 2022
b2ca10b
skipping testPromptDismiss for safari
oleg-andreyev Jan 21, 2023
804003a
running simple-phpunit for macos
oleg-andreyev Jan 21, 2023
50d69de
max timeout-minutes 10
oleg-andreyev Jan 21, 2023
8515112
max timeout-minutes 20
oleg-andreyev Jan 21, 2023
247b724
override connection timeout to 5s and request timeout to 10s
oleg-andreyev Jan 21, 2023
3703612
request timeout to 15s, added method to override curl timeout, compos…
oleg-andreyev Jan 22, 2023
f5be585
skipping test
oleg-andreyev Jan 22, 2023
94cb770
added USE_SAFARI_TECHNOLOGY_PREVIEW
oleg-andreyev Jan 22, 2023
5c84b58
skip testInvalidTimeoutSettingThrowsException
oleg-andreyev Jan 22, 2023
616aba2
disabled screenshot for safari
oleg-andreyev Jan 22, 2023
85937e8
skip testShortTimeoutDoesNotWaitForElementToAppear
oleg-andreyev Jan 22, 2023
038fcf9
skip testLongTimeoutWaitsForElementToAppear
oleg-andreyev Jan 22, 2023
07519bb
fixing USE_SAFARI_TECHNOLOGY_PREVIEW
oleg-andreyev Jan 22, 2023
20c77cd
fix
oleg-andreyev Jul 12, 2023
8f129c1
phpcs
oleg-andreyev Jul 12, 2023
f4e1fef
rebase 1.4
oleg-andreyev Nov 14, 2024
5b1b3d2
fix
oleg-andreyev Nov 14, 2024
afd5770
bump behat/mink to 1.11 (#92)
oleg-andreyev Dec 10, 2024
8bf3d72
Merge branch '1.4' into macos
oleg-andreyev Dec 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 102 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
on:
push:
branches:
- master
- "master"
- "1.3"
- "1.4"
pull_request:
branches:
- master
- "master"
- "1.3"
- "1.4"

env:
DRIVER_URL: "http://localhost:4444"
WEB_FIXTURES_HOST: "http://localhost:8002"

USE_SAFARI_TECHNOLOGY_PREVIEW: "false"
defaults:
run:
shell: bash
Expand All @@ -20,18 +24,18 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ 8.2 ]
php: [ 8.3 ]
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
extensions: zip, :xdebug
tools: composer
- id: composer-cache
run: echo "::set-output name=directory::$(composer config cache-dir)"
- uses: actions/cache@v3
run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT
- uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.directory }}
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -44,22 +48,67 @@ jobs:
run: |
./bin/phpstan analyze
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
php: [ 8.0, 8.1, 8.2 ]
php: [ 8.1, 8.2, 8.3 ]
browser: [ chrome, firefox ]
experimental: [false]
os: [ ubuntu-latest ]
use_safari_technology_preview: [false]
include:
- php: 8.1
experimental: true
browser: chrome
os: macos-latest

- php: 8.1
experimental: true
browser: firefox
os: macos-latest

- php: 8.2
experimental: true
browser: chrome
os: macos-latest

- php: 8.2
experimental: true
browser: firefox
os: macos-latest

- php: 8.3
experimental: true
browser: chrome
os: macos-latest

- php: 8.3
experimental: true
browser: firefox
os: macos-latest

- php: 8.3
experimental: true
browser: safari
os: macos-latest
use_safari_technology_preview: false

- php: 8.3
experimental: true
browser: safari
os: macos-latest
use_safari_technology_preview: true

- php: 8.4
experimental: true
browser: chrome
os: ubuntu-latest
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
timeout-minutes: 5
timeout-minutes: 20
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand All @@ -71,10 +120,10 @@ jobs:

- name: Determine composer cache directory
id: composer-cache
run: echo "::set-output name=directory::$(composer config cache-dir)"
run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT

- name: Cache composer dependencies
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.directory }}
key: ${{ matrix.php }}-composer-${{ hashFiles('**/composer.lock') }}
Expand All @@ -84,9 +133,11 @@ jobs:
run: |
mkdir -p ./logs

echo "::group::apt-get install"
sudo apt-get install xvfb
echo "::endgroup::"
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
echo "::group::apt-get install"
sudo apt-get install xvfb
echo "::endgroup::"
fi;

echo "::group::composer update"
composer update --no-interaction --prefer-dist
Expand All @@ -105,22 +156,52 @@ jobs:
- uses: browser-actions/setup-geckodriver@latest
if: matrix.browser == 'firefox'

- if: matrix.browser == 'safari' && matrix.use_safari_technology_preview == true
run: |
brew tap homebrew/cask-versions
brew install --cask safari-technology-preview

- name: Start ChromeDriver
if: ${{ matrix.browser == 'chrome' }}
run: |
xvfb-run --server-args="-screen 0, 1280x720x24" --auto-servernum \
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
chromedriver --port=4444 --verbose --whitelisted-ips= &> ./logs/chromedriver.log &
else
xvfb-run --server-args="-screen 0, 1280x720x24" --auto-servernum \
chromedriver --port=4444 --verbose --whitelisted-ips= &> ./logs/chromedriver.log &
fi;

while ! nc -z localhost 4444 </dev/null; do echo Waiting for driver to start...; sleep 1; done

- name: Start GeckoDriver
if: ${{ matrix.browser == 'firefox' }}
run: |
xvfb-run --server-args="-screen 0, 1280x720x24" --auto-servernum \
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
geckodriver --host 127.0.0.1 -vv --port 4444 &> ./logs/geckodriver.log &
else
xvfb-run --server-args="-screen 0, 1280x720x24" --auto-servernum \
geckodriver --host 127.0.0.1 -vv --port 4444 &> ./logs/geckodriver.log &
fi;

while ! nc -z localhost 4444 </dev/null; do echo Waiting for driver to start...; sleep 1; done

- name: Start SafariDriver
if: ${{ matrix.browser == 'safari' }}
run: |
if [[ "${{ matrix.use_safari_technology_preview }}" == true ]]; then
defaults read /Applications/Safari\ Technology\ Preview.app/Contents/Info CFBundleShortVersionString
else
defaults read /Applications/Safari.app/Contents/Info CFBundleShortVersionString
fi;

if [[ "${{ matrix.use_safari_technology_preview }}" == true ]]; then
/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver -p 4444 --diagnose &
else
/usr/bin/safaridriver -p 4444 --diagnose &
fi;

while ! nc -z localhost 4444 </dev/null; do echo Waiting for driver to start...; sleep 1; done

- name: Start webserver
shell: bash
run: |
Expand All @@ -131,13 +212,14 @@ jobs:
env:
SYMFONY_DEPRECATIONS_HELPER: 'max[total]=999999'
BROWSER_NAME: ${{ matrix.browser }}
USE_SAFARI_TECHNOLOGY_PREVIEW: ${{ matrix.use_safari_technology_preview }}
run: |
./bin/phpunit -v

- name: Archive logs artifacts
if: ${{ always() }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: logs_browser-${{ matrix.browser }}_php-${{ matrix.php }}
name: logs_browser-${{ matrix.os }}_${{ matrix.browser }}_php-${{ matrix.php }}
path: |
logs
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ logs/
vendor-bin/**/vendor/
bin/
vendor/
composer.lock
!bin/browser
!bin/start_driver.sh
!bin/start_webserver.sh
.phpunit.result.cache
.php-cs-fixer.cache
driver.zip
driver.tar.gz
.idea/
.phpunit.result.cache
2 changes: 2 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
return (new PhpCsFixer\Config())
->setRiskyAllowed(true)
->setRules([
'@PHP81Migration' => true,
'@PHPUnit91Migration:risky' => true,
'@Symfony' => true,
])
->setFinder($finder);
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
MinkPhpWebDriver
=================================

[![Latest Stable Version](https://poser.pugx.org/oleg-andreyev/mink-phpwebdriver/v)](https://packagist.org/packages/oleg-andreyev/mink-phpwebdriver)
[![Latest Unstable Version](https://poser.pugx.org/oleg-andreyev/mink-phpwebdriver/v/unstable)](https://packagist.org/packages/oleg-andreyev/mink-phpwebdriver)
[![Total Downloads](https://poser.pugx.org/oleg-andreyev/mink-phpwebdriver/downloads)](https://packagist.org/packages/oleg-andreyev/mink-phpwebdriver)
[![CI](https://github.com/oleg-andreyev/MinkPhpWebDriver/actions/workflows/ci.yml/badge.svg)](https://github.com/oleg-andreyev/MinkPhpWebDriver/actions/workflows/ci.yml)
[![License](https://poser.pugx.org/oleg-andreyev/mink-phpwebdriver/license)](https://github.com/oleg-andreyev/MinkPhpWebDriver/blob/main/LICENSE)
[![codecov](https://codecov.io/gh/oleg-andreyev/mink-phpwebdriver/branch/main/graph/badge.svg?token=11hgqXqod9)](https://codecov.io/gh/oleg-andreyev/mink-phpwebdriver)


Initially it's started as [PR](https://github.com/minkphp/MinkSelenium2Driver/pull/304) to MinkSelenium2Driver

Major updates include:
- Switch to using `facebook/webdriver`
- Update minimum php version to 8.0
- Update minimum php version to 8.1
- Tested against the latest Google Chrome and Mozilla Firefox both in GUI and Headless modes

## Setup
Expand All @@ -20,18 +28,24 @@ https://github.com/oleg-andreyev/MinkPhpWebdriverExtension

## Testing

### Safari
You must enable the 'Allow Remote Automation' option in Safari's Develop menu to control Safari via WebDriver.

```bash
./bin/start_webdriver.sh &
# ./bin/start_driver.sh <browser> <version>
./bin/start_webserver.sh &
# ./bin/start_driver.sh <browser> [<version>]
# ./bin/start_driver.sh chrome
# ./bin/start_driver.sh firefox
# ./bin/start_driver.sh safari
./bin/start_driver.sh chrome latest &
BROWSER_NAME=chrome ./bin/phpunit
```

This will download the latest driver for specified browser and will execute phpunit

## Running GitHub Acton locally
## Running GitHub Action locally
Follow https://github.com/shivammathur/setup-php#local-testing-setup

## Copyright

Copyright (c) 2023 Oleg Andreyev <[email protected]>
Copyright (c) 2024 Oleg Andreyev <[email protected]>
19 changes: 1 addition & 18 deletions bin/browser/chrome.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,8 @@ set -ex
MACHINE_FAMILY=$1
DRIVER_VERSION=$2

if [[ "$DRIVER_VERSION" == "latest" ]]; then
DRIVER_VERSION=$(curl -sS https://chromedriver.storage.googleapis.com/LATEST_RELEASE)
fi

mkdir -p chromedriver

if [[ $MACHINE_FAMILY == "windows" ]]; then
PLATFORM="win32"
fi

if [[ $MACHINE_FAMILY == "linux" ]]; then
PLATFORM="linux64"
fi

if [[ $MACHINE_FAMILY == "mac" ]]; then
PLATFORM="mac64"
fi

wget -q -t 3 "https://chromedriver.storage.googleapis.com/${DRIVER_VERSION}/chromedriver_${PLATFORM}.zip" -O driver.zip
unzip -qo driver.zip -d chromedriver/
./bin/bdi -vvv driver:chromedriver --driver-version=$DRIVER_VERSION --os=$MACHINE_FAMILY ./chromedriver

./chromedriver/chromedriver --port=4444 --verbose --enable-chrome-logs --whitelisted-ips=
27 changes: 1 addition & 26 deletions bin/browser/firefox.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,8 @@ set -ex
MACHINE_FAMILY=$1
DRIVER_VERSION=$2

if [[ "$DRIVER_VERSION" == "latest" ]]; then
DRIVER_VERSION=$(curl -sS https://api.github.com/repos/mozilla/geckodriver/releases/latest | grep -E -o 'tag_name([^,]+)' | tr -d \" | tr -d " " | cut -d':' -f2)
fi

mkdir -p geckodriver

EXTENSION="tar.gz"

if [[ $MACHINE_FAMILY == "windows" ]]; then
PLATFORM="win64"
EXTENSION="zip"
fi

if [[ $MACHINE_FAMILY == "linux" ]]; then
PLATFORM="linux64"
fi

if [[ $MACHINE_FAMILY == "mac" ]]; then
PLATFORM="macos"
fi

wget -q -t 3 "https://github.com/mozilla/geckodriver/releases/download/${DRIVER_VERSION}/geckodriver-$DRIVER_VERSION-${PLATFORM}.${EXTENSION}" -O "driver.${EXTENSION}"

if [[ "$EXTENSION" == "tar.gz" ]]; then
tar -xf driver.tar.gz -C ./geckodriver/;
else
unzip -qo driver.zip -d geckodriver/
fi;
./bin/bdi -vvv driver:geckodriver --driver-version=$DRIVER_VERSION --os=$MACHINE_FAMILY ./geckodriver

./geckodriver/geckodriver --host 127.0.0.1 -vv --port 4444
31 changes: 31 additions & 0 deletions bin/browser/safari.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

set -ex

if [[ $(uname -o) != "Darwin" ]]; then
echo "Can be executed only on MacOS"
exit 1;
fi

rm -rf ~/Library/Logs/com.apple.WebDriver/*

if [[ "$USE_SAFARI_TECHNOLOGY_PREVIEW" == true ]]; then
/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver -p 4444 --diagnose &
else
/usr/bin/safaridriver -p 4444 --diagnose &
fi;

SAFARIDRIVER_PID=$!

function stop {
kill $SAFARIDRIVER_PID
}

trap stop SIGINT
trap stop ERR

# generate first log
sleep 5
curl 127.0.0.1:4444 -vvv

tail -F ~/Library/Logs/com.apple.WebDriver/*
2 changes: 1 addition & 1 deletion bin/start_driver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ UNAME=$(uname -s)
case "$UNAME" in
*NT*) MACHINE_FAMILY=windows ;;
Linux*) MACHINE_FAMILY=linux ;;
Darwin*) MACHINE_FAMILY=mac ;;
Darwin*) MACHINE_FAMILY=macos ;;
esac

if [ -z "$BROWSER_NAME" ]; then
Expand Down
Loading
Loading