Skip to content

Instantly share code, notes, and snippets.

@eklundkristoffer
Last active March 1, 2019 21:15
Show Gist options
  • Save eklundkristoffer/25c3e28ab67ad1a07b40b6982b0b5e62 to your computer and use it in GitHub Desktop.
Save eklundkristoffer/25c3e28ab67ad1a07b40b6982b0b5e62 to your computer and use it in GitHub Desktop.
Laravel dusk clearVue & typeVue
<?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