Is there a way to use selenium-wire in python to capture a full screenshot of a web page and save it as a png file after clicking the submit button?
Despite seeing a popup message saying "taking screenshot!!", the actual screenshot file is not being saved. Here's what I've tried:
html2canvas = """
var s = window.document.createElement('script');
s.src = 'https://html2canvas.hertzen.com/dist/html2canvas.min.js';
window.document.head.appendChild(s);
"""
driver.execute_script(html2canvas)
script = """
btn = document.getElementById("input_2")
btn.addEventListener("click", () => {
alert('taking screenshot!!');
// creating canvas of element using html2canvas
html2canvas(srcElement).then(canvas => {
// adding canvas/screenshot to the body
if(btn.id === "take-src-only") {
return document.body.appendChild(canvas);
}
// downloading canvas/screenshot
const a = document.createElement("a");
a.href = canvas.toDataURL();
a.download = "fullscreenshot.png";
a.click();
});
});
"""
driver.execute_script(script)