【发布时间】:2016-02-05 11:39:12
【问题描述】:
我有一个在 Firefox 中运行的 Capybara/Cucumber 测试,它不会单击 svg 元素。我对其他相同类型的元素进行了等效测试,但 Capybara 告诉我这个特定元素的错误:
Element is not clickable at point (1179.5, 172.96665954589844). Other element would receive the click: <svg height="124" width="290"></svg> (Selenium::WebDriver::Error::UnknownError)
点击的样子:
find("#partner-profit-chart svg g.pie-slice._1").click
实际站点托管在这里http://mrr.devtechlab.com/mrr-dashboard.html,它不会点击的元素是右侧的第三个饼图。我可以单击其他饼图就好了,但不知何故 Selenium 认为它会单击包含仅此图表元素的 SVG ???
编辑: 最终使用以下方法手动单击 d3 元素(jquery click 不适用于 d3 元素仅供参考):
execute_script(
%Q(
jQuery.fn.d3Click = function () {
this.each(function (i, e) {
var evt = new MouseEvent("click");
e.dispatchEvent(evt);
});
};
$("#partner-profit-chart svg g.pie-slice._1 path").d3Click();
)
)
【问题讨论】:
标签: selenium capybara dc.js clickable