Forum Discussion

kinsleyd's avatar
kinsleyd
Contributor
15 years ago

Searching for text

I'm searching for an effecient way to look at the loaded page and search for some text, specifically the text one can expect if the page returns a javascript error or finds no matching documents, which the developers have made global.  The trouble is I can not predict exactly where it'll be on the page.  I've tried using an if .... exists  statement, but then I get a bunch of errors as its trying to find the frame I typically see the text appearing in which isn't there if the page does load/present documents properly, if that makes sense.  My next thought was FindAllChildren, but then I'd find myself looking at an array, which I guess is possible, but seems cludgey somehow.  Any thoughts?



TIA - Dave



Got the findallchildren logic working, but still seems cludgey

  • Hi Mazhar,





    Thanks for sending the code. I tried to execute the script I sent in my previous post, and it worked fine for this page:

    Sub Test

      Set page = Sys.Process("iexplore").Page("*")

      Set obj = page.FindChild("innerText","CON*",100)

      obj.Click

    End Sub






    Please confirm that this code does not work for you. If it does not work, please let me know the exact text of the error posted to the test log.
  • Hi David,



    I have further analyze the same problem, as i told you in my previous post it was showing "There was an attempt......" error message, my script was considering a wrong object as another object has innerText as "Conversion Table", to avoid this i have changed the string from CON to CONXXXXX in my application, now i am getting Object Not Found Error.



    Regards,

  • Hi Mazhar,





    In this case, try searching by two properties:

    Sub Test

      Set page = Sys.Process("iexplore").Page("*")

      Set obj = page.FindChild(Array("innerText", "tagName"), Array("CON*", "Tab"),100)

      obj.Click

    End Sub

  • Hi Mazhar,





    Thank you for the sample application. As I see, HTML Components (*.HTC) are used in it. This is the cause of the problem - HTML Components are not currently supported by TestComplete.





    I tried to find a workaround by working with these *.HTC controls via Internet Explorer's DOM document using native methods and properties, but these tabs are not accessible even in this case. So, it looks like there is no way to work with these tab objects even from within the tested page itself. Please contact the application developers and ask them whether there is a way to work with the tabs in a script within the tested page. If there is a way to do this, most probably, it will be possible to adapt this way for TestComplete.