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

2 Answers 2

4

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

driver.findElementByClassName("headline").Text

Alternatively, using a CSS selector:

driver.findElementByCssSelector(".headline").Text
Sign up to request clarification or add additional context in comments.

Comments

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
    

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.