Reputation: 1
I'm having a little trouble with my code. Follow the code below
<a href="LINK HERE"><img src="IMAGE LINK HERE" border="0" alt="Page suivante" align="right"></a>
For reasons of confidentiality, I canno't show the link. I would like to know, how can I click on this link using "alt".
Thanks
Upvotes: 0
Views: 379
Reputation: 4486
I'm not too familiar with CSS selectors (so am sure someone else can/will give you a better answer), but this seems to work for me if I add a reference for Microsoft HTML Object Library
:
Option Explicit
Private Sub SomeCssSelection()
Dim html As MSHTML.HTMLDocument
Set html = New MSHTML.HTMLDocument
html.body.innerHTML = "<a href=""LINK HERE""><img src=""IMAGE LINK HERE"" border=""0"" alt=""Page suivante"" align=""right""></a>"
Dim targetElement As MSHTML.HTMLImg
Set targetElement = html.querySelector("img[alt=""Page suivante""]")
Debug.Assert Not (targetElement Is Nothing)
End Sub
As pointed out by QHarr, single quotes can be used to make the code easier to read:
Set targetElement = html.querySelector("[alt='Page suivante']")
Upvotes: 2