Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle a javascript alert window using PHP behat/mink selenium2 chrome webdriver

When testing I get a javascript alert box and I try closing it but I get error unexpected alert open: {Alert text : OK to remove this exclusion?}

I am trying to use:

$this->driver = new Selenium2Driver('chrome');
$this->driver->getWebDriverSession()->accept_alert();

What is the proper way to use PHP behat/mink selenium2 chrome webdriver to close an alert box?

Using Behat 3.2.0 mink 1.7.1

like image 574
kingpinzs Avatar asked Jan 20 '26 06:01

kingpinzs


1 Answers

Could you check with this

$this->getSession()->getDriver()->getWebDriverSession()->accept_alert();

or

Could you try updating ConfirmPopup function in featureContext.php file as follows

public function iConfirmPopup()
{
$this->getMainContext()->getSession()->getDriver()->getWebDriverSession()->accept_alert();
}

add this in featureContext.php file

Reference Link solution to use alert(), confirm() and prompt() in Selenium2Driver

like image 183
vickisys Avatar answered Jan 21 '26 18:01

vickisys



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!