Excel 需要使用Selenium Wrapper for Visual Basic验证表单元格中的文本

Excel 需要使用Selenium Wrapper for Visual Basic验证表单元格中的文本,excel,vba,selenium,Excel,Vba,Selenium,我正在使用VisualBasic的Selenium包装器来自动化Chrome浏览器 我需要根据先前存储的字符串变量invoice中的字符串验证表中的文本 简化的HTML示例: <th scope="row" class=" dataCell "> <a href="link-to-follow" onclick="searchResultClick.mousedown(this, event)" onmousedown="searchResultClick.mousedown

我正在使用VisualBasic的Selenium包装器来自动化Chrome浏览器

我需要根据先前存储的字符串变量invoice中的字符串验证表中的文本

简化的HTML示例:

<th scope="row" class=" dataCell  ">
<a href="link-to-follow" onclick="searchResultClick.mousedown(this, event)" onmousedown="searchResultClick.mousedown(this, event)">Link Text</a>
</th>
<td class=" dataCell  ">Text to be verified</td>
<td class=" dataCell  ">&nbsp;</td>
出现一条错误消息,显示运行时错误“13”:类型不匹配


提前感谢您提供的任何帮助。对编程来说还是相当新的。

我写VBA代码已经很久了。然而你的问题看起来很简单

Sub SearchForInvoice()
    Dim driver As New SeleniumWrapper.WebDriver
    Dim invoice As String

    invoice = "Text to be verified"

    'You are doing driver.verifyTextPresent on driver itself. It should be on an element instead.
    'Or, simply finding the element with text based xpath search is enough as well.

    If driver.findElementByXPath("//td[.='Text to be verified']").size() > 0 Then

       MsgBox("Success")

    End If
End Sub

哪一行引发异常?@Saifur该行:If driver.verifytextpresentationvoice=True,则正在给我问题谢谢你的建议。我尝试了If driver.findelementbypath//d[.=invoice].Size>0,但我收到一条错误消息,提示编译错误:类型不匹配,然后突出显示>。你知道为什么会发生这种情况吗?实际上是驱动程序。findElementsByXPath//td[.='Text to verification']。size>0抱歉,对硒化镓VBA不太熟悉
Sub SearchForInvoice()
    Dim driver As New SeleniumWrapper.WebDriver
    Dim invoice As String

    invoice = "Text to be verified"

    'You are doing driver.verifyTextPresent on driver itself. It should be on an element instead.
    'Or, simply finding the element with text based xpath search is enough as well.

    If driver.findElementByXPath("//td[.='Text to be verified']").size() > 0 Then

       MsgBox("Success")

    End If
End Sub