Why does the WaitForControlExist() function returned 'false' during the Coded UI project running the second test case?
-
Thursday, December 22, 2011 9:29 AM
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
All Replies
-
Thursday, December 22, 2011 10:21 AM
Hi,
I've recorded the same scenario in Windows 7 & IE8 box. However, i'm not able to replicate the error.
Anyways,
try the following code, to verify whether 'uIWindowsLiveIDEdit' exists or not
if (uIWindowsLiveIDEdit.Exists)
{
}
Thanks, Narasimha... Please mark it as answer, if this reply answerd your question -
Friday, December 23, 2011 5:04 AM
Hi,
Thank you for your reply.
And it was the same issue by using 'Exists' property to check that UI Control status.
The 'Exists' property also returned 'false' during the Coded UI project running the second test case.
-
Tuesday, December 27, 2011 3:55 AMModerator
Hi AlexZhu,
Thank you for posting in the MSDN forum.
Tapas wrote a blog, it told about how to validate the control’s existence and the WaitForReady Issues, see http://blogs.msdn.com/b/tapas_sahoos_blog/archive/2011/11/07/troubleshooting-record-and-playback-issues-in-coded-ui-test.aspx.
The error message: 'COM object that has been separated from its underlying RCW cannot be used.'
I find two useful threads, see:
http://social.msdn.microsoft.com/Forums/ar-SA/vsautotest/thread/628ff454-68b5-41dd-a709-498f197a1b5d
http://social.msdn.microsoft.com/Forums/en-US/vsautotest/thread/90974f08-dce9-41c3-a323-87771e69dfff
Hope it can help.
If no helps, please attach your Visual Studio project or a simple similar App, you can upload it to the sky driver, and then share the download link in your post. You can post the steps about recording the UI test in your reply. We try to record the same UI test and check it.
If there's any concern, please feel free to let us know.
Have a nice day,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator Monday, January 09, 2012 3:24 AM
-
Thursday, December 29, 2011 8:34 AMModerator
Hi AlexZhu,
I am writing to check the status of the issue on your side.
What about this problem now?
Would you mind letting us know the result of the suggestion?
Best Regards,
Jack Zhai [MSFT]
MSDN Community Support | Feedback to us
- Edited by Jack Zhai - MSFTMicrosoft Contingent Staff, Moderator Thursday, December 29, 2011 8:47 AM

