Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium vba按类名获取元素_Vba_Excel_Selenium_Selenium Webdriver - Fatal编程技术网

Selenium vba按类名获取元素

Selenium vba按类名获取元素,vba,excel,selenium,selenium-webdriver,Vba,Excel,Selenium,Selenium Webdriver,当我尝试以下操作时,我得到一个错误“对象不支持属性或方法” 我还尝试了driver.getElementsByClassName(“headline”)(0)。Text它不是“get”,而是“find”: 或者,使用CSS选择器: driver.findElementByCssSelector(".headline").Text 标题中的标题元素是: 使用FindElementByCss: 使用FindElementByXPath: driver.findElementByClassN

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

我还尝试了
driver.getElementsByClassName(“headline”)(0)。Text

它不是“get”,而是“find”:

或者,使用CSS选择器:

driver.findElementByCssSelector(".headline").Text

标题中的标题元素是:

  • 使用FindElementByCss:

  • 使用FindElementByXPath:

  • driver.findElementByClassName("headline").Text
    
    driver.findElementByCssSelector(".headline").Text
    
    <div class="headline">
        <h1>Fury upsets Klitschko to win heavyweight titles</h1>
    </div>
    
    driver.FindElementByClassName("headline").Text
    
    driver.FindElementByCss("div.headline > h1").Text
    
    driver.FindElementByXPath("//div[@class='headline']/h1").Text