File: D:/HostingSpaces/slenders/slenders.nl/app/Komma/Kms/QualityAssurance/ExtraDuskTools.php
<?php
namespace App\Komma\Kms\QualityAssurance;
use Laravel\Dusk\Browser;
/**
* Trait ExtraDuskTools
*
* Notice. only works with laravel 5.7.
* Include it in your service provider boot method
*
* @package App\Komma|Kms\QualityAssurance
*/
trait ExtraDuskTools
{
public function setupExtraDuskTools()
{
//Helpers
Browser::macro('scrollToElement', function ($element = null) {
// $this->script('document.querySelector("'.$element.'").scrollIntoView()');
$this->script('document.querySelector(\''.$element.'\').scrollIntoView({ behavior: \'smooth\' });');
return $this;
});
//Assertions
/**
* Extend the dusk browser with a method that can count elements
*/
Browser::macro('assertElementsCountIs', function(int $count, string $selector) {
PHPUnit::assertEquals( $count, count($this->elements( $selector )));
return $this;
});
}
}