I use the assertion function to identify controls. When I use the assertion function for the Coded UI Test (Ctrl + Shift + I) the menu items in my .NET application running on Windows 10 are always recogniced at the wrong position. I use Visual Studio 2017 Enterprise (version 15.5.7).
My cursor was at the "Öffnen" menu item but the MSAA thinks it is the "Speichern" menu item. It seems shifted for one menu entry.
For other application the control identification works fine. It seems a problem with this particular application.
What could possibly be wrong in using Coded UI Test Builder?
Update
I also tried to increase the MaxLevelsForItemContainer from the default value of 2 to 5 in the CodedUITestBuilder.exe.config without success.
The SearchConfiguration.NextSibling() method didn't work either.
It is probably an issue with the Spiechern button masking the Öffnen button -
atleast so far as the test builder sees it.
Try navigating to the Öffnen button through usage of the parent child navigator in the test builder (the button button 4 arrows around a blue box, next to Retry and Add Assertion), and then identify with the NextSibling() method. This would look like:
// Clicks Öffnen - Change NextSibling()to be whatever filial relation is required
var offnen = new WpfButton();
offnen = offnen.SearchProperties.Add(WpfButton.PropertyNames.Name, "Spiechern").NextSibling();
offnen.Click();
If that doesn't work set your tests up to use the identification of the Spiechern button, and then alter the portion that needs to click on the Öffnen button to click slightly above above the Spiechern button. That would look like:
// Clicks Öffnen - Change xOffset and yOffset to whatever is required to click Öffnen
var spiechern = new WpfButton();
spiechern= spiechern.SearchProperties.Add(WpfButton.PropertyNames.Name, "Spiechern");
Mouse.Click(spiechern, new Point(xOffset, yOffset));
I was able to do what I wanted by using the menu keyboard shortcuts and navigating through the menu and record this.
Possible solution in this case:
use keyboard shortcuts
After an Visual Studio 2017 Enterprise update from version 15.5.7 to 15.6.1 the menu item was recognized correctly. I'm not aware of any other change I did on my system but since the update it seems to work.
Solution:
Update Visual Studio 2017
Related
I'm using visual studio 2010 and i'M creating aN MFC dialog based application. Everything was working fine until recently when the add variable wizard stopped showing up when we right click on a control in main dialog and choose add variable.
I have 3 dialogs in the project. The add variable wizard shows up for the other dialogs. Only for the main dialog the wizard is not showing up, ie. nothing
is happening when we right click and choose add variable on say picture control embedded in main dialog.
I'm using 64 bit Windows 7.
The problem was ID mismatch(ID of main dialog) in the properties of dialog and the header of the corresponding class of the dialog. It is fixed and is working correctly now.
Using MFC in Visual Studio 2012
I want to use a CMFCColorButton in a dialog in my application.
I added the CMFCColorButton button to my dialog in the resource editor (test it, works OK); click on the button and the underlying CMFCColorPopupMenu is display and stay displayed until manually dismissed (choosing a color or clicking somewhere else).
When I build my application and try the button in the dialog, it works differently, when I click the button, the underlying CMFCColorPopupMenu is displayed and immediately dismissed. If I want to select a color, I need to keep the mouse button down.
I tried in a different application (default MFC application) and I get the desired behavior (click and the CMFCColorPopupMenu stay visible).
I am not certain what could trigger the behavior difference.
I try toggling the CMFCColorButton::m_bAutoSetFocus value of the button and there is no change of behavior. ( I am not certain what is the purpose of this variable, but that is another subject)
Any ideas? hints/tips?
Thanks,
Max.
I've been trying to create a custom toolbar in a MFC project in Visual Studio 2010. I've been following the Sketcher tutorial in Ivan Horton's Beginning Visual C++ 2010. The problem I'm running into is that the toolbar doesn't update to reflect the order and spacing of icons I have created.
I've created a small screenshot to demonstrate the problem:
In the background is the visual studio toolbar editor with my desired toolbar configuration. In the foreground is the actual app, which does not reflect the spacing or order of icons I've designed. It does reflect NEW icons being added, and the icons work fine, but I just can't seem to get them to re-order or appropriately space themselves. They just append to the end in whatever order I create them.
I've tried the rudimentary techniques of restarting both VS and windows, but to no avail.
Any tips on getting it to play nicely? Lacking that, is there somewhere to manually view or edit the code generated by the toolbar editor?
For starters, if you create an MFC SDI/MDI project in VS.NET 2005, there is no such issue. It happens in VS.NET 2008 and 2010.
In fact, your rearrangement of the standard toolbar does takes effect. It's just not showing you the default state. To restore the state: click the small arrow button at the end of toolbar -> Add or Remove Buttons -> Standard -> Reset Toolbar.
Though I'm not 100% sure why it happens like this(design like this or a bug), there is a way to work around it and it works:
Add following code to the end of CMainFrame::LoadFrame(...)
BOOL CMainFrame::LoadFrame(UINT nIDResource, DWORD dwDefaultStyle, CWnd* pParentWnd, CCreateContext* pContext)
{
...
// Explicitly restore toolbar state
m_wndToolBar.RestoreOriginalstate();
return TRUE;
}
I recommend you to contact Microsoft support engineers as there's little resource on the web.
The reason could be that the toolbar state is already loaded from the registry whenever your application starts. So the framework reads the toolbar state and adds the new buttons to the end. Is there a Workspace key in your Registry and did you try to delete it anytime you make changes to the toolbar? The key should be at a location like HKEY_CURRENT_USER\Software\MyCompany\MyApp\Workspace
The values for MyCompany and MyApp are usually set in InitInstance. Always calling RestoreOriginalState() would break the code to allow user modifications to the toolbar.
I am developing a simple c++ program inside Microsoft Visual Studio. This program will later be convert to DLL, in order to register it to Internet Explorer.
Inside my program, I would like to do like this:
if flag=1,
toolbar_button = green;
else
toolbar button = red;
I want to create a simple button on the Internet Explorer, and the button can reflects the color that I pass from my c++ program.
How can I achieve this?
Update: So far, I follow this manual http://msdn.microsoft.com/en-us/library/aa753588%28VS.85%29.aspx#details_script . I do it inside my Windows XP and IE8. It still does not work. No button appear on the IE toolbar.
I have a MFC MDI application that I've recently ported from VS2003 to VS2008, and at the same time moved from Stingray Objective Studio 2006 v2 to v10.1. On the previous versions of my application, if I had more than one view open, the Window menu would be populated by an enumerated list of available views, e.g. 1 MyViewA, 2 MyViewB etc... If I had a large number of views, I would also get a Windows... menu option to allow me to select a view. This no longer happens, which is breaking some of my GUI level regression tests. My guess is that this functionality was implemented by either CMDIFrameWnd or SECMDIFrameWnd but I couldn't find a reference to it in the documentation. Does anyone know how I can get this functionality back.
First thing I'd do is create a new MDI application with the ClassWizard and check if the functionality you're missing is present. If so, poke around and see if you can tell what's different. One place to look may be the menu resource for the main menu.
If there is no in-built functionality to provide what you need, you can dynamically build the menu with the following pseudocode:
foreach registered CDocumentTemplate
foreach document
foreach view
{
if (numberOfWindowMenuItems < 5)
{
Add menu item
}
else
{
Add "Windows..." menu item
break all loops;
}