硒和 SVG
我有一个使用 SVG 仪表的 Web 应用程序。该仪表显示我的网格(几台机器)的健康状态。
仪表有 3 种颜色:绿色、黄色和红色。
我希望能够编写一个测试来确保该仪表正确地表示数据。也就是说,我的测试将计算预期的网格健康值并确保仪表指向适当的区域。
使用 Selenium 2.0 可以吗?
I have a web application that uses an SVG gauge in it. this gauge displays the health status of my grid (several machines).
The gauge has 3 colors: green, yellow, and red.
I want to be able to write a test that ensures that this gauge represents data correctly. That is, my test will calculate the expected grid health value and make sure the gauge points to the appropriate area.
Is this possible using Selenium 2.0?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Selenium 将允许您使用 JavaScript 获取 DOM 中任何元素的属性,因此类似的内容
将为您提供填充颜色,但它可能会返回为:“rgb(255,0,0)”(表示红色)。您必须检查它,并相应地设置比较逻辑。
另外,您没有说明如何渲染 SVG。有很多方法......我所描述的适用于现代浏览器,其中 SCV 元素是 DOM 的直接一部分,但对于较旧的浏览器或如果您使用 Raphael 的东西则情况并非如此。
Selenium will allow you to, using JavaScript, get at the properties of any element in the DOM, so something like
will get you the fill color, but it may come back like: "rgb(255,0,0)" for Red. You'll have to inspect that, and set up your compare logic accordingly.
Also, you didn't say how you're rendering the SVG. There are so many ways... What I described works for modern browsers where the SCV elements are straight up part of the DOM, but that's not the case for older browsers or if you're using something Raphael.
所以我想,我还没有测试过......
svg 元素出现在圆顶中就像
所以我可以一直走下去,直到找到我需要的属性..在我的例子中,女巫是变换。该属性是使用 GWT 生成的。您还可以使用 GWT 分配 id,这使得整个过程变得更加简单
So i figured it out i think, didnt test it yet...
the svg elements appear in the dome as simply as
and so i can just walk about it till i find the attribute i need..witch is tranform in my case. this attribute is generated using GWT. you can also assign id's using GWT witch makes the process a whole lote simpler