locked
Problem in identifying button in hand coded CODED UI in VSTS 2010 RRS feed

  • Question

  • Hi,

    I have recently started hand coding VSTS 2010 CODED UI looking at several self explanatory posts in net. I faced some basic problems as the control i tried to click was not found. 

    Extracts from my testmethod : [ Commented parts are which i tried but wasn't able to find the control anyhow]

                   BrowserWindow br = BrowserWindow.Launch("http://localhost/WEB_APP/page1.aspx");


                UITestControl page2button = new UITestControl(br);
                page2button.TechnologyName = "web";
                //page2button.SearchProperties.Add("controltype", "button");

                //page2button.SearchProperties.Add("id","btnpage2");
                //page2button.SearchProperties.Add(UITestControl.PropertyNames.ControlType, "button");
                page2button.SearchProperties.Add(UITestControl.PropertyNames.Name, "btnpage2");

                Mouse.Click(page2button);

    and the source code for the button look like this :

    <input type="submit" name="btnpage2" value="Page 2" id="btnpage2" />

    Now while executing the test it have passed once , for rest of the time it's failing with below result :

    Test method TEST_WEB.APP_TEST.WEB_APP threw exception: 
    Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotFoundException: The playback failed to find the control with the given search properties. Additional Details: 
    TechnologyName:  'web'
    Name:  'btnPage2'
     Failed to find any control that matched the value btnPage2 for the search property Name. ---> System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.

    Below the debug trace when it passed for once : The code is same for fail and pass cases 

    E, 5728, 14, 2013/03/21, 22:39:32.156, 251619529432, QTAgent32.exe, LoadLibrary() : Unable to find the resource 37382 from assembly C:\Windows\system32\en-US\ieframe.dll.mui: Error1814
    E, 5728, 14, 2013/03/21, 22:39:32.158, 251619532071, QTAgent32.exe, LoadLibrary() : Unable to find the resource 41728 from assembly C:\Windows\system32\en-US\ieframe.dll.mui: Error1814
    E, 5728, 14, 2013/03/21, 22:39:32.158, 251619532426, QTAgent32.exe, LoadLibrary() : Unable to find the resource 8131 from assembly C:\Windows\system32\en-US\ieframe.dll.mui: Error1814
    E, 5728, 14, 2013/03/21, 22:39:32.158, 251619532723, QTAgent32.exe, LoadLibrary() : Unable to find the resource 8131 from assembly C:\Windows\system32\en-US\ieframe.dll.mui: Error1814
    E, 5728, 14, 2013/03/21, 22:39:32.158, 251619533234, QTAgent32.exe, LoadLibrary() : Unable to find the resource 8131 from assembly C:\Windows\system32\en-US\ieframe.dll.mui: Error1814
    E, 5728, 14, 2013/03/21, 22:39:32.158, 251619533892, QTAgent32.exe, LoadLibrary() : Unable to find the resource 803 from assembly C:\Windows\system32\en-US\user32.dll.mui: Error1814
    E, 5728, 14, 2013/03/21, 22:39:32.214, 251619665276, QTAgent32.exe, IEDOM : Could not get valid window handle of Internet Explorer_server
    W, 5728, 14, 2013/03/21, 22:39:32.215, 251619665562, QTAgent32.exe, IEDOM : Unable to get the document Window Handle
    W, 5728, 14, 2013/03/21, 22:39:35.618, 251627623254, QTAgent32.exe, IEDOM : CreateWebControlEventHandler : Created OutProc EventSink
    W, 5728, 14, 2013/03/21, 22:39:35.620, 251627626692, QTAgent32.exe, IEDOM : CreateDocumentEventHandler : Created OutProc EventSink
    W, 5728, 14, 2013/03/21, 22:39:36.383, 251629411101, QTAgent32.exe, IEDOM : RetryScriptInitialization : First action on the page should be a non-hover action for implicit hover and inproc events Or Activex/Script is disabled on the page
    W, 5728, 14, 2013/03/21, 22:39:36.399, 251629449680, QTAgent32.exe, PERF WARNING: FindAllDescendents: took 658 ms. Expected it to take maximum 500 ms.
    W, 5728, 14, 2013/03/21, 22:39:36.797, 251630379987, QTAgent32.exe, <a class=success>Playback - {1} [SUCCESS] MouseButtonClick - "[web]Name='btnPage2'"
    \0</a>
    W, 5728, 14, 2013/03/21, 22:39:36.920, 251630667553, QTAgent32.exe, IEDOM : StopSession of the plugin called before StartSession
    W, 5728, 14, 2013/03/21, 22:39:36.920, 251630667819, QTAgent32.exe, UIA : StopSession of the plugin called before StartSession

    Am i doing anything wrong ? missing anything ? not understanding anything ?

    Kindly help ?

    WBR,

    Soumyageet

       
    Thursday, March 21, 2013 5:20 PM

Answers

  • Hello,

    Thank you for your post.

    I have recently started hand coding VSTS 2010 CODED UI looking at several self explanatory posts in net.

    Generally it is not recommended to hand code a coded UI test since you can’t know the UI and control structure completely and maybe some unknown issues in your code will fail to locate a target control.

    I suggest that you can try to record a mouse click action on the ‘page2button’ suing Coded UI Test Builder in the page1.aspx. Then you can run the coded UI test to check if the button can be found well.

    If yes, you can check the code in recorded method in UIMap.Designer.cs file to compare the differences between the code and your hand coding code.

    For example, you can check what properties of the button the CodedUI uses to search the control and how CodedUI uses the properties to locate the control.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Amanda Zhu Wednesday, March 27, 2013 8:17 AM
    Friday, March 22, 2013 5:40 AM

All replies

  • Hello,

    Thank you for your post.

    I have recently started hand coding VSTS 2010 CODED UI looking at several self explanatory posts in net.

    Generally it is not recommended to hand code a coded UI test since you can’t know the UI and control structure completely and maybe some unknown issues in your code will fail to locate a target control.

    I suggest that you can try to record a mouse click action on the ‘page2button’ suing Coded UI Test Builder in the page1.aspx. Then you can run the coded UI test to check if the button can be found well.

    If yes, you can check the code in recorded method in UIMap.Designer.cs file to compare the differences between the code and your hand coding code.

    For example, you can check what properties of the button the CodedUI uses to search the control and how CodedUI uses the properties to locate the control.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Amanda Zhu Wednesday, March 27, 2013 8:17 AM
    Friday, March 22, 2013 5:40 AM
  • Hello,

    Since we haven't heard from you for a long time, I temporarily close this case. I mark useful reply as answer. If you have any concerns, please feel free to reopen it or submit a new question.

    Thanks for your understanding.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, March 27, 2013 8:17 AM
  • Maybe your control is added dynamically by JavaScript? In that case use WaitForControlExist method before performing any action with it.
    Thursday, April 11, 2013 1:17 PM
  • Amamnda,

    Thanks , i was off for few days so wasn't able to try. I will try this and come back. 

    Thursday, April 18, 2013 1:29 AM
  • I'm doing hand-coded CUIT, which I blog about over at BurdetteLamar.wordpress.com.
    Sunday, April 6, 2014 4:36 PM