File: D:/HostingSpaces/SBogers10/helder.komma.pro/app/Komma/QualityAssurance/ExtraDuskTools.php
<?php
namespace App\Komma\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\QualityAssurance
*/
trait ExtraDuskTools
{
public function setupExtraDuskTools()
{
//Helpers
Browser::macro('scrollToElement', function ($element = null) {
$this->script("$('html, body').animate({ scrollTop: $('$element').offset().top }, 0);");
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;
});
}
}