문제

I try to verifiy in selenium RC with python: sel.is_element_present("//div[@id='USER_PHOTOS']/div[1]/span[1]/img) but looks like can not get it right. and tried this: sel.is_element_present("//div[@id='USER_PHOTOS']) it works. did anyone why it can't find the sub tag here:

<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>
도움이 되었습니까?

해결책

In your xpath - //div[@id='USER_PHOTOS']/div[1]/span[1]/img , selenium will look for a div under div id = USER_PHOTOS. Your span doesn't come under "USER_PHOTOS" its under the <div class="ug_photos">

You should use //div[@class='ug_photos']//span[1]/img

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top