The following code open a website, wait for 10 seconds to make sure that the website is loaded. It then scrolls down 5 times and then click a specific location on the screen where a link is situated. There are two problems I want to remove.
Problem 1:
It is working but it is not a good approach. I know AutoIt provides a facility where a user can search for the text to click it. For example
<a href="example.com"> click here to go to example.com </a> then we can ask autoit to click the link "click here to go to example.com" on loading the page.
Problem 2:
Instead of waiting for specific time e.g. 10 seconds, it would be better to perform the click action after the page is loaded fully.
Global $MOUSE_WHEEL_DOWN1 = "Down"
ShellExecute("chrome.exe", "https://example.com","","")
; To open the example.com page in google chrome.
WinWait('example - Google Chrome')
sleep(10000) ; wait for ten seconds to make sure the page is loaded
WinActivate('example - Google Chrome')
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE) ; Maximize the window to make sure the clicking place is right each time
sleep(1000) ; wait for maximize window
MouseWheel($MOUSE_WHEEL_DOWN1, 5) ; scroll down the page because the link is at the bottom of the page
sleep(1000)
MouseClick('primary', 1295,312) ; click the text of the link to open the next page. e.g. "click here to go to next page"