Selenium and AHK - How to get the size of table rows/column?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Renets
Posts: 36
Joined: 12 Jul 2018, 13:11

Selenium and AHK - How to get the size of table rows/column?

25 Jun 2020, 11:41

I've been researching hours without success

I just need the syntax for Autohotkey to get the size of a table rows/column

I am following this guide https://www.guru99.com/handling-dynamic-selenium-webdriver.html

In other languages they suggest this:

Code: Select all

WebElement tbody = driver.findElement(By.xpath("//div[@class='z-listbox-body']/table/tbody"));
List<WebElement> rows = tbody.findElements(By.xpath("tr"));
totalrows = rows.size();
Note that they use the "List<WebElement>" to convert into a List type the variable, the problem is, that in AHK there is no variable type definition, it should be automatically, but apparently not in this case

This is the page I am doing test on, but can't get it to work
http://demo.guru99.com/test/web-table-element.php#

I just need to know how many rows and/or columns it has, it should be as simple as this:

Code: Select all

 MsgBox %  ""  oChrome.findElementByXpath("//*[@id='leftcontainer']/table/thead/tr/th").size()
(Gives no error but doesnt show any value)

Or even this, like there they suggested (https://stackoverflow.com/questions/57237659/how-to-get-the-total-number-of-elements-in-a-html-with-selenium-webdriver-and-au)

Code: Select all

 MsgBox %  ""  oChrome.findElementByXpath("//*[@id='leftcontainer']/table/thead/tr/th").Count()
(Error: Unknown Name, Specifically: Count)

The goals is to have the number of columns (in this case 5) and Rows (26), this, in order to further fo a For Each and loop through the values of each row

I would appreciate any kinds of suggestions, thanks!


Full Code

Code: Select all

oChrome := ChromeGet() ; Object for Chrome

MsgBox %  ""  oChrome.findElementByXpath("//*[@id='leftcontainer']/table/thead/tr/th").Size() ; FAIL

MsgBox %  "Finish" 
return

ChromeGet(IP_Port := "127.0.0.1:9222") {
    oChrome := ComObjCreate("Selenium.ChromeDriver")
    oChrome.SetCapability("debuggerAddress", IP_Port)
    oChrome.Start()
    return oChrome
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 398 guests