使用capybara-webkit在Google地图中单击叠加标记 [英] Click overlay marker in Google Maps with capybara-webkit

查看:62
本文介绍了使用capybara-webkit在Google地图中单击叠加标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过capybara-webkit单击Google地图叠加层?那水豚用硒呢?选择标记后,我想测试信息窗口的内容。我还想测试页面上是否有 n 个标记。

Is there a way to click a Google Maps overlay with capybara-webkit? What about Capybara using Selenium? I want to test the content of the info window once the marker is selected. I also want to test that there are n markers on the page.

推荐答案

这可以做到,但需要更改创建标记的方式。您必须指示它们呈现为图像而不是画布元素:

This can be done, but requires a change to how you create your markers. You must instruct them to render as images rather than canvas elements:

new google.maps.Marker({
  position:  latLng,
  animation: google.maps.Animation.DROP,
  name:      business.get('name'),
  id:        business.get('id'),
  optimized: false, // <-- this is the stuff
  title:     business.get('name')
});

然后在测试中,您可以 find('div [title = Business\ Title]')。click

Then in your test, you can find('div[title="Business\ Title"]').click

如果可能的话,您可能会考虑仅在测试环境中这样做,但这就是满足您和您的需求。

If possible, you might want to consider doing this just for a test environment, but that's up to you and your needs.

信用: http://blog.mojotech.com/selecting-google-maps-v3-markers-with-selenium-or-jquery/

希望这会有所帮助!

这篇关于使用capybara-webkit在Google地图中单击叠加标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆