Enable and Disable Pop-Ups

Enable or disable pop-ups in your Selenium tests across different browsers

Enable pop-ups

You can enable pop-ups in Chrome, IE and Safari as follows:

Pop-ups are enabled by default (as the pop-up blocker is disabled, by default).

To enable the popups in IE, use the browserstack.ie.enablePopups capability.

caps.setCapability("browserstack.ie.enablePopups", "true");
caps["browserstack.ie.enablePopups] = "true"
desiredCap.SetCapability("browserstack.ie.enablePopups", "true");
caps["browserstack.ie.enablePopups"] = "true"
var capabilities = {
  "browserstack.ie.enablePopups" : "true"
}
$caps["browserstack.ie.enablePopups"] = "true";
$caps->{"browserstack.ie.enablePopups"} = "true";

To enable the popups in Safari, use the browserstack.safari.enablePopups capability.

caps.setCapability("browserstack.safari.enablePopups", "true");
caps["browserstack.safari.enablePopups] = "true"
desiredCap.SetCapability("browserstack.safari.enablePopups", "true");
caps["browserstack.safari.enablePopups"] = "true"
var capabilities = {
  "browserstack.safari.enablePopups" : "true"
}
$caps["browserstack.safari.enablePopups"] = "true";
$caps->{"browserstack.safari.enablePopups"} = "true";

Disable pop-ups

Note:
  • For all browsers except Chrome, the pop-ups are disabled by default.
  • If you have enabled them using the steps in the previous section, remove the code that disables the pop-up blocker to disable popups

Disable pop-ups in Chrome

For Chrome, the pop-up blocker is not enabled by default. To enable the pop-up blocker, create a chromeOptions capability, and pass the disable-popup-blocking as excludeSwitches.

ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("excludeSwitches", "disable-popup-blocking");
caps.setCapability(ChromeOptions.CAPABILITY, options);
caps = Selenium::WebDriver::Remote::Capabilities.chrome
caps["chromeOptions"] = {}
caps["chromeOptions"]["excludeSwitches"] = ["disable-popup-blocking"]
using OpenQA.Selenium.Chrome;

DesiredCapabilities capability;
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.AddAdditionalCapability("excludeSwitches", "disable-popup-blocking");
capability = (DesiredCapabilities)chromeOptions.ToCapabilities();
caps = DesiredCapabilities.CHROME
caps["chromeOptions"] = {}
caps["chromeOptions"]["excludeSwitches"] = ["disable-popup-blocking"]
var capabilities = {
  "browserName" : "chrome",
  "chromeOptions" : {
    "excludeSwitches" : ["disable-popup-blocking"]
  }
}
$chromeoptions = array("excludeSwitches"=>array("disable-popup-blocking"));
$caps = array("platform"=>"WINDOWS", "browserName"=>"chrome", "chromeOptions"=>$chromeoptions);
$caps->{"chromeOptions"} = { "excludeSwitches" => ("disable-popup-blocking") };

We're sorry to hear that. Please share your feedback so we can do better






Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback