這是我的元素的代碼
<input type="text" class="nameOfClass" id="someid" name="somename" maxlength="255" placeholder="justholder" ng-model="model" tooltip-placement="top" tooltip-trigger="mouseenter" tooltip-animation="false" style="">
如您所見,沒有屬性值,但我可以清楚地看到我正在嘗試自動化的 Web 應用程式的該文本欄位中有文本。
所以我的問題是,我不知道如何獲取文本欄位的值。我試過谷歌瀏覽器檢查器來查找價值在哪里,但沒有任何運氣。在我讀到的某處,快取可能會導致此問題,但在網路控制臺中,我可以看到請求回應中的值。
謝謝
uj5u.com熱心網友回復:
假設要獲取文本欄位中寫入的值,可以通過呼叫val.
cy.get('#someid')
.invoke('val')
.then((value) => {
cy.log(value) //logs the value
})
如果要對值應用任何斷言,可以:
cy.get('#someid').should('have.value', 'your-value')
uj5u.com熱心網友回復:
如果您指的是type="text",那不是用戶輸入的文本 - 它是一個屬性,告訴輸入允許哪些值。
你也可以有type="number", type="date", type="color",等等
檢查輸入是否為“文本”型別將通過此完成,
cy.get('input#someid').should('have.attr', 'type', 'text')
檢查 value 屬性將像這樣完成
cy.get('input#someid')
.type('entering a value') // there's nothing in value yet
.should('have.value', 'entering a value')
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/422896.html
標籤:
上一篇:在非bean類中使用@Slf4j
