Forum Discussion

rjamison's avatar
rjamison
Occasional Contributor
13 years ago

Unable to find the object in script loop after first time thru loop

I have a script that runs through a loop and the second time tru the loop, it produces the 'Unable to find the object...' error.



To ensure I can in fact see the object, I put in a msgbox if an 'if' condition can identify it just ahead of the line that  tries to set a panel to that object.



My script fires off the msgbox because the if condition is true, but the very next line produces this error.



Here is my code snippet inside the loop:



if (Sys.Process("iexplore", 2).Page("http://stage.XXX.local/outdoor/rain-chains_169132").Panel("HN_HNMC").Panel("HN_HNMC_Cont").Panel(1).Panel(0).Panel(0).Panel(2).Panel(1).Panel("dump_content").Panel(0).Panel(1).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Panel("MII026_AC_Purchase").Panel("MII026_AC_AddToCart").ImageButton("rlMainATC_MII026_AC_addToCartBtn").Exists) then


msgbox("Looks good to me!")


end if


 


Set panel = page.Panel("HN_HNMC").Panel("HN_HNMC_Cont").Panel(1).Panel(0).Panel(0) _


.Panel(2).Panel(1).Panel("dump_content").Panel(sku_row).Panel(sku_col) _


.Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0).Panel(0) _


.Panel(sku_item + "_AC_Purchase") _


.Panel(sku_item + "_AC_AddToCart") _


.ImageButton("rlMainATC_" + sku_item + "_AC_addToCartBtn")





XXX is my local address.

 

Any assistance would be greatly appreciated.  I've spent far too much time on the issue already.

Thanks



rjamison

3 Replies

  • Hi Ron,



    We'll need some more details to track down the problem. Please post here:

    - the exact error message and Additional Info from the test log.

    - your complete script with the loop and the page, sku_row, sku_col and sku_item variable values.

    Thanks.
  • rjamison's avatar
    rjamison
    Occasional Contributor
    Helen,

    Thank you so much for your response.  I did manage to figure this out after taking a different approach to the problem.  The sku_row and sku_col values had changed from the time I had this running in our test environment versus the values in our stage environment.  Since the sku location values had changed, the sku_item would also have to change, but it wasn't.  That is where the error came in.  Very hard to glean the real error in the 'Unable to find the object panel("MII026_AC_Purchase")' when I could physically see it on the screen.  Positionally, the panel I was looking for had changed.



    Thank you for your assistance.



    I am new to forums, so should I now unsubscribe from this thread? 
  • Hi Ron,



    Glad to hear you've solved the problem!



    In your case, I'd actually recommend locating target objects using search functions, such as FindChild, Page.NativeWebObject.Find or Page.EvaluateXPath. That will help you avoid issues with changes in the intermediate object hierarchy and also significantly shorten the syntax for accessing web page elements.



    For example:

    ' Using FindChild and search depth

    Set panel = page.FindChild( _

      Array("ObjectType", "ObjectIdentifier"), _

      Array("ImageButton", "rlMainATC_" & sku_item & "_AC_addToCartBtn"), _

      100)



    ' Using NativeWebObject.Find

    Set panel = page.NativeWebObject.Find("ObjectIdentifier", "rlMainATC_" & sku_item & "_AC_addToCartBtn", "input")



    ' Using XPath

    Set panel = page.EvaluateXPath("//INPUT[@id='rlMainATC_" & sku_item & "_AC_addToCartBtn']")(0)




    I am new to forums, so should I now unsubscribe from this thread?
    Just click the "Unsubscribe" link in the top right of this page, above your original post.

    Alternatively, you can go to your forum profile and manage thread subscriptions on the Forum Subscriptions tab.

    I've attached screenshots for your reference. :)