简体   繁体   English

如何使用slimerJS允许访问浏览器地理位置API?

[英]How to allow access to the browsers geolocation API using slimerJS?

I am trying to access a website using SlimerJS. 我正在尝试使用SlimerJS访问网站。 On the website you can not proceed without allowing access to the browsers geolocation API. 在网站上,您必须先访问浏览器地理位置API,然后才能继续。 Its the popup that appears when to click allow. 单击允许时出现的弹出窗口。

Is there any way to allow and provide a geolocation to this website using SlimerJS? 有什么方法可以使用SlimerJS允许并提供对该网站的地理位置?

It seems like you can't just tell the browser to send a specific position. 似乎您不能仅仅告诉浏览器发送特定位置。 But the code of your webpage under test uses the window.navigator object to get the location. 但是您被测网页的代码使用window.navigator对象来获取位置。 So if you manage to somehow change or fake window.navigator.geolocation your problem should be solved. 因此,如果您设法以某种方式更改或伪造window.navigator.geolocation则应解决问题。

Check this answer where Artjom points out on how to use casper.js to proxy the window.navigator.appName object. 检查此答案 ,Artjom指出如何使用casper.js代理window.navigator.appName对象。 It should be possible to adapt that to your problem with the window.navigator.geolocation object. 使用window.navigator.geolocation对象应该可以使其适应您的问题。

Also this issue might be of your interest. 同样,您可能会感兴趣此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM