cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to read caption of a form

Highlighted
Contributor

Unable to read caption of a form

Jared,


So in this case we would be using a different type of function to find the location of a character and have that return a non-zero if the character exists.  If this is a workaround that is fine, but why can I not do a compare?


I do other functions where I abbreviate form and window names with an '*' and don't have any problems there.  Why would this one be so special?


Mike


P.S. (I have copied the original information from the old message board.)



AutomatedQA Support <support@automatedqa.com> wrote:

Hi Michael,


<<

  Log["Message"](w["WndCaption"] == "*t*"); //Log 3

>>

When you use the "*t*" string in the line above, it means that you want to compare the string with the caption whose value should be "*t*". I suppose that you want to determine whether the 't' character belongs to the caption. In this case, you need to use the indexOf method. Here's an example:


if (w["WndCaption"].indexOf("t") > 0)

    Log["Message"]("TRUE");


Please read the following MSDN article for more information:

http://msdn.microsoft.com/en-us/library/53xtt423(VS.85).aspx


--

Best regards,

Jared - AQA Support

~~~~~~~~~~~~~~~~~~~~~


Michael St.Peter wrote:

Jared,


Well, I changed the one item in my code from ["Caption"] to ["WndCaption"] and I can get the caption that I am looking for, however, my compare does not work.  I'm using a small function right now.

function Test2()

{

  var w = P3PlusProcess["Form"]("Ponemah Physiology Platform*")["Panel"]("Workspace")["WaitMDIWindow"]("DRa*", 3000);

  if (w.Exists)

    Log["Message"](w["WndCaption"]); //Log 1

  else

    Log["Message"]("The object doesn't exist"); //Log 2

 

  Log["Message"](w["WndCaption"] == "*t*"); //Log 3 

  Log["Message"](w["WndCaption"] == "DRa  1% complete");//Log 4 

  

  x = P3PlusProcess["Form"]("Ponemah Physiology Platform *")["Panel"]("Workspace")["MDIWindow"]("DRa*")["WndCaption"];

  Log["Message"](x); //Log 5

}


The caption of the window is changing about once a minute, maybe less.  What doesn't make sense is that Log 3 will come up as 'False' while Log 4 comes up as 'True' when the dialog is at 1%.  Of course, when it is no longer 1%, Log 4 changes to False.  I just don't understand what I am doing wrong where Log 3 is reporting False.  Also note that Log 1 and 5 come up with the same information.


Mike


"AutomatedQA Support" <support@automatedqa.com> wrote:

Hi Michael,


1.) Does the changing of the title of the form affect TC where a refresh is recommended?

You can try using the WaitMDIWindow method, which will refresh the object tree before obtaining an object, together with the Exists property. Here's an example:

var w = Sys["Process"]("PPP3")["Form"]("Ponemah Physiology Platform*")["Panel"]("Workspace")["WaitMDIWindow"]("DRa*", 3000);

 if (w.Exists)

   Log["Message"](w["Caption"]);

 else

   Log["Message"]("The object doesn't exist");

Does this work for you? If you still get the error message, tell me how often the caption of the window changes. Also, post here the entire function in which you obtain the window.

As for the second question, the problem cannot occur because there's the '%' character in the caption.


--

Best regards,

Jared - AQA Support

~~~~~~~~~~~~~~~~~~~~~


"Michael St.Peter" <mstpeter@datasci.com> wrote in message news:4b211c94$1@news.automatedqa.com...

David,

I can try, but the files required to create the issue of having the title of the forms are several gigabytes.  Before sending I do have a couple of questions.

1.) Does the changing of the title of the form affect TC where a refresh is recommended?

2.) One of the characters in the title is '%'.  Could my coding (or something in TC) not like this character?

Thanks,

Mike


AutomatedQA Support <support@automatedqa.com> wrote:

Hi Michael,


We were unable to reproduce the problem here. Could you zip your entire project suite folder along with logs and send us the archive via our Contact Support


Form

(http://www.automatedqa.com/support/message/)?

--

Best regards,

David - AQA Support

~~~~~~~~~~~~~~~~~~~~~


Michael St.Peter wrote:

Using the object browser, I am viewing the form with the full name:

Sys["Process"]("PPP3")["Form"]("Ponemah Physiology Platform  - TEST_750-490sp2.RVW (User: St.Peter)")["Panel"]("Workspace")["MDIWindow"]("DRa  14% complete")

In my script I use the following name:

P3PlusProcess["Form"]("Ponemah Physiology Platform *")["Panel"]("Workspace")["MDIWindow"]("DRa*")["Caption"]

However, the script cannot see the object because 'Object Expected' is typically returned.  The first two modifications that I made, for other objects, I have not had any problems.  The last mod, changing "DRa  14% complete" to "DRa*" seems to be where my issue lies.  The caption for the form changes until it reaches 100% and then it goes to "DRa".  Why can I not get the caption with my modified code?


1 REPLY 1
Highlighted

RE: Unable to read caption of a form

Hello Michael,




You can use the '*' character in such methods of TestComplete as Window, Find, MDIWindow, etc. In this case, TestComplete will recognize this character as a special wildcard and  ignore any symbols. However, when you use the '*' character in the following line:

Log["Message"](w["WndCaption"] == "*t*"); //Log 3 

the script engine recognizes the character as an asterisk that belongs to the "*t*" string. The result of this comparison will be true only when the value of the caption is equal to "*t*" (not "complete").

--
Dmitry Nikolaev

Learn SmartBear products in a fun and easy way and prove your knowledge!
>>Participate in the TechCorner Challenge today
New Here?
Join us and watch the welcome video:
Announcements
Join TechCorner Challenge!
Want a fun and easy way to learn TestComplete? Try solving weekly TechCorner challenges and get into the Leaderboard!

Challenge Status

Changing options from outside of TestComplete

Participate!

How to execute remote test and obtain results via Test Runner REST API

Participate!

Comparing content of HTML table with Excel file data

Participate!

Compare HTML table with Excel file and correct data in the file

Participate!
Top Kudoed Authors