【问题标题】:Removing "This site is attempting to open a pop-up window" on WebDriver (PHP)删除 WebDriver (PHP) 上的“此站点正在尝试打开弹出窗口”
【发布时间】:2020-01-15 20:19:41
【问题描述】:

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

【问题讨论】:

    标签: php selenium-webdriver webdriver facebook-webdriver


    【解决方案1】:

    您可以尝试将功能“nativeWebTap”设置为“true”,然后尝试执行示例测试吗?告诉我进展如何?

    【讨论】:

      猜你喜欢
      • 2014-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-23
      • 2011-10-23
      • 2019-01-07
      • 2011-02-16
      • 2012-12-06
      相关资源
      最近更新 更多