0

I am using VBA to scrape a website. I was given the URL to the homepage of the website, but I need to access the info in its tabs. The URL stays the same upon entering the tab. I have looked online.

<li>
<a href="#" onclick="displayQuery();">Query</a>
</li>

I looked into HTML and this is the part that is executed when I click on the relevant tab.

I tried ie.document.querySelector("div[id=overview]").Click.

Community
  • 1
  • 1
Wen Jiaxin
  • 15
  • 1
  • why do you think this selector works? it's not a DVI and doesn't have the ID – Philipp Sander May 17 '19 at 08:41
  • My apologies Philip, I did not use the DIV or ID directly. I was trying to substitute the values but to no avail. – Wen Jiaxin May 27 '19 at 04:59
  • I realised the mistake was that the code was embedded within a frame. so it should have went something like ie.document.frames(0).querySelector("div[id=overview]").Click. Thanks! – Wen Jiaxin Jul 22 '19 at 01:22

1 Answers1

1

Use the onclick attribute. You are after an a tag element. Also, as mentioned in comments that id is not shown in the html above (though may belong to another element).

ie.document.querySelector("[onclick='displayQuery();']").click

To open in a new tab would require possibly amending this element via javascript.

If this answer is correct:

Clicking an anchor with href="#" will move the scroll position to the top.

The real work is happening in the function called by the onclick event i.e. displayQuery();

QHarr
  • 83,427
  • 12
  • 54
  • 101