我们如何使用 Chrome 中的 webdriver 运行自动化测试来测试也应该在离线模式下工作的应用程序?
我尝试添加 ' profile['network.manage-offline-status'] = true' 但这似乎并未将 chrome 浏览器转为离线模式
profile = Selenium::WebDriver::Chrome::Profile.new
profile['default_search_provider.enabled'] = false
profile['network.manage-offline-status'] = true
profile['homepage'] = 'about:blank'
I have tried adding ' profile['network.manage-offline-status'] = true' but this doesn't seem to be turning the chrome browser to offline mode
profile = Selenium::WebDriver::Chrome::Profile.new
profile['default_search_provider.enabled'] = false
profile['network.manage-offline-status'] = true
profile['homepage'] = 'about:blank'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
谷歌搜索该配置文件设置,看起来这只是 Firefox 设置,因此对 Chrome 实例没有影响。
阅读一些有关 Chrome 的信息,似乎没有简单的选项可以进入“离线模式”。
您可以通过 watir-webdriver 手动断开计算机与 Internet 的连接来测试功能,但这对于自动化测试来说并不是一个好的解决方案。
Googling that profile setting, it looks like it's only a Firefox setting, so will have no effect on an instance of Chrome.
Reading a little about Chrome, it appears there is no simple option for going into an "offline mode".
You could test the functionality through watir-webdriver by manually disconnecting your computer from the Internet, but that's not a good solution for automated tests.
如果您使用 Chrome 浏览器和 java selenium 那么下面是我使用的代码:
“app.isConnected = true;” : 是我用来转到离线然后返回在线的控制台命令
if you are using Chrome browser and java selenium then below is the code which I have used:
"app.isConnected = true;" : is the console command which I am using to goto Offline and then back to Online