V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
sophie2805
V2EX  ›  问与答

driver.findElement By.xpath 就是找不到网页上明明存在的元素,甚至复制了 firebug 里面此元素的 xpath,也找不到这个元素,灵异了??

  •  
  •   sophie2805 · 2015-07-02 16:58:26 +08:00 · 4473 次点击
    这是一个创建于 3220 天前的主题,其中的信息可能已经有所发展或是发生改变。
    http://bbs.wacai.com/thread-651750-1-1.html

    这个页面,我要找下方快速回复那个页面元素

    试过了driver.findElement(By.id("fastpostmessage")).clear(); 找不到

    试过了driver.findElement(By.xpath("//*[@id='fastpostmessage']")).clear(); 找不到

    试过了driver.findElement(By.xpath("/html/body/div[13]/div[4]/div[6]/form/table/tbody/tr/td[2]/div[1]/div[2]/div/div[2]/textarea")).clear(); 找不到,而且这个xpath是我从firebug里面复制出来的

    为什么呢 = =#
    2 条回复    2015-07-02 18:05:40 +08:00
    sophie2805
        1
    sophie2805  
    OP
       2015-07-02 17:00:06 +08:00
    看过了,不存在frame iframe啥的,都是普通的div一路下去
    sophie2805
        2
    sophie2805  
    OP
       2015-07-02 18:05:40 +08:00
    我尝试分步去定位,textarea的父节点都定位到了,但是这个textarea定位不到,是因为textarea里面的那个onkeydown="seditor_ctlent(event, 'fastpostvalidate($(\'fastpostform\'))');" 导致的?

    <div class="area">
    <textarea class="pt" tabindex="4" onkeydown="seditor_ctlent(event, 'fastpostvalidate($(\'fastpostform\'))');" id="fastpostmessage" name="message" cols="80" rows="6"></textarea>
    </div>
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1293 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 17:55 · PVG 01:55 · LAX 10:55 · JFK 13:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.