arrow_back
我已尝试使用以下代码但不起作用。对于 chrome,它表示超时。 对于边缘,它不关注后退按钮,而是关注文本框。
请帮我解决这个问题。
Chrome :
cy.get('#asset-categories>div:nth-child(2)>div:nth-child(1)>div:nth-child(1)>button')
.trigger('mouseover').invoke('show')
cy.contains('Back to asset categories')
边缘:
cy.get('#asset-categories>div:nth-child(2)>div:nth-child(1)>div:nth-child(1)>button')
.focused().realHover()
cy.contains('Back to asset categories')
If I hover the back button, "Back to asset categories" will be displayed.
最佳答案
在我的例子中,我必须在将鼠标悬停在按钮上时显示工具提示。它对我有用。我正在验证颜色,您可以根据您的要求进行编辑。我的代码如下:
describe('color', () => {
it('should have correct background color', () => {
cy.get('[data-cy="button"]').realHover();
cy.get('.mat-tooltip')
.should('have.css', 'background-color', 'rgb(111, 111, 111)');
});
it('should have correct text color', () => {
cy.get('[data-cy="button"]').realHover();
cy.get('.mat-tooltip')
.should('have.css', 'color', 'rgb(255, 255, 255)');
});
});
https://stackoverflow.com/questions/68161473/