我们可以在剧作家中为GEO位置运行基于IP的测试吗?

发布于 2025-02-04 16:18:54 字数 81 浏览 5 评论 0原文

剧作家使用纬度和经度提供地理位置支持,但是它仅更改客户端的位置。在我的用例中,我需要IP地址需求以及API和URL,因此请根据IP地址获取和渲染内容

Playwright provides geolocation support using latitude and longitude, however it only changes location at client. In my use-case, I need IP address needs along with APIs and urls so fetch and render content based on IP address

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以为你会在 2025-02-11 16:18:54

剧作家的地理位置支持是关于模拟客户端的地理位置的,如下文:

const context = await browser.newContext({
  geolocation: { longitude: 52.3456, latitude: 5.6789},
  permissions: ['geolocation']
});

由于您无法控制服务器,因此无法更改服务器的地理位置。您唯一可以做的就是模拟服务器响应,但是这样您就不会测试实际的服务器行为,这似乎是您想要的。

Playwright geolocation support is about emulating the geographic location of the client, as diplayed below:

const context = await browser.newContext({
  geolocation: { longitude: 52.3456, latitude: 5.6789},
  permissions: ['geolocation']
});

It is not possible to change the geolocation of the server, since you don't have control over the server. The only thing you can do is mock the server response, but that way you're not testing the actual server behavior, which seems to be what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文