Is there a way to bypass Chrome geolocation dialog in Protractor tests?

十年热恋 提交于 2019-12-25 01:38:47

问题


I faced this problem, when automating an application with protractor.

Once I open a home page I get geolocation dialog with Block/Allow buttons, which didn't let proceed without selection either option

It turned out, that this dialog is not an instance of alert, that's why browser.switchTo().alert().confirm() didn't work

Passing '--disable-notifications' argument to Chrome also didn't solve the problem

Research online didn't give any positive results. How to solve it?


回答1:


The solution to the problem is to pass "prefs": {'profile.default_content_setting_values.geolocation': 2} to capabilities object in your protractor.config.js

Below is another option that does pretty much the same thing.

So chrome may take an argument --user-data-dir=/tmp/chrome which specifies profile to open chrome with. If profile doesn’t exist at specified directory it creates default one. Then if you open /tmp/chrome/Default/Preferences you’ll see an object with preferences. You needed to set default_content_setting_values.geolocation to 2 (not 1 or 0) to make it NOT prompt that dialog



来源:https://stackoverflow.com/questions/55731421/is-there-a-way-to-bypass-chrome-geolocation-dialog-in-protractor-tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!