Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find button by text exactly #1162

Open
Barbapapazes opened this issue Feb 11, 2025 · 0 comments
Open

Find button by text exactly #1162

Barbapapazes opened this issue Feb 11, 2025 · 0 comments

Comments

@Barbapapazes
Copy link

Dusk Version

8.x

Laravel Version

11.x

PHP Version

8.4

PHPUnit Version

10.x

Database Driver & Version

/

Description

Hello 👋,

The method pressAndWaitFor uses the method findButtonByText (

/**
* Resolve the element for a given button by text.
*
* @param string $button
* @return \Facebook\WebDriver\Remote\RemoteWebElement|null
*/
protected function findButtonByText($button)
{
foreach ($this->all('button') as $element) {
if (Str::contains($element->getText(), $button)) {
return $element;
}
}
}
) that does not try to resolve the button with exactly its name but with a name that contains the parameter. This is an issue when there is multiple button on the page.

For example, you can have the button Create Application and another button Create but you won't be able to target Create because Create Application will always be resolved first (if it appears fist in the DOM).

Steps To Reproduce

  1. Create a button Create Application
  2. Create a button Create
  3. Try to use the method pressAndWaitFor to select the Create but Dusk will try to press Create Application.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant