florentbr / SeleniumBasic

A Selenium based browser automation framework for VB.Net, VBA and VBScript
BSD 3-Clause "New" or "Revised" License
431 stars 197 forks source link

In SeleniumBasic How to Create an Array on "div" Tags #210

Closed rsherfey closed 4 years ago

rsherfey commented 4 years ago

I am scraping data from a Chrome webpage in Excel v.16 using SeleniumBasic. Because this deal with patient data, I cannot provide a lot of information. Originally, I wrote the code I needed using VBA in IE.

Here is the html:

image

Here is my original VBA code, which worked just fine:

image

In SeleniumBasic I am finding it difficult to grab the “div” data. I can access ![image](https://user-images.githubusercontent.com/67288933/90295026-bd169800-de3c-11ea-9baa-8b2ea1eadbe7.png because it is an “id”. But I need to know how to get the message elements within that “div id” (could be up to 10 messages) and load them into an array. The "Messages" I am referring to are: image

Is there a way to accomplish using Selenium Basic what I did in VBA? Any help would be greatly appreciated!

mogulman52 commented 4 years ago

To select elements use Xpath. It is extremely powerful. It takes a bit to understand it so be patient. Search 'Xpath Tutorial Youtube' on Bing.

rsherfey commented 4 years ago

mogulman52, thank you for your recommendation. I think Xpath is what I was looking for.