Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser.php
Show First 20 Lines • Show All 180 Lines • ▼ Show 20 Lines | class Browser extends \Laravel\Dusk\Browser | ||||
public function removeDownloadedFile($filename) | public function removeDownloadedFile($filename) | ||||
{ | { | ||||
@unlink(__DIR__ . "/Browser/downloads/$filename"); | @unlink(__DIR__ . "/Browser/downloads/$filename"); | ||||
return $this; | return $this; | ||||
} | } | ||||
/** | /** | ||||
* Clears the input field and related vue v-model data. | |||||
*/ | |||||
public function vueClear($selector) | |||||
{ | |||||
if ($this->resolver->prefix != 'body') { | |||||
$selector = $this->resolver->prefix . ' ' . $selector; | |||||
} | |||||
// The existing clear(), and type() with empty string do not work. | |||||
// We have to clear the field and dispatch 'input' event programatically. | |||||
$this->script( | |||||
"var element = document.querySelector('$selector');" | |||||
. "element.value = '';" | |||||
. "element.dispatchEvent(new Event('input'))" | |||||
); | |||||
return $this; | |||||
} | |||||
/** | |||||
* Execute code within body context. | * Execute code within body context. | ||||
* Useful to execute code that selects elements outside of a component context | * Useful to execute code that selects elements outside of a component context | ||||
*/ | */ | ||||
public function withinBody($callback) | public function withinBody($callback) | ||||
{ | { | ||||
if ($this->resolver->prefix != 'body') { | if ($this->resolver->prefix != 'body') { | ||||
$orig_prefix = $this->resolver->prefix; | $orig_prefix = $this->resolver->prefix; | ||||
$this->resolver->prefix = 'body'; | $this->resolver->prefix = 'body'; | ||||
Show All 11 Lines |