Skip to content

Commit

Permalink
allow custom dusk selector
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jan 23, 2023
1 parent b4ac276 commit cf04717
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/Dusk.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

class Dusk
{
/**
* The Dusk selector (@dusk) HTML attribute.
*
* @var string
*/
public static $selectorHtmlAttribute = 'dusk';

/**
* Register the Dusk service provider.
*
Expand Down Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion src/ElementResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cf04717

Please sign in to comment.