Selenium-vba 按类名获取元素

2024-04-02

当我尝试以下操作时,出现错误“对象不支持属性或方法”

Sub Testing()
   Dim driver As New SeleniumWrapper.WebDriver
   driver.Start "chrome", "http://www.tsn.ca/fury-upsets-klitschko-to-become-heavyweight-champion-1.401257"
   driver.Open "/"

   MsgBox driver.getElementsByClassName("headline").Text

End Sub

我也尝试过driver.getElementsByClassName("headline")(0).Text


它不是“获取” - 它是“查找”:

driver.findElementByClassName("headline").Text

或者,使用 CSS 选择器:

driver.findElementByCssSelector(".headline").Text
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Selenium-vba 按类名获取元素 的相关文章

随机推荐