thqby / ahk2_lib

MIT License
233 stars 32 forks source link

thqby Chrome Class - How to wait for new page to load #19

Closed sousvideonlow closed 1 year ago

sousvideonlow commented 1 year ago

As illustrated in https://www.autohotkey.com/boards/viewtopic.php?f=82&t=116783&p=520585#p520585

Here's my question

utcString:="20230509T060000"
AddCountries:="&p1=tz_jst&p2=tz_aet&p3=236"
url := "https://www.timeanddate.com/worldclock/converter.html?iso=" utcString AddCountries
run("Chrome.exe " url)
xCh:=Chrome()
Page := xCh.GetPageBy("url", pageurl, "contains")
Page.WaitForLoad()

The above doesn't really wait for page to load because if I launch a new page too fast then Page becomes an empty string instead of an object

thqby commented 1 year ago
loop
sleep 10
until page := xCh.GetPageBy(...)
xCh:=Chrome()
page := xCh.NewTab(url)