Skip to content

Commit

Permalink
Fixes waitForTextIn() broken in v7.11.2
Browse files Browse the repository at this point in the history
Signed-off-by: Mior Muhammad Zaki <[email protected]>
  • Loading branch information
crynobone committed Oct 14, 2023
1 parent 6a60371 commit aeee257
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Concerns/WaitsForElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Facebook\WebDriver\WebDriverExpectedCondition;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use PHPUnit\Framework\ExpectationFailedException;

trait WaitsForElements
{
Expand Down Expand Up @@ -124,8 +125,8 @@ public function waitForTextIn($selector, $text, $seconds = null)
$message = 'Waited %s seconds for text "'.$this->escapePercentCharacters($text).'" in selector '.$selector;

return $this->waitUsing($seconds, 100, function () use ($selector, $text) {
return $this->assertSeeIn($selector, $text);
}, $message);
return Str::contains($this->resolver->findOrFail($selector)->getText(), $text);
}, $message)->assertSeeIn($selector, $text);
}

/**
Expand Down Expand Up @@ -394,8 +395,12 @@ public function waitUsing($seconds, $interval, Closure $callback, $message = nul

$this->driver->wait($seconds, $interval)->until(
function ($driver) use ($callback) {
if ($callback()) {
return true;
try {
if ($callback()) {
return true;
}
} catch (ExpectationFailedException $e) {
return false;
}
},
$message ? sprintf($message, $seconds) : "Waited {$seconds} seconds for callback."
Expand Down

0 comments on commit aeee257

Please sign in to comment.