问题描述
我有一个用于应用程序的量角器测试套件,该应用程序使用自定义协议处理程序从 iOS Web 视图中传递消息.
I have a Protractor test suite for an application that uses a custom protocol handler to pass messages out of an iOS web view.
使用量角器测试时,如何防止自定义 window.location = "app://doThing";
消息破坏我的测试?它显示打开 xdg-open?"弹出并不继续测试.
When testing it with protractor, how do I prevent the custom window.location = "app://doThing";
message from breaking my tests? It shows the "Open xdg-open?" popup and doesn't continue with tests.
我的量角器配置如下:
exports.config = {
...,
multiCapabilities: [ {
browserName: 'chrome',
chromeOptions: {
args: [ '--lang=en', '--window-size=1024x768' ]
},
specs: 'test-*.js',
} ]
};
推荐答案
我在 Chrome 60 中通过在 chromeOptions 块中设置首选项实现了这一点.
I achieved this in Chrome 60 by setting the preferences inside the chromeOptions block.
exports.config = {
...,
multiCapabilities: [ {
browserName: 'chrome',
chromeOptions: {
args: [ '--lang=en', '--window-size=1024x768' ],
// Replace "app" with your app's custom scheme.
prefs: {
protocol_handler: {
excluded_schemes: {
"app": true
}
}
},
},
specs: 'test-*.js',
} ]
};
在 Chrome 60 之前,我为 Chrome 运行程序强制执行了一个配置文件文件夹.例如,您可以在 Chrome docker 容器中创建一个名为/chrome-profile"的文件夹,然后在其中添加一个名为Default State"的文件,内容如下:
Before Chrome 60, I enforced a profile folder for the Chrome runner. You can do that by having a folder named "/chrome-profile" in the Chrome docker container for example, and adding one file in it named "Default State" with the following content:
{
"protocol_handler": {
"excluded_schemes": {
"app": true
}
}
}
然后,设置 Chrome user-data-dir 标志如下:
And after that, setting the Chrome user-data-dir flags as such:
exports.config = {
...,
multiCapabilities: [{
'browserName': 'chrome',
'chromeOptions' : {
args: ['--lang=en',
'--window-size=1024,768',
'--user-data-dir=/chrome-profile/']
},
specs: ['test-*.js']
}]
};
这篇关于如何禁用量角器的自定义协议处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!