Closed MatthieuMan closed 4 years ago
Sounds like what you want to do should work.
Can you share a minimal example of your code that isn't working as expected?
Hi, There it is I'd like to click on a input tag which trigger an action in javascript.
$link = $crawler
->filter('input#gaCookiesSwitchButton')
->link()
;
$client->click($link);
but it seems that we cannot navigate from a "input" tag.
**
* @author Kévin Dunglas <dunglas@gmail.com>
*/
final class Link extends BaseLink
{
use ExceptionThrower;
private $element;
public function __construct(WebDriverElement $element)
{
$tagName = $element->getTagName();
if ('a' !== $tagName && 'area' !== $tagName && 'link' !== $tagName) {
throw new \LogicException(\sprintf('Unable to navigate from a "%s" tag.', $tagName));
}
$this->element = $element;
$this->method = 'GET';
}
So is there another way to perfom an action on these tags?
Thanks a lot!!
@MatthieuMan Indeed \Symfony\Component\Panther\Client::click requires argument of type \Symfony\Component\DomCrawler\Link - so seems not good for clicking input element.
Can you try maybe this instead? :
$client->getMouse()->clickTo($cssSelector);
See: \Symfony\Component\Panther\WebDriver\WebDriverMouse::clickTo
@MatthieuMan Using the crawler to get a WebDriverElement
instance and clicking directly on that should suffice:
$inputCrawler = $crawler->filter('input#gaCookiesSwitchButton');
$inputElement = $inputCrawler->first();
$inputElement->click();
The above example is a perhaps a little verbose in order to be more clear.
@domis86
$client->getMouse()->clickTo($cssSelector);
works perfectly thank you
@webignition thanks, it works as well, that's said, more verbose yes.
Thank you guys !!
Hi,
Is there a way to clic on any tag like
<input>
except<a>
and do not get aLogicException: Unable to navigate from a "input" tag.
?Thanks