From 70734f1af59e6319f3fa7fdb5dea15b522fc9a43 Mon Sep 17 00:00:00 2001 From: Christian Sciberras Date: Tue, 5 Mar 2024 21:22:53 +0100 Subject: [PATCH 1/8] Improve readme --- README.md | 73 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index bd4361e..437a652 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ # Mink WebDriver Classic Driver +[![PHP Version](http://poser.pugx.org/mink/webdriver-classic-driver/require/php)](https://packagist.org/packages/mink/webdriver-classic-driver) [![Latest Stable Version](https://poser.pugx.org/mink/webdriver-classic-driver/v)](https://packagist.org/packages/mink/webdriver-classic-driver) [![Latest Unstable Version](https://poser.pugx.org/mink/webdriver-classic-driver/v/unstable)](https://packagist.org/packages/mink/webdriver-classic-driver) [![Total Downloads](https://poser.pugx.org/mink/webdriver-classic-driver/downloads)](https://packagist.org/packages/mink/webdriver-classic-driver) @@ -7,9 +8,41 @@ [![License](https://poser.pugx.org/mink/webdriver-classic-driver/license)](https://github.com/minkphp/webdriver-classic-driver/blob/main/LICENSE) [![codecov](https://codecov.io/gh/minkphp/webdriver-classic-driver/branch/main/graph/badge.svg?token=11hgqXqod9)](https://codecov.io/gh/minkphp/webdriver-classic-driver) -## Usage Example +A [php-webdriver](https://github.com/php-webdriver/php-webdriver)-based driver +for [Mink](https://github.com/minkphp/Mink), supporting Selenium 2-4 and tested on Chrome, Firefox and Edge. -``` php +## Installation + +### For Mink/Standalone Usage + +Simply install the package with composer and check the [Standalone Usage Example](#standalone-usage-example) below. + +```shell +composer require "behat/mink" "mink/webdriver-classic-driver" +``` + +### For Behat/BDD Usage + +1. Add all the relevant packages - typically this will be for testing your application, so you'd want to use `--dev`. + ```shell + composer require --dev "behat/behat" "behat/mink" "friends-of-behat/mink-extension" "mink/webdriver-classic-driver" + ``` +2. Configure Behat to enable the Mink Extension and set it to use this driver, for example: + ```yaml + # behat.yml + default: + extensions: + Behat\MinkExtension\Extension: + browser_name: chrome + base_url: https://example.com/ + sessions: + default: + webdriver-classic: ~ + ``` + +## Standalone Usage Example + +```php new Session(new WebdriverClassicDriver($browserName)), -)); +]); $session = $mink->getSession('webdriver-classic'); $session->visit($url); @@ -33,29 +66,23 @@ $session->getPage()->findLink('Chat')->click(); Please refer to [MinkExtension-example](https://github.com/Behat/MinkExtension-example) for an executable example. -## Installation - -``` bash -composer require behat/mink mink/webdriver-classic-driver -``` - ## Testing -1. Start WebDriver - 1. If you have Docker installed, run - ```bash - docker run -p 4444:4444 selenium/standalone-firefox:4.18.1 - ``` - 2. If you do not have Docker, but you have Java - ```bash - curl -L https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.18.0/selenium-server-4.18.1.jar > selenium-server-4.18.1.jar - java -jar selenium-server-4.18.1.jar standalone - ``` +1. Start WebDriver: + 1. If you have Docker installed, run: + ```shell + docker run -p 4444:4444 selenium/standalone-firefox:4.18.1 + ``` + 2. If you do not have Docker, but you have Java, run: + ```shell + curl -L https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.18.0/selenium-server-4.18.1.jar > selenium-server-4.18.1.jar + java -jar selenium-server-4.18.1.jar standalone + ``` 2. Start WebServer by running - ``` bash + ```shell ./vendor/bin/mink-test-server ``` 3. Start PhpUnit - ```bash + ```shell ./vendor/bin/phpunit -v --coverage-clover=coverage.clover ``` From a8ce926ef47af4624dff9087c2d354694768d5d9 Mon Sep 17 00:00:00 2001 From: Christian Sciberras Date: Wed, 6 Mar 2024 09:41:10 +0100 Subject: [PATCH 2/8] Update README.md Co-authored-by: Christophe Coevoet --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 437a652..a03f842 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Please refer to [MinkExtension-example](https://github.com/Behat/MinkExtension-e ```shell ./vendor/bin/mink-test-server ``` -3. Start PhpUnit +3. Run PHPUnit ```shell ./vendor/bin/phpunit -v --coverage-clover=coverage.clover ``` From f9a541c2ac06f6fd19aa60c6dda55df04608109b Mon Sep 17 00:00:00 2001 From: Christian Sciberras Date: Wed, 6 Mar 2024 11:11:27 +0100 Subject: [PATCH 3/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a03f842..94eb460 100644 --- a/README.md +++ b/README.md @@ -84,5 +84,5 @@ Please refer to [MinkExtension-example](https://github.com/Behat/MinkExtension-e ``` 3. Run PHPUnit ```shell - ./vendor/bin/phpunit -v --coverage-clover=coverage.clover + ./vendor/bin/phpunit ``` From 9bbdc2774542f2d42712aff93dc15361cb9fa4a2 Mon Sep 17 00:00:00 2001 From: Christian Sciberras Date: Sun, 10 Mar 2024 17:10:55 +0100 Subject: [PATCH 4/8] Add contrib; update readme; add composer scripts --- .github/CONTRIBUTING.md | 39 +++++++++++++++++++++++++++++++++++++++ CHANGELOG.md | 3 --- LICENSE | 2 ++ README.md | 23 ++--------------------- composer.json | 10 ++++++++++ 5 files changed, 53 insertions(+), 24 deletions(-) create mode 100644 .github/CONTRIBUTING.md delete mode 100644 CHANGELOG.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..11e29c4 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,39 @@ +# Contributing to Mink WebDriver Classic Driver + +At the moment, contributions can be in the form of: + +1. [Reporting Bugs or Requesting Features](https://github.com/minkphp/webdriver-classic-driver/issues) +2. [Contributing Code (as Pull Requests)](https://github.com/minkphp/webdriver-classic-driver/pulls) + +## Licensing + +The changes you contribute (as Pull Requests) will be under the +same [MIT License](https://github.com/minkphp/webdriver-classic-driver/blob/main/LICENSE) used by this project. +Needless to say, it is your responsibility that your contribution is either your original work or that it has been +allowed by the original author. + +## Code Quality + +We use automated tools to have a general and consistent level of code quality. Simply run the following before each +commit (or at least before sending a Pull Request): + +```shell +composer run lint +``` + +## Testing + +1. Firstly, you will need to run Selenium and a Web Browser (and/or perhaps a driver in between): + 1. **With Docker** - A `docker-compose.yml` file with sensible defaults is already provided , so you can just run: + ```shell + docker-compose up + ``` + 2. **With Java (Native)** - This would take more work, but performs better. Get started by running: + ```shell + curl -L https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.18.0/selenium-server-4.18.1.jar > selenium-server-4.18.1.jar + java -jar selenium-server-4.18.1.jar standalone + ``` +2. Finally, you can simply run the tests with: + ```shell + composer run test + ``` diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index ade6d88..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,3 +0,0 @@ -## 1.0.0 / unreleased - -Initial release of the driver diff --git a/LICENSE b/LICENSE index 8433f21..9f53c0c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,3 +1,5 @@ +MIT License + Copyright (c) 2023-present MinkPhp contributors Permission is hereby granted, free of charge, to any person diff --git a/README.md b/README.md index 94eb460..91494b4 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,8 @@ composer require "behat/mink" "mink/webdriver-classic-driver" ## Standalone Usage Example +You'll need to set up Selenium. Refer to [Contributing \ Testing](.github/CONTRIBUTING.md#testing) to see how. + ```php getPage()->findLink('Chat')->click(); ``` Please refer to [MinkExtension-example](https://github.com/Behat/MinkExtension-example) for an executable example. - -## Testing - -1. Start WebDriver: - 1. If you have Docker installed, run: - ```shell - docker run -p 4444:4444 selenium/standalone-firefox:4.18.1 - ``` - 2. If you do not have Docker, but you have Java, run: - ```shell - curl -L https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.18.0/selenium-server-4.18.1.jar > selenium-server-4.18.1.jar - java -jar selenium-server-4.18.1.jar standalone - ``` -2. Start WebServer by running - ```shell - ./vendor/bin/mink-test-server - ``` -3. Run PHPUnit - ```shell - ./vendor/bin/phpunit - ``` diff --git a/composer.json b/composer.json index e608342..6b86893 100644 --- a/composer.json +++ b/composer.json @@ -40,5 +40,15 @@ "branch-alias": { "dev-main": "1.x-dev" } + }, + "scripts": { + "lint": [ + "Composer\\Config::disableProcessTimeout", + "vendor/bin/phpstan" + ], + "test": [ + "Composer\\Config::disableProcessTimeout", + "vendor/bin/phpunit" + ] } } From 97689325fde82c0b5d71e1656746a4cc82080add Mon Sep 17 00:00:00 2001 From: Christian Sciberras Date: Thu, 14 Mar 2024 19:35:13 +0100 Subject: [PATCH 5/8] CR fixes --- .github/CONTRIBUTING.md | 2 +- LICENSE | 2 -- README.md | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 11e29c4..671c2b4 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -26,7 +26,7 @@ composer run lint 1. Firstly, you will need to run Selenium and a Web Browser (and/or perhaps a driver in between): 1. **With Docker** - A `docker-compose.yml` file with sensible defaults is already provided , so you can just run: ```shell - docker-compose up + docker compose up ``` 2. **With Java (Native)** - This would take more work, but performs better. Get started by running: ```shell diff --git a/LICENSE b/LICENSE index 9f53c0c..8433f21 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,3 @@ -MIT License - Copyright (c) 2023-present MinkPhp contributors Permission is hereby granted, free of charge, to any person diff --git a/README.md b/README.md index 91494b4..a3f267d 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ composer require "behat/mink" "mink/webdriver-classic-driver" ## Standalone Usage Example -You'll need to set up Selenium. Refer to [Contributing \ Testing](.github/CONTRIBUTING.md#testing) to see how. +You will need to run a WebDriver server, either using [Selenium](https://www.selenium.dev/) or the browser driver directly. ```php Date: Sat, 29 Jun 2024 21:36:43 +0200 Subject: [PATCH 6/8] Update README.md --- README.md | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/README.md b/README.md index a3f267d..05238e0 100644 --- a/README.md +++ b/README.md @@ -27,18 +27,7 @@ composer require "behat/mink" "mink/webdriver-classic-driver" ```shell composer require --dev "behat/behat" "behat/mink" "friends-of-behat/mink-extension" "mink/webdriver-classic-driver" ``` -2. Configure Behat to enable the Mink Extension and set it to use this driver, for example: - ```yaml - # behat.yml - default: - extensions: - Behat\MinkExtension\Extension: - browser_name: chrome - base_url: https://example.com/ - sessions: - default: - webdriver-classic: ~ - ``` +2. Configure Behat to enable the Mink Extension and set it to use this drive. ## Standalone Usage Example From 3466441a59e7a10478f85d1b1776f2f3c5f2d76e Mon Sep 17 00:00:00 2001 From: Christian Sciberras Date: Tue, 6 Aug 2024 20:19:16 +0200 Subject: [PATCH 7/8] Update README.md Co-authored-by: Christophe Coevoet --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 05238e0..26494e2 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ composer require "behat/mink" "mink/webdriver-classic-driver" ```shell composer require --dev "behat/behat" "behat/mink" "friends-of-behat/mink-extension" "mink/webdriver-classic-driver" ``` -2. Configure Behat to enable the Mink Extension and set it to use this drive. +2. Configure Behat to enable the Mink Extension and set it to use this driver. ## Standalone Usage Example From 4b888e5fe9a57c91e1f0957585d8f145718513c3 Mon Sep 17 00:00:00 2001 From: Christian Sciberras Date: Fri, 1 Nov 2024 18:41:24 +0100 Subject: [PATCH 8/8] Merge latest main; add a few improvements --- .gitattributes | 1 + .github/CONTRIBUTING.md | 39 -------------------------------- CONTRIBUTING.md | 50 +++++++++++++++++++++++++++++++++++++++++ README.md | 4 ++-- 4 files changed, 53 insertions(+), 41 deletions(-) delete mode 100644 .github/CONTRIBUTING.md create mode 100644 CONTRIBUTING.md diff --git a/.gitattributes b/.gitattributes index 60c56bf..cea7f33 100644 --- a/.gitattributes +++ b/.gitattributes @@ -6,5 +6,6 @@ /phpunit.xml.dist export-ignore /tests export-ignore /README.md export-ignore +/CONTRIBUTING.md export-ignore /resources/get-syn.php export-ignore /docker-compose.yaml export-ignore diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md deleted file mode 100644 index 671c2b4..0000000 --- a/.github/CONTRIBUTING.md +++ /dev/null @@ -1,39 +0,0 @@ -# Contributing to Mink WebDriver Classic Driver - -At the moment, contributions can be in the form of: - -1. [Reporting Bugs or Requesting Features](https://github.com/minkphp/webdriver-classic-driver/issues) -2. [Contributing Code (as Pull Requests)](https://github.com/minkphp/webdriver-classic-driver/pulls) - -## Licensing - -The changes you contribute (as Pull Requests) will be under the -same [MIT License](https://github.com/minkphp/webdriver-classic-driver/blob/main/LICENSE) used by this project. -Needless to say, it is your responsibility that your contribution is either your original work or that it has been -allowed by the original author. - -## Code Quality - -We use automated tools to have a general and consistent level of code quality. Simply run the following before each -commit (or at least before sending a Pull Request): - -```shell -composer run lint -``` - -## Testing - -1. Firstly, you will need to run Selenium and a Web Browser (and/or perhaps a driver in between): - 1. **With Docker** - A `docker-compose.yml` file with sensible defaults is already provided , so you can just run: - ```shell - docker compose up - ``` - 2. **With Java (Native)** - This would take more work, but performs better. Get started by running: - ```shell - curl -L https://github.com/SeleniumHQ/selenium/releases/download/selenium-4.18.0/selenium-server-4.18.1.jar > selenium-server-4.18.1.jar - java -jar selenium-server-4.18.1.jar standalone - ``` -2. Finally, you can simply run the tests with: - ```shell - composer run test - ``` diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..2f89721 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,50 @@ +# Contributing to Mink WebDriver Classic Driver + +At the moment, contributions can be in the form of: + +1. [Reporting Bugs or Requesting Features](https://github.com/minkphp/webdriver-classic-driver/issues) +2. [Contributing Code (as Pull Requests)](https://github.com/minkphp/webdriver-classic-driver/pulls) + +## Licensing + +The changes you contribute (as Pull Requests) will be under the same +[MIT License](https://github.com/minkphp/webdriver-classic-driver/blob/main/LICENSE) used by this project. Needless to say, it is your responsibility that your contribution is either +your original work or that it has been allowed by the original author. + +## Code Quality + +We use automated tools to have a general and consistent level of code quality. Simply run the following before pushing +each commit (or at least before sending a Pull Request): + +```shell +composer run lint +``` + +## Testing + +You will need [Docker](https://www.docker.com/products/docker-desktop/), [PHP 7.4](https://php.net/downloads) or higher +and [Composer](https://getcomposer.org) running on your machine. + +1. Run the Selenium service (containing Chrome by default) with: + ```shell + docker compose up + ``` +2. Secondly, simply run the tests with: + ```shell + composer run test + ``` +3. You can observe and interact with the tests by visiting [`localhost:7900`](http://localhost:7900). + +### Additional Notes + +- By default, Chrome and Selenium 4 is used - but you can change that with the `SELENIUM_IMAGE` env var, e.g.: + ```shell + export SELENIUM_IMAGE=selenium/standalone-firefox:3 # Firefox and Selenium 3 + docker compose up + ``` +- Tests depends on a server serving the test fixtures. `bootstrap.php` conveniently starts (and stops) such a server + for you while tests are running. It defaults to port `8002` for historical reasons, but can be changed with a custom + PHPUnit config file and changing the `WEB_FIXTURES_HOST` variable (see also the next point). +- To customise any PHPUnit settings, make a copy of `phpunit.xml.dist` named as `phpunit.xml` and change it as needed. +- The test setup can also work without Docker, but takes more effort (downloading and running **Selenium**, a + **Web Browser** and probably a **Web Driver** for your browser). diff --git a/README.md b/README.md index 5ad87ae..506a3fd 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ use Behat\Mink\Mink, require_once __DIR__ . '/vendor/autoload.php'; -$browserName = 'firefox'; +$browserName = 'chrome'; $url = 'https://example.com'; $mink = new Mink([ @@ -52,7 +52,7 @@ $mink = new Mink([ $session = $mink->getSession('webdriver-classic'); $session->visit($url); -$session->getPage()->findLink('Chat')->click(); +$session->getPage()->findLink('More information...')->click(); ``` Please refer to [MinkExtension-example](https://github.com/Behat/MinkExtension-example) for an executable example.