For people using Laravel Dusk (and in my case I wanted to click a Facebook modal to test a federated login via Socialite):
use Facebook\WebDriver\WebDriverBy;
$confirmationButton = $browser->driver->findElement(WebDriverBy::cssSelector('.layerConfirm'));
$browser->driver->executeScript("arguments[0].click();", [$confirmationButton]);
This seemed to force the click even though previously screenshots from Dusk were showing that a dark (mostly black) translucent layer was hovering over the whole screen, preventing any clicks (even though in normal non-Dusk attempts, everything in the browser looked fine).
See also:
P.S. I also later realized that the Facebook modal had a fancy gradual transition when it was inflating / appearing, so it seems that $browser->waitFor('.layerConfirm', 4)
was firing prematurely, so I thought I could instead just use pause(2000)
to force it to wait a full 2 seconds for the transition to complete (and then wouldn't need to use executeScript
at all). But no amount of pause let the modal become fully visible and clickable.