Skip to content

Instantly share code, notes, and snippets.

@alnutile
Last active July 1, 2016 21:01
Show Gist options
  • Save alnutile/8365634 to your computer and use it in GitHub Desktop.
Save alnutile/8365634 to your computer and use it in GitHub Desktop.
Dealing with Alerts
/**
* @hidden
*
* @Then /^I click on the alert window$/
*/
public function iClickOnTheAlertWindow() {
$this->getMainContext()->getSession()->getDriver()->getWebDriverSession()->accept_alert();
}
/**
* @hidden
*
* @Then /^I switch to popup by clicking "([^"]*)" and clicking alert$/
*/
public function iSwitchToPopupByClickingAndClickingAlert($arg1) {
$originalWindowName = $this->getMainContext()->getSession()->getWindowName(); //Get the original name
$this->setMainWindow();
$this->getMainContext()->getSession()->getPage()->clickLink("$arg1");
$this->iClickOnTheAlertWindow();
$popupName = $this->getNewPopup($originalWindowName);
//Switch to the popup Window
$this->getMainContext()->getSession()->switchToWindow($popupName);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment