diff --git a/src/Codeception/Lib/InnerBrowser.php b/src/Codeception/Lib/InnerBrowser.php index 5ee79c5..86014a1 100644 --- a/src/Codeception/Lib/InnerBrowser.php +++ b/src/Codeception/Lib/InnerBrowser.php @@ -407,7 +407,10 @@ public function click($link, $context = null): void $anchor = $this->getCrawler()->selectLink($link); } - if (count($anchor) > 0) { + if (count($anchor) > 1) { + throw new TestRuntimeException(count($anchor) . " matching elements found with [$link], try to be more precise about what to click"); + } + if (count($anchor) === 1) { $this->openHrefFromDomNode($anchor->getNode(0)); return; }