我試圖用硒模塊,採用硒服務器獨立-2.39.0的Firefox版本27.0 IM來自動perl的Web應用程序,硒返回錯誤元件,而XPath是存在於網頁代碼
而我跑我的劇本我在這行
$sel->click_ok("//g[contains(\@class,'highcharts-series-group')]//rect");
得到錯誤
這種情況的HTML是:
<g class="highcharts-series-group" zIndex="3">
<g class="highcharts-series highcharts-tracker highcharts-tracker" visibility="visible" zIndex="0.1" transform="translate(27,20) scale(1 1)" style="cursor:pointer;" clip-path="url(#highcharts-347)">
<rect fill="rgb(86,161,220)" x="478" y="34" width="25" height="167" fill-opacity="1" rx="4" ry="4">
</g>
<g class="highcharts-markers" visibility="visible" zIndex="0.1" transform="translate(27,20) scale(1 1)">
</g>
i am getting error : ERROR: Element //g[contains(@class,'highcharts-series-group')//rect] not found
在此先感謝
樣本:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<script type="text/javascript">
var rand="1390977827";
</script>
</head>
<body class="rdx_auto_cursor">
<div class="chart" data-highcharts-chart="1">
<div id="highcharts-2" class="highcharts-container" style="position: relative; overflow: hidden; width: 1029px; height: 250px; text-align: left; line-height: normal; z-index: 0; font-family: "Lucida Grande","Lucida Sans Unicode",Verdana,Arial,Helvetica,sans-serif; font-size: 12px; left: 0.199997px; top: 0.199997px;">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="1029" height="250">
<desc>Created with Highcharts 3.0.2</desc>
<defs>
<clipPath id="highcharts-3">
<rect fill="none" x="1" y="1" width="980" height="198">
</rect>
</clipPath>
</defs>
<g class="highcharts-series-group" zIndex="3">
<g class="highcharts-series highcharts-tracker highcharts-tracker highcharts-tracker" visibility="visible" zIndex="0.1" transform="translate(27,20) scale(1 1)" style="cursor:pointer;" clip-path="url(#highcharts-3)">
<rect fill="rgb(86,161,220)" x="478" y="100" width="25" height="100" fill-opacity="1" rx="4" ry="4">
</rect>
</g>
<g class="highcharts-markers" visibility="visible" zIndex="0.1" transform="translate(27,20) scale(1 1)">
</g>
</g>
</svg>
</div>
</body>
</html>
包含不是必需的,如果你使用的是整個班級名稱......只要'''''''class ='highcharts-series-group'] // rect' would ... – Amith
@amith即使我不要使用包含然後也給它同樣的錯誤。 – hims15
@amith我會一直使用包含在xpath中使用類時,因爲可以添加和刪除類。與css選擇器不同,xpath將類視爲字符串而不是值的集合 –