技术改变人生!

selenium XPath使用心得

上一篇 / 下一篇  2013-01-17 18:18:56 / 个人分类:selenium

<html>
<body>
<div class="dropdownlist">
<select name="childVariationASIN" style="width:180px;">

<option value="" selected="selected" title="Select">Select</option>
<option value="B002VYJB5S" title="59 mm :: 101/13 Gold-Cream/Brown Gradient">Gold-Cre...</option>
<option value="B00193CBMM" title="59 mm :: 103/11 Gunmetal-Grey/Grey Gradient">Gunmetal...</option>
<option value="B003ENRWHE" title="59 mm :: 103/13 Gunmetal-Grey/Brown">Gunmetal...</option>

</select>
</div>
<div id='selected_product_name'>
Gold-Cream/Brown Gradient
<div>

</body>
</html>

 

 

 

答案:用xpath获取元素值

<xpath expression=
"//select[@ name='childVariationASIN']
          /option[@value!=''
                and
                 @title[contains(.,//div[@id='selected_product_name']/text())

"
>


TAG:

 

评分:0

我来说两句

Open Toolbar