1

in the link https://www.forebet.com/en/predictions-tips-atl%C3%A9tico-madrid-real-madrid-553878 I want to load the document that is on the page that you click on "uo_t_butt"

I create the script with

Sub provaonclick()

Dim objIE As Object
Dim ele As Object
Dim ele1 As Object


Set objIE = CreateObject("internetexplorer.application")
objIE.Visible = True
objIE.navigate "https://www.forebet.com/it/pronostico-per-real-madrid-liverpool-fc-731893"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
Set ele = objIE.document.getElementsByClassName("tabs-ul")(0)
Set ele1 = ele.document.getElementById("uo_t_butt").Click

End Sub

but in the object ele1 there is nothing

QHarr
  • 83,427
  • 12
  • 54
  • 101
plinius
  • 23
  • 4
  • 1
    You question is unclear. You said `click on "uo_t_butt"` but never did clarify what is `uo_t_butt`. Is this a class or id or something else? Moreover, the link within your script and the link in your description are different. Try to edit your question to clear the confusion @plinius. – SIM Oct 04 '18 at 13:26

3 Answers3

1

What i think is your problem is that it is a javascript controlling the button.

HTML and javascript isn't my strong suit but the following code works for me:

Sub provaonclick()
Dim objIE As Object

Set objIE = New InternetExplorerMedium
objIE.Visible = True
objIE.navigate "https://www.forebet.com/it/pronostico-per-real-madrid-liverpool-fc-731893"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop

With objIE.Document.getElementById("uo_t_butt")
    .Focus
    .Click
End With

End Sub

".Focus" made the code work for me. I don't know what it does though.

EDIT: Actually not using set in front of "objIE.Document.getElementById("uo_t_butt").click" was the difference.

Mr ML
  • 428
  • 2
  • 14
  • Because as per my answer, you have removed the .Click which was producing the JScriptTypeInfo object. – QHarr Oct 04 '18 at 13:59
  • Yes is see you've changed your answer and explained a bit. Thank you for the explanation. – Mr ML Oct 05 '18 at 05:59
0

You can't normally set an element and try to do a click on it at the same time. The Set keyword is for assigning a reference. It is necessary to distinguish between assignment of an object and assignment of the default property of the object. It is this reference type you will be passing around.

This:

Set ele1 = ele.document.getElementById("uo_t_butt").Click

Normally, this would have thrown an error. Weirdly there is a javascript item generated which is JScriptTypeInfo. This , according to this, likely

hides a number of objects that can be found in JScript.dll.

Remove the action (.Click) from the end to set an object in the normal way and you don't need the preliminary object. Work direct of document with the id.

I had no problem using id with:

objIE.document.querySelector("#uo_t_butt").Click

You can use an attribute = value CSS selector

objIE.document.querySelector("[onclick*='uo']").Click

This switches to the unders/overs tab.

enter image description here

Could also use:

objIE.document.querySelector("[id='uo_t_butt']").Click
QHarr
  • 83,427
  • 12
  • 54
  • 101
  • sorry was my mistake I wanted to load all the document instead of the click command, actually click and I load the page in the open browser and I solved it so ele.document.getElementById("uo_t_butt").Click – plinius Oct 04 '18 at 13:54
  • Which is the answer I gave. – QHarr Oct 04 '18 at 14:00
0
Sub provaonclick()
Dim objIE As Object
Dim ele As Object

Set objIE = CreateObject("internetexplorer.application")
objIE.Visible = True
objIE.navigate "https://www.forebet.com/it/pronostico-per-real-madrid-liverpool-fc-731893"
Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
objIE.document.getElementById("uo_t_butt").Click

Set ele = objIE.document.getElementsByClassName("schema")(1)
Stop
End Sub

sorry all I thought I had solved but my macro just click on "onclick" but does not load the new page in "ele". In "ele" I find the first page that opens not the clicked one

plinius
  • 23
  • 4