在我的電子商務頁面上,商品的價格降低了。
它顯示舊價格被剔除(600.00 歐元)和新價格未被剔除(499.00 歐元)。
但是當我查詢頁面時,我只得到文本值
cy.get('#normalprice span')
.invoke('text')
.should('eq', '600.00€`)
如何測驗文本是否被洗掉?我期待<s>600.00€</s>但cy.get('#normalprice span s')失敗了。
uj5u.com熱心網友回復:
很可能它是text-decoration用來做洗掉線的。
嘗試獲取 CSS 值,
cy.contains('span', '600.00€')
.invoke('css', 'text-decoration')
.should('contain', 'line-through')
洗掉線也可以應用于父級,因此您可能需要添加一個.parents()選擇器
cy.contains('span', '600.00€')
.parents('div') // inspect to see where the CSS is applied
.invoke('css', 'text-decoration')
.should('contain', 'line-through')
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/489527.html
上一篇:如何用燒瓶添加css?
