3

when I try the following I get an error "object does not support property or method"

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

I have also tried driver.getElementsByClassName("headline")(0).Text

Community
  • 1
  • 1
Display name
  • 177
  • 1
  • 3
  • 14

2 Answers2

4

It is not "get" - it is "find":

driver.findElementByClassName("headline").Text

Alternatively, using a CSS selector:

driver.findElementByCssSelector(".headline").Text
alecxe
  • 441,113
  • 110
  • 1,021
  • 1,148
0

The headline element within the website is:

<div class="headline">
    <h1>Fury upsets Klitschko to win heavyweight titles</h1>
</div>

So you can use either of the following Locator Strategies:

  • Using FindElementByClassName:

    driver.FindElementByClassName("headline").Text
    
  • Using FindElementByCss:

    driver.FindElementByCss("div.headline > h1").Text
    
  • Using FindElementByXPath:

    driver.FindElementByXPath("//div[@class='headline']/h1").Text
    
undetected Selenium
  • 151,581
  • 34
  • 225
  • 281