I am a beginner developing a web application when history.back() is called I want to programatically click a button in the previous page. I have 2 pages page1 and page2, when history.back is called from page2 I would like to go back to page1 and click end button that is present in page1
document.addEventListener("start", () => {
console.log("session ended");
console.log("final", Content);
history.back();
document.querySelector(".end__button").click();
});
<div class='end__button'>
<button>btn</button>
</div>
query selector either cannot find button or line is not executed. How can I solve this problem? TIA