Reputation: 177
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
Upvotes: 3
Views: 17775
Reputation: 193148
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
Upvotes: 0
Reputation: 473903
It is not "get" - it is "find":
driver.findElementByClassName("headline").Text
Alternatively, using a CSS selector:
driver.findElementByCssSelector(".headline").Text
Upvotes: 4