0

我正在使用 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
}
4

1 回答 1

0

您可以尝试将功能“nativeWebTap”设置为“true”,然后尝试执行示例测试吗?让我知道事情的后续?

于 2020-01-15T12:19:41.657 回答