Forum Discussion

rjamison's avatar
rjamison
Occasional Contributor
13 years ago

How do I avoid Error flag in results when I test for it?

I need to test a web page to ensure it is the one I need to be on.  Here are two subs that do not produce the results I expect:


Sub Test4

  Call Browsers.Item(btIExplorer).Run("http://www.yahoo.com/")

  'An Object map taken from the Yahoo.com page.

  'Sys.Browser("iexplore").Page("http://www.yahoo.com/").Panel("y_shade").Panel("default_p_30345150").Panel("default_p_30345150_bd").Panel("default_u_30345158").Panel("default_u_30345158_bd").Panel("yui_3_4_0_1_1343863995532_100").Link(0)

  strNextLine = "http://www.yahoo.com/"

  '  This produces no error - as expected. ' an error - how do I get arround it?

  if Sys.Browser("iexplore").Page(strNextLine).Panel("y_shade").exists then

    if Sys.Browser("iexplore").Page(strNextLine).Panel("y_shade").Panel("default_p_30345150").exists then

      Log.Message(strNextLine + " Is the right site")

    else

      Log.Message(strNextLine + " Is the wrong site")

    end if

 end if

  call Sys.Browser.browserwindow(0).close

End Sub


Sub Test5

  Call Browsers.Item(btIExplorer).Run("http://www.yahoo.com/")

  'An Object map taken from the Yahoo.com page.

  'Sys.Browser("iexplore").Page("http://www.yahoo.com/").Panel("y_shade").Panel("default_p_30345150").Panel("default_p_30345150_bd").Panel("default_u_30345158").Panel("default_u_30345158_bd").Panel("yui_3_4_0_1_1343863995532_100").Link(0)

  strNextLine = "http://www.yahoo.com/"

  '  This produces an error - how do I get arround it?

  if Sys.Browser("iexplore").Page(strNextLine).Panel("y_shade").exists then

    if Sys.Browser("iexplore").Page(strNextLine).Panel("y_shade").Panel("default_p_30345151").exists then

      Log.Message(strNextLine + " Is the right site")

    else

      Log.Message(strNextLine + " Is the wrong site")

    end if

  end if

  call Sys.Browser.browserwindow(0).close

End Sub



On the TestScript Log page, I get this error:  Unable to find the object Panel("default_p_30345151"). See Additional Information for details.



How doI get around this as it shows up as an error.  What I need to see are teh Log Messages, and I do see them.  QA Complete logs is as error even though I got what I expected.  Please explain how to 'Code around' this problem.



Thanks.

  • Hi,

    TestComplete has special Wait- functions that should be used to obtain an object that may exist or not exist. Such functions can return a stub object that has the Exist property set to False, and they do not post an error to the Log in case the object does not exist.

    Please refer to the Checking Whether an Object Exists help topic.

  • jlesch's avatar
    jlesch
    New Contributor
    I am having the same problem. It is logging the test as failed when it is working as expected.



    If link.exists Then

    log.message ".."

    else

    log.message ".."

    End If



    A error shows up in the log saying that it cant find "link" and then fails the test.



    any suggestions to help us out?