I'm trying to click on an element of the iframe (onpage).
I decided on the element "ablobcathungry" for now.
I can't seem to get it to work however, no click is executed.
Are there special tricks required for this ?
The frame loads perfectly, so thats not the issue ...
<html>
<body>
<iframe id="my-iframe" src="https://app.box.com/s/j7i88s6jb4yyk4wmiti4tol8ejoikdhl/folder/189200124977#" style=" display:block; position: absolute; height: 100%; width: 100%" frameborder="0" ></iframe>
<script>
window.onload = function() {
var myIframe = document.getElementById("myIframe");
myIframe.onload = function() {
var iframeDocument = myIframe.contentDocument || myIframe.contentWindow.document;
var year2023 = iframeDocument.body.querySelector(":contains('ablobcathungry')");
year2023.click();
};
};
</script>
</body>
</html>
I also tried another approach utilizing positioning, which yields no click either
<body>
<iframe id="myIframe" src="app.box.com/s/j7i88s6jb4yyk4wmiti4tol8ejoikdhl/folder/189200124977" style="width: 100%; height: 1000px;"></iframe>
<script>
window.addEventListener("load", function() {
var iframe = document.getElementById("myIframe");
iframe.addEventListener("load", function() {
setTimeout(function() {
var x = iframe.contentWindow.innerWidth / 2;
var y = iframe.contentWindow.innerHeight / 2; iframe.contentWindow.document.elementFromPoint(x, y).click();
}, 8000);
});
});
</script>
</body>
</html>