2012-03-23 53 views
0

我嘗試使用python驗證RC: sel.is_element_present(「// div [@ id ='USER_PHOTOS']/div [1]/span [1]/img ) 但看起來像不能正確。 並試圖這樣: sel.is_element_present(「// div [@ id ='USER_PHOTOS']) 它的工作原理。 沒有人爲什麼不能在這裏找到副標誌:selenium無法在firefox上找到html元素

<div class="bx01 deals swirllinks"> 
<div id="USER_PHOTOS" class="bx01"> 
<div class="ug_photos"> 
    <span class="u_/LocationPhotos-g294212-d1234659-Fairmont_Beijing-Beijing.html#41195738 fkASDF fkLnk" onclick="setPID(3901); return ta.call('ta.overlays.Factory.photosLB', event, this);"> 
     <img class="ug_photo" alt="coffee machine" src="http://ccm.ddcdn.com/ext/photo-l/02/5d/7c/f6/coffee-machine.jpg"/> 
    </span> 
    <span class="u_/LocationPhotos-g294212-d1234659-Fairmont_Beijing-Beijing.html#41195739 fkASDF fkLnk" onclick="setPID(3901); return ta.call('ta.overlays.Factory.photosLB', event, this);"> 
     <img class="ug_photo" alt="bathroom" src="http://ccm.ddcdn.com/ext/photo-l/02/5d/7c/f7/bathroom.jpg"/> 
    </span> 

回答

0

在你的XPath - // DIV [@ ID = 'USER_PHOTOS'] /DIV [1]/SPAN [1]/IMG ,硒將在 div id = USER_PHOTOS下查找div 。您的跨度不來下「USER_PHOTOS」其下的<div class="ug_photos">

您應該使用//div[@class='ug_photos']//span[1]/img

相關問題