Skip to content

Commit

Permalink
Allow dusk attribute selectors to be chained (#1034)
Browse files Browse the repository at this point in the history
* Allow `dusk` attribute selectors to be chained

* Add test
  • Loading branch information
JayBizzle authored Apr 13, 2023
1 parent 67ec16b commit 836338e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
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::$selectorHtmlAttribute.'="'.explode('@', $selector)[1].'"]';
$selector = preg_replace('/@(\S+)/', '['.Dusk::$selectorHtmlAttribute.'="$1"]', $selector);
}

return trim($this->prefix.' '.$selector);
Expand Down
1 change: 1 addition & 0 deletions tests/ElementResolverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public function test_format_correctly_formats_selectors()
$this->assertSame('prefix #second', $resolver->format('@modal-second'));
$this->assertSame('prefix #first-third', $resolver->format('@modal-third'));
$this->assertSame('prefix [dusk="missing-element"]', $resolver->format('@missing-element'));
$this->assertSame('prefix [dusk="missing-element"] > div', $resolver->format('@missing-element > div'));
}

public function test_find_by_id_with_colon()
Expand Down

0 comments on commit 836338e

Please sign in to comment.