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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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