Removing "This site is attempting to open a pop-up window" on WebDriver (PHP)

850 Views Asked by At

I'm testing on BrowserStack using Facebook WebDriver (PHP). I'm testing on iPhone, and when my website opens a URL on a new tab, the popup blocker comes up with the message: "This site is attempting to open a pop-up window". I'm trying to accept the message (or dismiss it), so I can move on and continue the test.

I haven't been able to find a way to get rid of the message. Any clues?

public function setUp()
{
    $browserstack_api_url = 'https://' . BROWSERSTACK_USERNAME . ':' . BROWSERSTACK_ACCESS_KEY . '@' . TESTING_SERVER_URL . '/wd/hub';

    //Capabilities array
    $config = json_decode('{
        "capabilities": {
            "acceptSslCerts": true,
            "browserstack.ie.enablePopups": true,
            "browserstack.safari.enablePopups": true,
            "browserstack.debug": true
        },

        "environments": [{
            "device": "iPhone 8",
            "realMobile": "true",
            "os_version": "11"
        }]
    }');

    //Configure the capabilities
    $capabilities = $this->getCapabilities($config, 0, 'abc');
    $this->web_driver = RemoteWebDriver::create($browserstack_api_url, $capabilities);
}

public function getCapabilities($config, $task_id, $project_name)
{
    //Setup device capabilities
    $caps = $config['environments'][$task_id];
    foreach ( $config['capabilities'] as $key => $value )
    {
            if ( !array_key_exists($key, $caps) )
            {
                    $caps[$key] = $value;
            }
    }

    $caps['project'] = $project_name;
    return $caps;
}

public function testDevelopment()
{
    $url = $this->staging_url;
    $this->web_driver->get($url);
    $this->web_driver->findElement(WebDriverBy::id('zipcode'))->sendKeys('12345');
    $this->web_driver->findElement(WebDriverBy::cssSelector("#continue-btn"))->click(); //This action triggers the popup, and fails
}
1

There are 1 best solutions below

1
On

Can you try setting the capability "nativeWebTap" as "true" and then try executing a sample test? Let me know how it goes?