From cf04717664f80204567ad3077ea7484a0be16497 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sun, 22 Jan 2023 22:45:17 -0600 Subject: [PATCH] allow custom dusk selector --- src/Dusk.php | 18 ++++++++++++++++++ src/ElementResolver.php | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Dusk.php b/src/Dusk.php index e09a7a511..f4e3e1c49 100644 --- a/src/Dusk.php +++ b/src/Dusk.php @@ -6,6 +6,13 @@ class Dusk { + /** + * The Dusk selector (@dusk) HTML attribute. + * + * @var string + */ + public static $selectorHtmlAttribute = 'dusk'; + /** * Register the Dusk service provider. * @@ -43,4 +50,15 @@ protected static function duskEnvironment($options) return app()->environment(...$options['environments']); } + + /** + * Set the Dusk selector (@dusk) HTML attribute. + * + * @param string $attribute + * @return void + */ + public static function selectorHtmlAttribute(string $attribute) + { + static::$selectorHtmlAttribute = $attribute; + } } diff --git a/src/ElementResolver.php b/src/ElementResolver.php index 92b1d1c71..7f4db8651 100644 --- a/src/ElementResolver.php +++ b/src/ElementResolver.php @@ -410,7 +410,7 @@ public function format($selector) ); if (Str::startsWith($selector, '@') && $selector === $originalSelector) { - $selector = '[dusk="'.explode('@', $selector)[1].'"]'; + $selector = '['.Dusk::$selectorHtmlAttribute.'="'.explode('@', $selector)[1].'"]'; } return trim($this->prefix.' '.$selector);