量角器:单击SVG元素不起作用 [英] Protractor: Click on SVG element not work

查看:123
本文介绍了量角器:单击SVG元素不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用量角器测试angularjs应用.

I am testing an angularjs App using protractor.

我需要测试对SVG元素的点击.

I need to test the click on an SVG element.

量角器可以找到该元素,它可以对元素进行单击,但是单击之后什么也没有发生.

Protractor can find the element, it can run the click on the element, but after the click nothing happens.

单击后应更改页面.

代码是

el=element(by.xpath('(//*[local-name()="g" ]//*[local-name() = "rect"])[1]'))
    browser.actions().mouseMove(el.getWebElement()).click().perform();

推荐答案

这仍然是一个问题.根据github问题,应使用browser.actions().以下解决方案终于为我解决了:

This is still an issue. According to github issues browser.actions() should be used. Following solution finally worked out for me:

await browser.driver.actions().mouseMove(element(by.css('YOUR_LOCATOR')).getWebElement()).perform();
await browser.actions().click().perform();

https://github.com/angular/protractor/issues/2272

https://github.com/angular/protractor/issues/4495

这篇关于量角器:单击SVG元素不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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