Web Scraping VBA + Selenium Error: Element not found

bunburyst

New Member
Joined
Apr 18, 2018
Messages
24
Hello friends, i am trying to build a code with vba + selenium to extract a table in a web.
When executing the macro I get the following error "Element Not Found for Class=tablaHistoricoPrecio". I don't understand, because according to the structure of the web code the table has that definition. Any help would be appreciated. Greetings.

This is my vba code

VBA Code:
Private driver As New WebDriver
Sub repsol2022()
Dim GIGYA As Object
Set driver = New EdgeDriver
Dim rowc, cc, columnC As Integer
rowc = 2
With driver
    .Start "edge"
   .Get "https://repsol.force.com/portalGestorEESS/s/consultaPrecios"
 
     With .FindElementByClass("gigya-login-form")
           
           .FindElementByClass("gigya-input-text").SendKeys "xxx"
            .FindElementByClass("gigya-input-password").SendKeys "xxx"
             .FindElementByClass("gigya-input-submit").submit
           
          End With
     Application.Wait Now + TimeSerial(0, 0, 5)
   
For Each tr In driver.FindElementByClass("tablaHistoricoPrecio").FindElementByTag("tbody").FindElementsByClass("precioDetalle")
columnC = 1
For Each th In tr.FindElementsByClass("precioDetalle")
Data.Cells(rowc, columnC).Value = th.Text
columnC = columnC + 1
Next th
rowc = rowc + 1
Next tr
           
End With
Exit Sub


End Sub

This is the web code
web code2.jpg


This is a table screenshot

table.jpg
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,223,886
Messages
6,175,189
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top