删除WebDriver(PHP)上的“此站点正在尝试打开弹出窗口”

时间:2019-12-25 01:18:20

标签: php selenium-webdriver webdriver facebook-webdriver

我正在使用Facebook WebDriver(PHP)在BrowserStack上进行测试。我正在iPhone上进行测试,当我的网站在新选项卡上打开URL时,弹出窗口阻止程序会显示以下消息:“此站点正在尝试打开弹出窗口”。我正在尝试接受该消息(或将其消除),所以我可以继续并继续测试。

我一直找不到消除消息的方法。有任何线索吗?

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
}

0 个答案:

没有答案