Is there any possibility to commit a value of a variable (declared as string) on a SelectedItem of a ComboBox in a Coded UI Test?
for instance:
private const string SALUTATION = "Mr.";
...
CommonMap.SalutationParams.LstEntriesSelectedItemsAsString = SALUTATION;
CommonMap.Salutation();
...
I am getting an error because of trying this:
Result Message:
Test method CodedUIClassicCommon.Common.CodedUITestsCommon.CodedUIClassicCommonNeuerBenutzerWeiblich threw exception:
Microsoft.VisualStudio.TestTools.UITest.Extension.PlaybackFailureException: Cannot perform 'SetProperty of SelectedItemsAsString with value "A.Frau/SgF"' on the control. Additional Details:
TechnologyName: 'MSAA'
ControlType: 'List'
---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0xF004F008
TestCleanup method CodedUIClassicCommon.Common.CodedUITestsCommon.MyTestCleanUp threw exception. Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToPerformActionOnHiddenControlException: Microsoft.VisualStudio.TestTools.UITest.Extension.FailedToPerformActionOnHiddenControlException: Cannot perform 'Click' on the hidden control. Additional Details:
TechnologyName: 'MSAA'
Name: 'Neu Ctrl+N'
ControlType: 'MenuItem'
---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0xF004F002.
I have searched in google for such a problem but i couldn't resolve it.
thanks for any help.
eric
Should
CommonMap.SalutationParams.LstEntriesSelectedItemsAsString = SALUTATION;
Have a dot between the LstEntries and SelectedItemsAsString?
CommonMap.SalutationParams.LstEntries.SelectedItemsAsString = SALUTATION;
Can you confirm that the object you are trying to click on is in fact visible? If you are clicking on a MenuItem that is hidden because the list needs to be expanded/scrolled/etc it will throw an error. This would be my first thought.
Also, I prefer to use the PerformSelect of the MenuItem rather than reassigning the value.
Related
I get the following error at runtime from a C# WPF application:
A first chance exception of type
'System.Windows.Markup.XamlParseException' occurred in
PresentationFramework.dll
Additional information: 'Set property
'System.Windows.Controls.ContentControl.Content' threw an exception.'
Line number '6' and line position '6'.
How can I find which file this is associated with? The Visual Studio solution contains two XAML files, app.xaml and MainWindow.xaml.
I am using VS 2010 on Windows 7. The application targets .NET 4.0.
UPDATE:
Following up on Kasper's helpful suggestion, I displayed the exception in detail, and this is what it showed:
Based on the information in there, I was able to gather that a certain DLL was missing. Supplying the DLL fixed this problem, but I still have other XAML parse errors coming up.
In the code-behind, the XAML code is parsed in the method InitializeComponent which is automatically generated. This method is called in the Window object's constructor. So to have more details about the exception, put the call to InitializeComponent in a try/catch block. This way, you have access to the useless XamlParseException, but also to its InnerExceptions and to the StackTrace.
UPDATE!
You can call the inner exception using a MessageDialog.
public partial class Window1 : System.Windows.Window
{
public Window1()
{
try
{
InitializeComponent();
}
catch ( Exception ex )
{
// Log error (including InnerExceptions!)
// Handle exception
MessageDialog dialog = new MessageDialog(ex.InnerException);
dialog.ShowAsync();
}
}
}
Hope that helps :)
There is also another trick to this:
Open the "Exceptions" window (Debug/Exceptions) in Visual Studio.
Click "add"
Add "System.Windows.Markup.XamlParseException"
Check the box to break on throw for this exception.
Hit F5!
You'll find that the XamlParseException you catch is much more descriptive, and will give the correct position in the xaml file.
Let me know if this was easier :)
I want to know if it's possible to get / know the current page in wpf.
In my project, I put this code and I have the correct page:
var current_page = (Window.Current.Content as Frame).Content.GetType();
Windows.Current.Content was null.
But in my UI Test project, I have the following error:
Result Message:
Test method CodedUITestProject1.CodedUiTest.CodedUITestMethod1 threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
The C# line below generates an error:
Excel.Worksheet wks = (Excel.Worksheet)wbk.Worksheets.Add(After: wbk.Worksheets.Count);
I intend for the code to create a new worksheet in the workbook wbk, but no new worksheet is created. Instead I get an error.
The error message I receive is:
A first chance exception of type
'System.Runtime.InteropServices.COMException' occurred in
Microsoft.Office.Interop.Excel.dll
How do I learn more about this error so that I can resolve it?
View detail tells me nothing that makes sense to me. Check the error code property of the exception to determine the HRESULT returned by the COM object tells me nothing that makes sense to me.
I don't know how to move forward with error searching from here.
What property or method call exactly fires the exception?
I'd recommend breaking the chain of calls and declaring each property or method on a separate line of code. Thus, you will be able to find the exact one which fires the exception.
Also try to specify optional parameters explicitly:
Excel.Worksheet wks = (Excel.Worksheet)wbk.Worksheets.Add(Type.Missing, wbk.Worksheets[1], Type.Missing, Type.Missing);
Pay attention to the fact that you need to specify the sheet after which the new sheet is added, not a number!
The error message:
A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.Office.Interop.Excel.dll
Is just a notification from a handled exception, you should have a try catch surround your call:
Excel.Worksheet wks = (Excel.Worksheet)wbk.Worksheets.Add(After: wbk.Worksheets.Count);
Try intercept the real exception.
An exception of type 'System.Exception' occurred in PresentationFramework.dll but was not handled in user code
Additional information: The component 'System.Data.Entity.DynamicProxies.Product_05FB87F8C316B6DF15988BC9D5490B22CB7A8FD7DD4DBD1126E065199C01A696' does not have a resource identified by the URI '/CRUDusingWPF;component/product.xaml'.
I do not think you have given enough info for others to help you.
Are you trying to use a DataTemplate for a Product?
Try turning off proxy creation and see if that makes a difference.
context.Configuration.ProxyCreationEnabled = false;
Additional information: Object reference not set to an instance of an object.
I have this code
DotTeachDataSet ds;
DotTeachDataSetTableAdapters.QuestionsTableAdapter ta;
private void button1_Click(object sender, RoutedEventArgs e)
{
ta.CreateQuestion(discussionQuestion.Text, webPage.Text, choiceA.Text, choiceB.Text, choiceC.Text, choiceD.Text, hint.Text, rightAnswerCbox.Uid);
ta.Fill(ds.Questions);
}
That Im using to try to get the values from text boxes in a xaml and send them to a data base but I keep getting the error:
An unhandled exception of type
'System.NullReferenceException'
occurred in DotTeach.exe
Additional information: Object
reference not set to an instance of an
object.
and visual studio highlights the line
ta.CreateQuestion(discussionQuestion.Text, webPage.Text, choiceA.Text, choiceB.Text, choiceC.Text, choiceD.Text, hint.Text, rightAnswerCbox.Uid);
Does anyone have any ideas what i could try?
I got rid of the error message but it's still not doing what I need it to do. I'm trying to get it to add data to a database when the button is clicked. Heres the function I'm using thats not working
private void button1_Click(object sender, RoutedEventArgs e)
{
DotTeach.DotTeachDataSet dotTeachDataSet = ((DotTeach.DotTeachDataSet)(this.FindResource("dotTeachDataSet")));
DotTeach.DotTeachDataSetTableAdapters.QuestionsTableAdapter dotTeachDataSetQuestionsTableAdapter = new DotTeach.DotTeachDataSetTableAdapters.QuestionsTableAdapter();
//ADD THE QUESTION TO THE DATA BASE
dotTeachDataSetQuestionsTableAdapter.CreateQuestion(discussionQuestion.Text, webPage.Text, choiceA.Text, choiceB.Text, choiceC.Text, choiceD.Text, hint.Text, rightAnswer.Text);
}
I'm not even sure what else to try.
Well, to get a NullReferenceException, one of the following is null:
ta
discussionQuestion
webPage
choiceA
choiceB
choiceC
choiceD
hint
rightAnswerCbox
My guess would be ta, but you should be able to find that out either with logging or in the debugger. What's meant to be assigning a non-null value to ta?
Is this always failing (in which case it'll be easy to diagnose) or only sometimes?
When VS highlights the line in debug , why not try placing your mouse over each one of the items Jon has mentioned and look what the debug info tells.Identify which item(s) is(are) null and then investigate why thats null.( There must be a reason ! )