2017-02-22 60 views
0

我有這樣一個DOM:無法找到一個方法來挖掘()這個元素(WD,的NodeJS)

<form id="frmResendPassword" role="form" method="post"> 
    <div class="form-group">...</div> 
    <span class="pull-right"> 
    <button type="submit" class="btn btn-sm btn-default"> 
    Resend Password</button> 
    </span> 
</form> 

我想輕按「重新發送密碼」按鈕。

我已經嘗試了許多不同的選擇,如:

elementByClassName("btn-default") 
elementById("frmResendPassword") 
elementByName("Resend Password") 
elementByCss(thecsspath) 

ECT ....他們沒有執行tap() ... 但是他們不扔一個元素沒有發現錯誤.... 所以我很困惑。可有一個人請幫助

更新: 下面是基本的自動化代碼...它非常基本

it("should send text to phone", function(){ 
    sleep.sleep(5) 
    return browser 
    .elementByName("mobileNo") 
    .sendKeys(usrnme) 
    .elementByCss("#frmResendPassword button[type=submit]") 
    .tap() 
}) 

這類型的細手機號碼,但它似乎忽略按下按鈕。

+0

?什麼是'thecsspath'?除了'elementByClassName(「btn-default」)'',你的其他選擇器抓取了錯誤的元素,但是這也可能抓住不同的按鈕。 – mrfreester

回答

1

我的猜測是選擇器是問題。試試這個:

elementByCss("button[type=submit]") 

,或者如果不唯一標識,也許這:

elementByCss("#frmResendPassword button[type=submit]") 

在英語中,這意味着一個buttontype價值的submit具有form其中的祖先id#)是frmResendPassword

+0

都沒有工作,有沒有其他的想法?即時通訊認真堅持這個簡單的任務 –

+0

也我更新,包括一個代碼段 –

+0

好吧,我改變了.tap()到.click(),它的工作 –

1

這就是我解決它的方法,這要感謝mrfreester

it("should send text to phone", function(){ 
sleep.sleep(5) 
return browser 
.elementByName("mobileNo") 
.sendKeys(usrnme) 
.elementByCss("#frmResendPassword button[type=submit]") 
.click() 

})是您使用的代碼來調用`龍頭()`

相關問題