Last active
March 1, 2019 21:15
-
-
Save eklundkristoffer/25c3e28ab67ad1a07b40b6982b0b5e62 to your computer and use it in GitHub Desktop.
Laravel dusk clearVue & typeVue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Laravel\Dusk\Browser; | |
Browser::macro('clearVue', function ($field) { | |
$field = $this->resolver->resolveForTyping($field); | |
foreach (range(1, strlen($field->getAttribute('value'))) as $index) { | |
$field->sendKeys($this->parseKeys(['{backspace}'])); | |
} | |
return $this; | |
}); | |
Browser::macro('typeVue', function ($field, $value) { | |
$this->clearVue($field); | |
$this->resolver->resolveForTyping($field)->sendKeys($value); | |
return $this; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment