├── .editorconfig ├── .styleci.yml ├── LICENSE.md ├── README.md ├── composer.json └── src └── SupportsSafari.php /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at http://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_size = 4 9 | indent_style = space 10 | end_of_line = lf 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.styleci.yml: -------------------------------------------------------------------------------- 1 | preset: laravel 2 | 3 | linting: true 4 | 5 | disabled: 6 | - single_class_element_per_statement 7 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | 3 | Copyright (c) Appstract 4 | 5 | > Permission is hereby granted, free of charge, to any person obtaining a copy 6 | > of this software and associated documentation files (the "Software"), to deal 7 | > in the Software without restriction, including without limitation the rights 8 | > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | > copies of the Software, and to permit persons to whom the Software is 10 | > furnished to do so, subject to the following conditions: 11 | > 12 | > The above copyright notice and this permission notice shall be included in 13 | > all copies or substantial portions of the Software. 14 | > 15 | > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | > THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Run Dusk tests in Safari 2 | 3 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/appstract/laravel-dusk-safari.svg?style=flat-square)](https://packagist.org/packages/appstract/laravel-dusk-safari) 4 | [![Total Downloads](https://img.shields.io/packagist/dt/appstract/laravel-dusk-safari.svg?style=flat-square)](https://packagist.org/packages/appstract/laravel-dusk-safari) 5 | [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) 6 | [![Build Status](https://img.shields.io/travis/appstract/laravel-dusk-safari/master.svg?style=flat-square)](https://travis-ci.org/appstract/laravel-dusk-safari) 7 | 8 | This package allows you to use the built-in Safari WebDriver of macOS, so you don't need Selenium to run Dusk tests in Safari. 9 | 10 | This requires Safari 10 or higher. 11 | 12 | ## Installation 13 | 14 | You can install the package via composer: 15 | 16 | ``` bash 17 | composer require appstract/laravel-dusk-safari 18 | ``` 19 | 20 | ## Usage 21 | 22 | Make sure to enable Remote Automation in the Safari menu bar: 23 | 24 | ```Develop > Allow Remote Automation.``` 25 | 26 | Add the ``SupportsSafari`` trait to your DuskTestCase: 27 | ```php 28 | use Appstract\DuskDrivers\Safari\SupportsSafari; 29 | 30 | abstract class DuskTestCase extends BaseTestCase 31 | { 32 | use CreatesApplication, SupportsSafari; 33 | } 34 | ``` 35 | 36 | Now you can start the server in the ```prepare``` method: 37 | ```php 38 | public static function prepare() 39 | { 40 | static::startSafariDriver(); 41 | } 42 | ``` 43 | 44 | Instruct Dusk to use Safari by changing ```DesiredCapabilities::chrome()``` 45 | to ```DesiredCapabilities::safari()``` in the Driver method: 46 | 47 | ```php 48 | protected function driver() 49 | { 50 | return RemoteWebDriver::create( 51 | 'http://localhost:9515', DesiredCapabilities::safari() 52 | ); 53 | } 54 | ``` 55 | 56 | ## Contributing 57 | 58 | Contributions are welcome, [thanks to y'all](https://github.com/appstract/laravel-blade-directives/graphs/contributors) :) 59 | 60 | ## About Appstract 61 | 62 | Appstract is a small team from The Netherlands. We create (open source) tools for webdevelopment and write about related subjects on [Medium](https://medium.com/appstract). You can [follow us on Twitter](https://twitter.com/teamappstract), [buy us a beer](https://www.paypal.me/teamappstract/10) or [support us on Patreon](https://www.patreon.com/appstract). 63 | 64 | ## License 65 | 66 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 67 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "appstract/laravel-dusk-safari", 3 | "description": "Run Dusk tests on Safari", 4 | "keywords": [ 5 | "appstract", 6 | "laravel", 7 | "Dusk", 8 | "Safari", 9 | "testing" 10 | ], 11 | "homepage": "https://github.com/appstract/laravel-dusk-safari", 12 | "license": "MIT", 13 | "authors": [ 14 | { 15 | "name": "Olav van Schie", 16 | "email": "hello@appstract.team", 17 | "homepage": "https://appstract.team", 18 | "role": "Developer" 19 | } 20 | ], 21 | "require": { 22 | "php": ">=5.6" 23 | }, 24 | "autoload": { 25 | "psr-4": { 26 | "Appstract\\DuskDrivers\\Safari\\": "src" 27 | } 28 | }, 29 | "config": { 30 | "sort-packages": true 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/SupportsSafari.php: -------------------------------------------------------------------------------- 1 | start(); 25 | 26 | static::afterClass(function () { 27 | static::stopSafariDriver(); 28 | }); 29 | } 30 | 31 | /** 32 | * Stop the Safaridriver process. 33 | * 34 | * @return void 35 | */ 36 | public static function stopSafariDriver() 37 | { 38 | if (static::$safariProcess) { 39 | static::$safariProcess->stop(); 40 | } 41 | } 42 | 43 | /** 44 | * Build the process to run the Safaridriver. 45 | * 46 | * @return \Symfony\Component\Process\Process 47 | */ 48 | protected static function buildSafariProcess() 49 | { 50 | return (new ProcessBuilder()) 51 | ->setPrefix('/usr/bin/safaridriver') 52 | ->add('-p 9515') 53 | ->getProcess(); 54 | } 55 | 56 | /** 57 | * Disable logging for safari. 58 | */ 59 | protected function storeConsoleLogsFor($browsers) 60 | { 61 | return false; 62 | } 63 | } 64 | --------------------------------------------------------------------------------