如何打印Excel VBA的Selenium包装器的findElements()值

时间:2015-09-01 02:49:04

标签: excel vba excel-vba selenium

首先,我知道findElements()会返回Selenium找到的值列表。我想知道如何在Excel VBA中打印每个项目或如何在Selenium包装器语法中打印它?

请参阅下面的代码。

我收到类似

的错误
  

对象不支持....."

使用msgBox语法。

Dim tableElement As WebElement

Set tableElement = driver.FindElementById("picker_address_table_tag")

Dim tableList As New List

Set tableList = tableElement.FindElementById("picker_address_thead").FindElementsByTagName("th")

Dim testString As Variant

testString = tableList.Values()


MsgBox testString(2)

MsgBox testString(3)

MsgBox testString(4)

MsgBox tableList.Count

MsgBox tableList.Item(1).Attribute

1 个答案:

答案 0 :(得分:2)

您应该获得IWebElement个对象的集合:

https://selenium.googlecode.com/svn/trunk/docs/api/dotnet/html/AllMembers_T_OpenQA_Selenium_IWebElement.htm

所以可能是这样的:

Dim e
'....
For Each e in tableList
    Debug.Print e.Text 'output innerText
Next e