尝试在Firefox中通过iframe打印pdf

时间:2019-05-14 09:55:22

标签: selenium iframe

尝试通过iframe打印PDF

WebDriverWait wait_iframe = new WebDriverWait(driver, 20000);
wait_iframe.until(ExpectedConditions.visibilityOfElementLocated((By.id("printpdf"))));

预期结果是账单pdf打印应该在屏幕上可见,但实际输出会引发错误消息,即错误:拒绝访问属性“ print”的权限

浏览器代码:

var urlBase = url + '?title=' + escape(data.url);
var iframe = '<iframe id="printpdf" src="' + urlBase + '" frameborder="0" width="100%" height="100%"></iframe>';
$("#loadPdf").empty().html(iframe);
$('#printpdf').on("load", function() {
    printPDF();
});

function printPDF() {
    var frame = document.getElementById("printpdf");
    frame.focus();
    frame.contentWindow.print();
}

0 个答案:

没有答案