Skip to content

Commit

Permalink
Consistently use WebDriverWait available API for WaitsForElements
Browse files Browse the repository at this point in the history
… trait instead of relying on `Carbon`. (#1062)

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* Apply fixes from StyleCI

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* Apply fixes from StyleCI

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

* Apply fixes from StyleCI

* wip

Signed-off-by: Mior Muhammad Zaki <[email protected]>

---------

Signed-off-by: Mior Muhammad Zaki <[email protected]>
Co-authored-by: StyleCI Bot <[email protected]>
  • Loading branch information
crynobone and StyleCIBot authored Oct 10, 2023
1 parent 3bf31f9 commit ae5a90c
Show file tree
Hide file tree
Showing 3 changed files with 166 additions and 80 deletions.
26 changes: 6 additions & 20 deletions src/Concerns/WaitsForElements.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace Laravel\Dusk\Concerns;

use Carbon\Carbon;
use Closure;
use Exception;
use Facebook\WebDriver\Exception\NoSuchElementException;
use Facebook\WebDriver\Exception\ScriptTimeoutException;
use Facebook\WebDriver\Exception\TimeoutException;
Expand Down Expand Up @@ -394,26 +392,14 @@ public function waitUsing($seconds, $interval, Closure $callback, $message = nul

$this->pause($interval);

$started = Carbon::now();

while (true) {
try {
$this->driver->wait($seconds, $interval)->until(
function ($driver) use ($callback) {
if ($callback()) {
break;
return true;
}
} catch (Exception $e) {
//
}

if ($started->lt(Carbon::now()->subSeconds($seconds))) {
throw new TimeoutException($message
? sprintf($message, $seconds)
: "Waited {$seconds} seconds for callback."
);
}

$this->pause($interval);
}
},
$message ? sprintf($message, $seconds) : "Waited {$seconds} seconds for callback."
);

return $this;
}
Expand Down
4 changes: 2 additions & 2 deletions src/ElementResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class ElementResolver
/**
* Set the elements the resolver should use as shortcuts.
*
* @var array
* @var array<string, string>
*/
public $elements = [];

Expand Down Expand Up @@ -62,7 +62,7 @@ public function __construct($driver, $prefix = 'body')
/**
* Set the page elements the resolver should use as shortcuts.
*
* @param array $elements
* @param array<string, string> $elements
* @return $this
*/
public function pageElements(array $elements)
Expand Down
Loading

0 comments on commit ae5a90c

Please sign in to comment.