1

I am trying to open an Internet Explorer window navigate to this weather website then click on the button to start the animation for the weather map. I cannot get the code to click the button. I tried getelementsbyName but I cannot find the Name. I think I found the ID (using another script to list the element ID's) so I am trying getelementsbyID and it is not working. I get an error "Object doesn't support this property or method:" This should be simple but I have very little experience. Any suggestions to click this button with VBS would be greatly appreciated.

Element: <div class="play-pause iconfont clickable off" data-ref="play"></div>

Website: https://www.windy.com/-Weather-radar-radar?radar,40.229,-83.364,5

Dim objWshShell,IE

Set objWshShell = Wscript.CreateObject("Wscript.Shell")
Set IE = CreateObject("InternetExplorer.Application")

With IE
  .Visible = True
  .Navigate "https://www.windy.com/-Weather-radar-radar?radar,40.229,-83.364,5"

'Wait for Browser
  Do While .Busy
    WScript.Sleep 10000
  Loop
  .documents.getElementsByID("playpause").Click()
End With
user692942
  • 16,398
  • 7
  • 76
  • 175
  • 3
    Possible duplicate of [Vbs To GetElement from web page does not workning properly](https://stackoverflow.com/questions/23971918/vbs-to-getelement-from-web-page-does-not-workning-properly) – user692942 Nov 08 '19 at 16:45

1 Answers1

1

The method you are trying to use is getElementById and doesn't contain an s after Element:

.document.getElementByID("playpause").Click()

should be

.document.getElementByID("playpause").Click

Also removed is the "s" on documents and the parentheses after Click.

Étienne Laneville
  • 4,697
  • 5
  • 13
  • 29
  • [Answered before](https://stackoverflow.com/a/23973451/692942), please try searching before leaving duplicate answers. We are talking about a technology which is now so old (20+ years) it's getting increasingly harder to even find the original documentation because Microsoft are so keen to bury it. With that in mind, how many times do you think questions like this have been asked here? – user692942 Nov 08 '19 at 16:46
  • Technically `getElementById()` is a DOM method and has nothing to do with VBScript apart from the fact that IE exposes it in the object model. – user692942 Nov 08 '19 at 16:51
  • 1
    The question you refer to has 3 duplicate answers and no accepted answer. – Étienne Laneville Nov 08 '19 at 16:52
  • Indeed, three duplicate answers, we don't need a fourth. The OP never accepted it doesn't make the fact the question was answered any less relevant and certainly doesn't mean adding more duplicates. – user692942 Nov 08 '19 at 16:54
  • That's great thank you for the answer. It at least let the code complete. It still didn't click the button but I'm sure I just need to find the right ID. Thank you. – gearhead081996 Nov 08 '19 at 18:02
  • 1
    Welcome to Stack Overflow, glad the answer helped you out. As Lankymart mentions, many of the questions you might have with this project will probably have been asked before so take a look at what's available on Stack Overflow when you need more help! – Étienne Laneville Nov 08 '19 at 18:23