I'm trying to have a code which redirect to a certain page and then wait the page to be fully loaded and then do some queries on this new page. For example I want to redirect to google.com and then inject 'hello' in the search bar.
I have tried some sleep/wait functions or event listeners but didn't worked.
<!DOCTYPE html>
<html>
<head>
<title>query</title>
</head>
<body>
<script type="text/javascript">
window.location = 'https://google.com';
document.querySelector('input[name="q"]').value = 'hello';
</script>
</body>
</html>
I would like to wait that the new page has fully charged and then do the query, but with the above script it only goes to google.com and don't inject 'hello' in the search bar.