[英]How to find the href inside of an element with cypress?
您還可以使用定位器[data-refid="recordId"]
,調用href
屬性並將其保存在夾具文件中。
cy.get('[data-refid="recordId"]').each(($ele) => {
cy.writeFile('cypress/fixtures/links.txt', $ele.attr('href'), {
flag: 'a+'
})
})
您需要使用invoke
方法。 你最終會得到這樣的結果: cy.get('a').invoke('href')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.