|
1 | | -; AutoIt script example |
| 1 | +; AutoIt script example with Selenium |
2 | 2 | ; https://www.autoitscript.com |
3 | 3 | ; |
4 | 4 |
|
| 5 | +Func Main() |
| 6 | + ; Launch the browser and open an URL |
| 7 | + Dim $driver = ObjCreate("Selenium.FirefoxDriver") |
| 8 | + $driver.Get("https://en.wikipedia.org/wiki/Main_Page") |
5 | 9 |
|
6 | | -; Launch the browser and open an URL |
7 | | -Local $driver = ObjCreate("Selenium.FirefoxDriver") |
8 | | -$driver.Get("https://en.wikipedia.org/wiki/Main_Page") |
| 10 | + ; List all links, remove duplicates and sort them |
| 11 | + Dim $links = $driver.FindElementsByCss("a").Attribute("href") |
| 12 | + $links.Distinct |
| 13 | + $links.Sort |
| 14 | + |
| 15 | + ; Launch Excel and create a Workbook |
| 16 | + Dim $excel = ObjCreate("Excel.Application") |
| 17 | + $excel.WorkBooks.Add ; Add a new workbook |
| 18 | + $excel.Visible = 1 ; Let Excel show itself |
| 19 | + |
| 20 | + ; Write the links in Excel and quit |
| 21 | + $links.ToExcel($excel.ActiveSheet, "Links") |
| 22 | + $driver.Quit |
| 23 | +EndFunc |
| 24 | + |
| 25 | +Main() |
9 | 26 |
|
10 | | -; List all links, remove duplicates and sort them |
11 | | -Local $links = $driver.FindElementsByCss("a").Attribute("href") |
12 | | -$links.Distinct |
13 | | -$links.Sort |
14 | 27 |
|
15 | | -; Launch Excel and create a Workbook |
16 | | -Local $excel = ObjCreate("Excel.Application") |
17 | | -$excel.WorkBooks.Add ; Add a new workbook |
18 | | -$excel.Visible = 1 ; Let Excel show itself |
19 | 28 |
|
20 | | -; Write the links in Excel and quit |
21 | | -$links.ToExcel($excel.ActiveWorkBook.ActiveSheet, "Links") |
22 | | -$driver.Quit |
23 | 29 |
|
24 | 30 |
|
0 commit comments