1
votes

When I try to run a simple coded UI test that I have written it is failing when I try to run the test. It fails on the first Mouse.Click statement (line 12 below).

In english the steps are as follows:

  1. Launch a new Internet Explorer Window (I find it odd that it's listed as "Click 'Chrome Legacy Window client').
  2. Go to the Contact Page (localhost:6983/Contact).
  3. Type "ardvark" into a text box and click the submit button.
  4. When the button is click copy "ardvark" to a label.

At this point I'm just expecting the test method to replay those steps.

Here is the generated code:

 public void RecordedMethod1()
    {
        #region Variable Declarations
        WinClient uIChromeLegacyWindowClient = this.UIVisualstudio2015CodeWindow.UIChromeLegacyWindowWindow.UIChromeLegacyWindowClient;
        HtmlCustom uIBgexitCustom = this.UIMSNCanadaHotmailOutlWindow.UIMSNCanadaHotmailOutlDocument.UIADFrame.UIAolAdvertisementDocument.UIVarinDapIFtrueinFIFtPane.UIItemFrame.UIHttpnym1ibadnxscomifDocument.UIItemFrame.UIHttpanimpbidaceadverDocument.UIItem200_141_express_Frame.UIHttps02mdnnet2467206Document.UIBgexitCustom;
        BrowserWindow uIMSNCanadaHotmailOutlWindow = this.UIMSNCanadaHotmailOutlWindow;
        HtmlEdit uIText1Edit = this.UIMSNCanadaHotmailOutlWindow.UIContactMyASPNETAppliDocument.UIText1Edit;
        HtmlInputButton uIClickMeButton = this.UIMSNCanadaHotmailOutlWindow.UIContactMyASPNETAppliDocument.UIClickMeButton;
        #endregion

        // Click 'Chrome Legacy Window' client
        Mouse.Click(uIChromeLegacyWindowClient, new Point(565, 497));

        // Set flag to allow play back to continue if non-essential actions fail. (For example, if a mouse hover action fails.)
        Playback.PlaybackSettings.ContinueOnError = true;

        // Mouse hover 'bg-exit' custom control at (1, 1)
        Mouse.Hover(uIBgexitCustom, new Point(1, 1));

        // Reset flag to ensure that play back stops if there is an error.
        Playback.PlaybackSettings.ContinueOnError = false;

        // Go to web page 'http://localhost:6983/Contact'
        uIMSNCanadaHotmailOutlWindow.NavigateToUrl(new System.Uri(this.RecordedMethod1Params.UIMSNCanadaHotmailOutlWindowUrl));

        // Type 'ardvark' in 'text1' text box
        uIText1Edit.Text = this.RecordedMethod1Params.UIText1EditText;

        // Click 'Click Me' button
        Mouse.Click(uIClickMeButton, new Point(43, 17));
    }

The following is the error I'm getting: The following is the error I'm getting: {"The playback failed to find the control with the given search properties. Additional Details: \r\nTechnologyName: 'MSAA'\r\nControlType: 'Client'\r\nName: 'Chrome Legacy Window'\r\n"}

1
What's the failure? - JWP
Which is line 12 and why are there more than 12 lines of code? Please read minimal reproducible example then cut down the code to the minimum needed and also show the failure details. - AdrianHHH
Hi Adrian... Unfortunately I can't help you verify the error, but as far as which line: It's the first mouse click ( described this in my initial sentence actually, but thank you for showing me the error of my ways ;) ): Mouse.Click(uIChromeLegacyWindowClient, new Point(565, 497)); I've also updated the question with the text from the error. - kickinchicken
I would expect that the autogenerated code for the chrome window is overly specific and does not find correctly on subsequent attempts. Please include the code for WinClient uIChromeLegacyWindowClient = this.UIVisualstudio2015CodeWindow.UIChromeLegacyWindowWindow.UIChromeLegacyWindowClient; - MPavlak
@NaeemA.Malik I think you are misunderstanding the Point() argument to Mouse.Click(). Please read blogs.msdn.microsoft.com/mathew_aniyan/2012/03/16/… . However the size of the values (ie 565, 497) plus the control name uIChromeLegacyWindowClient suggests that there is a big custom control, or perhaps an image or a canvas. - AdrianHHH

1 Answers

0
votes

Giving the points for mouse click should be the last option. The points won't be stable. Try to capture the element then perform mouse click on that. Or else write the search property dynamically in the code then perform click action.