Excel VBA Course
Excel VBA Course - From Beginner to Expert

200+ Video Lessons
50+ Hours of Video
200+ Excel Guides

Become a master of VBA and Macros in Excel and learn how to automate all of your tasks in Excel with this online course. (No VBA experience required.)

View Course

application defined error or stop without extract data

0

hello

I hope  find  solution . why  this  code  occures different errors out of memory or application defined error in this  line ?

.FindElementByClass("coi-banner__accept--fixed-margin").Click

    somtimes  is  gone  and  stop  it  without  extract  any  data  by  debug in word stop in the  end of  code .

currently  no error but  just show debug in word  stop.

Sub test2()

    Dim driver As New webdriver
    With driver
        .Start "Chrome"
        .Get "https://www.maersk.com/tracking/"
        .FindElementByClass("coi-banner__accept--fixed-margin").Click
        .FindElementById("track-input").SendKeys (Range("C2").Value)
        .FindElementByClass("track__search__button").Click
        cNum = .FindElementByClass("search-summary--bol__dd").Text
        frm = .FindElementByClass("search-summary--from__dd").Text
        to_ = .FindElementByClass("search-summary--to__dd").Text
        arrDate = .FindElementByClass("summary__text--date").Text
        LastLoc = .FindElementByClass("summary__text--location").Text
        TranPlan = .FindElementByClass("transport-plan").Text
    End With
    Stop
End Sub

I put  the  expected result should  be  in sheet ship based on cell C2 

Answer
Discuss

Discussion

The error probably occurs if that class cannot be found on the web page or if too many of them are found - that's what I'd guess. Sometimes web pages serve different code based on many factors and the specific class that we think we can always use to locate an item does not always work.
don (rep: 1989) May 19, '22 at 1:16 pm
The error probably occurs if that class cannot be found on the web page 
I don't  think  so . I  make  sure  all  of  waht  existed in the code are  matched with the  items in webpage.
or if too many of them are found
this  possibilty is  a big to  occures , I agree with this proposition .
 Sometimes web pages serve different code based on many factors and the specific class that we think we can always use to locate an item does not always work.
then  this  is trouble and  I  can't  deal  with  this  case .This is beyond my capabilities as a newbie to coding websites
thanks  for  your feedback
Alaa (rep: 28) May 19, '22 at 2:19 pm
Add to Discussion



Answer the Question

You must create an account to use the forum. Create an Account or Login