Using JavaScript I am atempting to simulate a click. This will be performed on a flash clip swf file. Using the following code. Here is what I have come up with.
countDown = 10;
var rollDice = setInterval(function() {
console.log(countDown);
if (countDown == 0) {
clearInterval(rollDice);
document.elementFromPoint(416, 825).click();
}
countDown--;
}, 1000);
With this code I get the following error: Uncaught TypeError: Cannot call method ‘click’ of null.
I’m not sure if clicking on an item by coordinates rather than a jQuery selector is a good idea. Why do you have to do the click event via coordiates rather than select the button that is being pressed?
You issue seems to be due to the fact that elementFromPoint doesn’t return a jQuery Object, try this instead: