Eli
Eli

Reputation: 181

Selenium and SVG

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?

Upvotes: 0

Views: 1839

Answers (2)

Eli
Eli

Reputation: 181

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

Upvotes: 0

Josh Pearce
Josh Pearce

Reputation: 3455

Selenium will allow you to, using JavaScript, get at the properties of any element in the DOM, so something like

var gaugeFill = document.getElementById('mygauge').getAttribute('fill');

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.

Upvotes: 1

Related Questions