New Member
November 28, 2019
Hello
I read your article https://www.myonlinetraininghu.....ling-forms
And thanks for that, I am trying to do something similar on this site
https://safer.fmcsa.dot.gov/mc.....LIC_SEARCH
I am testing by specifying only the state Alabama value = ALUS
However it says it can't find the element ID, not sure what I am missing this is my code
Option Explicit
' Written by Philip Treacy
' https://www.myonlinetraininghu.....ling-forms
Sub Scrape()
Dim Driver As New Selenium.ChromeDriver
Dim count As Long
Sheets("VAT Lookup").Activate
Set Driver = CreateObject("Selenium.ChromeDriver")
count = 1
' Code assumes all VAT numbers in Column A are valid
' No error checking is included here in case they are not
'
' While (Len(Range("A" & count)) > 0)
Driver.Get "https://safer.fmcsa.dot.gov/mcs150t/PKG_CT_PUBLIC.PRC_CT_PUBLIC_SEARCH"
Driver.FindElementById("pv_state_code").SendKeys "ALUS"
' Driver.FindElementById("number").SendKeys Range("A" & count)
Driver.FindElementById("submit").Click
' Uncomment the next line if you need to introduce a delay in the browser
' to allow it to load the results page
'Driver.Wait 1000
Range("B" & count) = Driver.FindElementByXPath("//table[2]/tbody/tr[2]/td[2]").Text
count = count + 1
' Wend
Driver.Quit
End Sub
October 5, 2010
Hi Ian,
If you look at the source code for that page you'll find this bit for the State Code
<select name="pv_state_code" class="form_data_left" id="state" >
The ID of the element is state but your VBA is looking for the ID pv_state_code
Change that and see if it fixes the issue.
Regards
Phil
1 Guest(s)