Skip to content

Commit afd6c71

Browse files
authored
Merge pull request #748 from hivokas/patch-3
[5.x] Adds typeWithPauses(), appendWithPauses() methods
2 parents 8065186 + 4e1e387 commit afd6c71

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/Concerns/InteractsWithElements.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,21 @@ public function type($field, $value)
144144
return $this;
145145
}
146146

147+
/**
148+
* Type the given value in the given field slowly.
149+
*
150+
* @param string $field
151+
* @param string $value
152+
* @param int $pause
153+
* @return $this
154+
*/
155+
public function typeSlowly($field, $value, $pause = 100)
156+
{
157+
$this->clear($field)->appendWithPauses($field, $value, $pause);
158+
159+
return $this;
160+
}
161+
147162
/**
148163
* Type the given value in the given field without clearing it.
149164
*
@@ -158,6 +173,23 @@ public function append($field, $value)
158173
return $this;
159174
}
160175

176+
/**
177+
* Type the given value in the given field slowly without clearing it.
178+
*
179+
* @param string $field
180+
* @param string $value
181+
* @param int $pause
182+
* @return $this
183+
*/
184+
public function appendSlowly($field, $value, $pause = 100)
185+
{
186+
foreach (str_split($value) as $char) {
187+
$this->append($field, $char)->pause($pause);
188+
}
189+
190+
return $this;
191+
}
192+
161193
/**
162194
* Clear the given field.
163195
*

0 commit comments

Comments
 (0)