【问题标题】:selenium can not find html element on firefoxselenium 在 Firefox 上找不到 html 元素
【发布时间】:2012-03-23 03:05:52
【问题描述】:

我尝试使用 python 在 selenium RC 中进行验证: sel.is_element_present("//div[@id='USER_PHOTOS']/div[1]/span[1]/img) 但看起来无法正确。 并尝试了这个: sel.is_element_present("//div[@id='USER_PHOTOS']) 有用。 有没有人为什么在这里找不到子标签:

<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>

【问题讨论】:

    标签: python firefox selenium rc


    【解决方案1】:

    在您的 xpath - //div[@id='USER_PHOTOS']/div[1]/span[1]/img 中,selenium 会在 下强> div id = USER_PHOTOS。您的跨度不属于“USER_PHOTOS”属于&lt;div class="ug_photos"&gt;

    你应该使用//div[@class='ug_photos']//span[1]/img

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-24
      • 1970-01-01
      • 2018-01-24
      • 1970-01-01
      • 2017-05-02
      • 2019-01-02
      • 2021-03-14
      相关资源
      最近更新 更多