locked
Why does the WaitForControlExist() function returned 'false' during the Coded UI project running the second test case?

    Question

  • Hi All,

    I have run into a problem during running Coded UI project.

    The WaitForControlExist() function returned 'false' to check whether the UI Control is existing or not during the Coded UI project running the second test case(suppose the second test case is same as the first test case). In fact, the UI Control was existed.

    See my code as following:

    public void signIn(string strUserName, string strUserNamePassowrd)

    {

    #region Variable Declarations

    HtmlEdit uIWindowsLiveIDEdit = this.UIWelcometoWindowsLiveWindow1.UIWelcometoWindowsLiveDocument.UIWindowsLiveIDEdit;

    HtmlEdit uIPasswordEdit = this.UIWelcometoWindowsLiveWindow1.UIWelcometoWindowsLiveDocument.UIPasswordEdit;

    HtmlInputButton uISigninButton = this.UIWelcometoWindowsLiveWindow1.UIWelcometoWindowsLiveDocument.UISigninButton;

    #endregion

    bool exist = uIWindowsLiveIDEdit .WaitForControlExist();

    if (exist)

    {

    // Type 'XXXXXX' in 'Windows Live ID:' text box

    uIWindowsLiveIDEdit.Text = strUserName;

    // Type '{Tab}' in 'Windows Live ID:' text box

    Keyboard.SendKeys(uIWindowsLiveIDEdit, this.signInAnswersWin2008R2Params.UIWindowsLiveIDEditSendKeys, ModifierKeys.None);

    // Type '********' in 'Password:' text box

    uIPasswordEdit.Password = strUserNamePassowrd;

    // Click 'Sign in' button

    Mouse.Click(uISigninButton, new Point(36, 9));

    }

    }

    then the value of exist is 'true' during running the first test case, but it is 'false' during running the second test case.

    In addition, if I checked that control whether is existing or not by using

    bool browserExist = this.UIWelcometoWindowsLiveWindow1.WaitForControlExist();

    it will prompt the error message: 'COM object that has been separated from its underlying RCW cannot be used.'  during running the second test case.

    But, it can be continue running the following steps(input username&password) without any errors during running the second test case if I was not using WaitForControlExist() function to check that UI control.

     

    So, my question is that why does the WaitForControlExist() function returned 'false' during the Coded UI project running the second test case? And in this case, which function should to be used to check one UI Control is existing or not?

     

    BTW, my testing environment is:

    OS: windows2008R2

    VS2010 Ultimate with Feature Pack2

    .NET4.0

    IE8.0,

    And I found that it is the same issue if it is running on the Windows7 & IE9 box

    Thursday, December 22, 2011 9:29 AM

Answers

All replies