sophie2805
V2EX  ›  问与答

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

  •  
  •   sophie2805 · Jul 2, 2015 · 5474 views
    This topic created in 4011 days ago, the information mentioned may be changed or developed.
    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 replies    2015-07-02 18:05:40 +08:00
    sophie2805
        1
    sophie2805  
    OP
       Jul 2, 2015
    看过了,不存在frame iframe啥的,都是普通的div一路下去
    sophie2805
        2
    sophie2805  
    OP
       Jul 2, 2015
    我尝试分步去定位,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>
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1527 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 16:37 · PVG 00:37 · LAX 09:37 · JFK 12:37
    ♥ Do have faith in what you're doing.