Forum Discussion

cvanvlack's avatar
cvanvlack
Occasional Contributor
4 months ago
Solved

What is the correct format for WaitWPFObject in Python?

Here is the name mapping when I use the object spy

I am running the application and getting the process with 

process <SPAN class="token operator">=</SPAN> TestedApps<SPAN class="token punctuation">.</SPAN>Virtek_Applications_ServerManager<SPAN class="token punctuation">.</SPAN>Run<SPAN class="token punctuation">(</SPAN>count<SPAN class="token punctuation">,</SPAN> ignore_running<SPAN class="token punctuation">,</SPAN> timeout_ms<SPAN class="token punctuation">)</SPAN>



and attempting to make sure it exists via

 o <SPAN class="token operator">=</SPAN> process<SPAN class="token punctuation">.</SPAN>WaitWPFObject<SPAN class="token punctuation">(</SPAN><SPAN class="token string">'WPFObject("HwndSource: ShellView", "Virtek Iris")'</SPAN><SPAN class="token punctuation">,</SPAN> timeout_ms<SPAN class="token punctuation">)</SPAN>



However 

o<SPAN class="token punctuation">.</SPAN>Exists


is returning False even though the application is definitely open.

Here are the docs I have been using for reference, 
https://support.smartbear.com/testcomplete/docs/reference/project-objects/items/tested-apps/testedapp/run.html

https://support.smartbear.com/testcomplete/docs/reference/test-objects/controls/desktop/general/process/index.html

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/window-and-process/waitwpfobject-method.html

However, the WaitWPFObject doc doesn't actually have a code snippet example to follow. 

 




  • This was SUPER helpful. Thank you very much!!

    Here is what I learned after using this example. 

    1. Basically, whatever arguments you can get to work for the WPFObject Method, you need to use the exact same arguments for the WaitWPFObject Method.

    2. I had misread the API and thought the WndCaption was optional. So I passed the ClassName, but left off the WndCaption so the function overloaded to assume I was passing in the Name.

    So when I was using 

    p = Sys.Process("VirtekIrisClient")
    o = p.WaitWPFObject("HwndSource: ShellView",timeout_ms)

    It wouldn't work. When I used

    p = Sys.Process("VirtekIrisClient")
    o = p.WaitWPFObject("HwndSource: ShellView","Virtek Iris",timeout_ms)

    It worked.

9 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I have no idea what process <SPAN class="token operator">... is about?

    It will be something along the lines of,

    Sys.Process("VirtekIrisClient").WaitWPFObject("WPFObject", "HwndSource: ShellView", 5000)

    This will wait up to 5 seconds for the object "WPFObject" to appear with the caption "HwndSource: ShellView"

    • cvanvlack's avatar
      cvanvlack
      Occasional Contributor

      Thanks for the response! I have absolutely no idea what happened with those code blocks as that's not what I had put there... I'll try to edit the original message to try to fix it.

      • cvanvlack's avatar
        cvanvlack
        Occasional Contributor

        The code blocks keep adding that stupid span object. Here's the actual code.
        p = TestedApps.Virtek_Applications_ServerManager.Run(count, ignore_running, timeout_ms)
        o = p.WaitWPFObject('WPFObject("HwndSource: ShellView", "Virtek Iris")', timeout_ms)
        o.Exists