how to for loop / for each loop ??

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
adrian_9832
Posts: 26
Joined: 23 Dec 2018, 00:40

how to for loop / for each loop ??

30 Oct 2019, 07:53

hello everyone !

i am a beginner.

here is my script , use selenium to find web element and retrieve text value.
i have a problem. i can find the webelement but i don't know how to use for loop to show the value ,
as autohotkey "for loop" API not friendly .... can anyone help .....

Code: Select all

driver := ComObjCreate("Selenium.FirefoxDriver")
driver.Get("https www.google.com /webhp?hl=zh-TW&sa=X&ved=0ahUKEwjj8fuci77lAhXOyosBHWCSCsAQPAgH")  Broken Link for safety

sleep, 2000
driver.findElementByName("q").sendKeys("selenium")
sleep, 2000
driver.FindElementByName("btnK").Click
sleep, 2000

h3Element := driver.FindElementByClass("LC20lb")                         <-----i want for loop all webelement , now only show the first element , how to go next ...
abc := h3Element.text
msgbox,%abc%


i try to below method:

Code: Select all

loop,3
{
h3Element := driver.FindElementByClass("LC20lb") 
abc := h3Element.text
msgbox,%abc%
}

or
h3Element := driver.FindElementByClass("LC20lb") 

while(h3element!="")
{
abc := h3Element.text
msgbox,%abc%
}
is not success ............please help....thanks all

i think if use for loop maybe work ,, but ahk maybe no this function...
for each i in h3element / or / for i in h3element

[Mod edit: [code][/code] tags added]

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], macromint, peter_ahk and 345 guests