我已经在我的网站上实现了打印功能,我想通过量角器/硒对其进行测试.
I've implemented an print functionallity at my site, and I would like to test it via protractor / selenium.
在测试期间有什么方法可以应用" @media print 下的样式?
There is any method to "apply" the styles that are under @media print during the test?
我只看到了一个相关的问题,但它没有任何好的答案.
I saw only one relevant question, but it without any good answer.
例如在那个示例中,我希望 #hidden div 将在测试期间显示.
For example at that sample I would like to the #hidden div will be shown during the test.
.print-only {
display: none;
}
@media print {
.print-only {
display: block;
}
}
<div id="hidden" class="print-only">Will be shown when printing</div>
我发现的一个选项是将所有打印" css 拆分为一个单独的文件,并通过 link 加载它带有 media="print" 的标签.
One option that I've found is to split all the "print" css into a separate file, and load it via link tag with media="print".
<link rel="stylesheet" type="text/css" href="print.css" media="print">
意思是根本不在大型css文件中使用媒体查询.
Meaning not to use media query inside large css file at all.
这样我可以在测试期间通过 executeScript 将 media="print" 属性更改为 all.
That way will allow me to change the media="print" attribute during test to all via executeScript.
希望对某人有所帮助.
这篇关于如何用量角器或硒测试@media print?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
ionic - 如何在 ion-header 中对长字符串进行自动换行ionic - How to wordwrap a long string in ion-header(ionic - 如何在 ion-header 中对长字符串进行自动换行)
如何在角度2中动态更改css类名How to change the css class name dynamically in angular 2(如何在角度2中动态更改css类名)
使用模态和样式的 Ionic 2 登录弹出窗口Ionic 2 login popup using Modal and styling(使用模态和样式的 Ionic 2 登录弹出窗口)
如何在ionic 3中进行水平滚动how to do horizontal scroll in ionic 3(如何在ionic 3中进行水平滚动)
与另一个离子卡重叠的虚拟滚动 ion-img 标签Virtual scroll ion-img tag overlapping to another ion card(与另一个离子卡重叠的虚拟滚动 ion-img 标签)
如何删除输入类型中的默认颜色?How to remove default color in input type?(如何删除输入类型中的默认颜色?)