我正在使用selenium RC的getAttribute
方法来获取SVG元素的颜色。
HTML代码如下:
<div style="width: 600px; height: 350px;">
<svg overflow="hidden" width="600" height="350">
<defs/><circle fill="#F0F8F8" fill-opacity="1.0" stroke="black" stroke-opacity="1.0" stroke-width="1" r="120" cx="300" cy="175"/><circle fill="#00bb00" fill-opacity="1.0" stroke="black" stroke-opacity="1.0" stroke-width="1" r="30" cx="420" cy="175"/>
</svg></div>
getAttribute
方法错误为xpath
。
我使用如下:
getAttribute("//table[@id='View$GraphPanel']//tbody/tr[2]/td/div//[local-name() = 'svg']//[name()='circle'][2]@fill")
错误:
2014-04-24 08:57:25.888 INFO - Command request: getAttribute[xpath=//table[@id='DashboardView$GraphPanel']//tbody/tr[2]/td/div//[local-name() = 'svg']//[name()='circle'][2]@fill, ] on session
2014-04-24 08:57:25.909 INFO - Got result: ERROR: Invalid xpath [2]: //table[@id='DashboardView$GraphPanel']//tbody/tr[2]/td/div//[local-name() = 'svg']//[name()='circle'][2] on session
2014-04-24 08:57:25,910 [main]org.junit.internal.runners.statements.FailOnTimeout: callable terminated == true, isDone == true, isCancelled == false