TestComplete can't find WinForms object during runtime - winforms

I have an application written in WinForms and it contains a single TextBox.
With the TestComplete spy, I can spot the TextBox and its properties but during runtime, this control, in contrast to all the other controls, can't be spotted by its name or any of its other properties.
Why is that and how can I fix it (either on the application side or the testing side)?
This is how the control is defined:
this.myTxtBx.BackColor = System.Drawing.SystemColors.InactiveBorder;
this.myTxtBx.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.myTxtBx.Location = new System.Drawing.Point(74, 25);
this.myTxtBx.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.myTxtBx.Name = "myTxtBox";
this.myTxtBx.Size = new System.Drawing.Size(91, 20);
this.myTxtBx.TabIndex = 1;
this.myTxtBx.TextChanged += new
System.EventHandler(this.myTxtBox_TextChanged);

You need to map the object at runtime with objectmapper, give it an alias and use it in your script.
(TC has its own winapp driver protocol that reads the screen very much like W3Cs webdriver that all major browsers support to make automation possible).
Below is a js-function using WIX that finds an objectmapped form and enters a value (Your alias would probably be something like:
Aliases.YourApp.myTxtBx.TextChanged):
function policeIdCheck() {
var nomatch = "GC0000531";
var idnumform = Aliases.LraClient.ContentControl.ActionInfoContainerClearView.ContentControl.ActionInfoContainer.ItemsControl.IDDocNumberForm;
if(idnumform.Exists) {
Log.Message("IDPolice Check");
idnumform.Keys(nomatch);
}
}

Related

Using Dynamic CEFSharp with ChromeTabs but AddressChanged is not exposed

I am making an app that started with the CEFSharp minimal example code and I am using ChromeTabs in Wpf. I have my CEFSharp diverting popup windows into tabs correctly but I am having an issue grabbing the URL of these dynamic CEFSharp windows. For some reason AddressChanged is not exposed for these dynamic windows. I have tried to make use of LoadingStateChanged to place the URL in a textbox but that creates all new issues with the threads. I have spent the past few days trying to get this to work and it is driving me crazy. This is how my new tab is created but it does not expose AddressChanged event.
int counttabs = tbControlRCI.Items.Count-1;
string popURL;
popURL = popup_request;
tbControlRCI = this.etTabCntrlRCI;
//here we should open a new tab and place a new rcibrowser in it and give it the url
RCIBrowser = new ChromiumWebBrowser(popURL);
RCIBrowser.Name = "RCIBrow_" + counttabs;
string shorturl = popURL.Substring(popURL.LastIndexOf("/"), popURL.Length - popURL.LastIndexOf("/"));
ChromeTabs.ChromeTabItem newTabItem = new ChromeTabs.ChromeTabItem
{
Header = shorturl,
Name = "RCITab_" + counttabs,
Content = RCIBrowser
};
LifespanHandler lifeRCI = new LifespanHandler();
RCIBrowser.LifeSpanHandler = lifeRCI;
lifeRCI.popup_request += life_popup_request;
tbControlRCI.Items.Add(newTabItem);
tbControlRCI.SelectedIndex = tbControlRCI.Items.Count - 1;
My XAML only has a ChromeTabsControl that I place all of these dynamic Tabs and Browsers into.
Can anyone show the error of my ways?
EDIT:
Ok, thanks amaitland, I have tried a few different ways to do that and it just does not update for some reason. All I need is a textbox to show the address the Browser is on, so one way is fine. So I tried this:
Binding b = new Binding();
b.Mode = BindingMode.OneWay;
b.Path = new PropertyPath("Address");
b.ElementName = "RCIBrowser";
txtbxRCI.SetBinding(TextBox.TextProperty, b);
Thanks a bunch,
Hometownnerd

Having issue with slow typing in Windows Forms App

I am writing a Windows Forms App with a ComboBox. It is a DropDownList with SuggestAppend. When the user types, it should position to the item meeting the keyed letters. If they type reasonably fast, this works as expected. If there is even a short delay in keystrokes, it starts over thinking it is a different value. Unfortunately, I have a number of one fingered typists (not even two fingers) and they can't type fast enough.
Here is the code as the designer created it...
this.cbxItemDescription.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend;
this.cbxItemDescription.AutoCompleteSource = sysem.Windows.Forms.AutoCompleteSource.ListItems;
this.cbxItemDescription.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbxItemDescription.FormattingEnabled = true;
this.cbxItemDescription.Location = new System.Drawing.Point(75, 2);
this.cbxItemDescription.Name = "cbxItemDescription";
this.cbxItemDescription.Size = new System.Drawing.Size(300, 21);
this.cbxItemDescription.TabIndex = 2;
this.cbxItemDescription.Visible = false;
this.cbxItemDescription.SelectedIndexChanged += new System.EventHandler(this.cbxItemDescription_SelectedIndexChanged);`
It is loaded by the line...
cbxItemDescription.Items.Add(value to be added);
Can anyone tell me how to extend the interval so it can accommodate these slow typists?
I have found answers for WPF ComboBoxes but unless I am not understanding the solution, they won't work for Windows Forms.

Coded UI test is not running while setting the UIElementText in the Playback

I have recorded the coded UI test using the VS2015 Coded UI Test builder. based on my recording the following function is created for my test method,
public void RecordedMethod1()
{
#region Variable Declarations
WpfText uIItemText = this.UIMainWindowWindow.UIAddNewRowControlCustom.UIGridCellCustom.UIItemText;
WpfEdit uIItemEdit = this.UIMainWindowWindow.UIAddNewRowControlCustom.UIGridCellCustom.UIItemEdit;
WpfText uIItemText1 = this.UIMainWindowWindow.UIAddNewRowControlCustom.UIGridCellCustom1.UIItemText;
#endregion
// Double-Click label
Mouse.DoubleClick(uIItemText, new Point(73, 3));
//// Failed in the following line and the test is not running after that.
// Type 'aaa' in text box
uIItemEdit.Text = this.RecordedMethod1Params.UIItemEditText;
// Double-Click label
Mouse.DoubleClick(uIItemText1, new Point(79, 10));
// Type 'bbb' in text box
uIItemEdit.Text = this.RecordedMethod1Params.UIItemEditText1;
// Type '{Enter}' in text box
Keyboard.SendKeys(uIItemEdit, this.RecordedMethod1Params.UIItemEditSendKeys, ModifierKeys.None);
}
After reaching the line to set the recorded value to the uiEditItem.Text the test case is not running further cased the failure in the test case.
I have googled for the solution and have found a one that says, you need to rewrite the test cases with the Kebord.SendKeys instead of directly setting the value to the Text property of the EditItem.
By this way I have made my code changes at the line as follows and its working.
// Type 'aaa' in text box
//uIItemEdit.Text = this.RecordedMethod1Params.UIItemEditText;
// Replaced the above line with the SenKeys
Keyboard.SendKeys(this.RecordedMethod1Params.UIItemEditText);
Is that the only solution for this problem (Manullay rewrite the test methods by using the SendKeys method instead of directly assigning a value to the uiEditItem.Text property) ? If not, please provide the feasible solution for this.

Layout issue with Codename One

At this moment I'm only testing my app in the simulator (as I'm having issues with "Send iOS Build" mentioned in another thread [Errors with Codename One "Send iOS Build" and "Send Android Build")
I'm experiencing some layout issues where it is not making use of the width and height correctly. The elements are left-aligned and there is unused space on the right side. And I need to scroll up and down instead of having everything fit within the visual area. Please see images.
The code are:
private final void show() {
loginSignupForm = new Form("Company", new BoxLayout(0));
Tabs loginSignupTabs = new Tabs();
Style loginSignupStyle = UIManager.getInstance().getComponentStyle("Tab");
prepareAndAddSignupTab(loginSignupTabs, loginSignupStyle);
prepareAndAddLoginTab(loginSignupTabs, loginSignupStyle);
loginSignupForm.add(loginSignupTabs);
loginSignupForm.show();
}
private void prepareAndAddLoginTab(Tabs loginSignupTabs, Style loginSignupStyle) {
loginID = new TextField();
loginPassword = new TextField();
Button loginButton = getLoginButton();
Component[] loginComponents = {
new Label("Email Address"),
loginID,
new Label("Password"),
loginPassword,
loginButton,
};
Container loginContainer = BoxLayout.encloseY(loginComponents);
FontImage loginIcon = FontImage.createMaterial(FontImage.MATERIAL_QUESTION_ANSWER, loginSignupStyle);
loginSignupTabs.addTab("Login", loginIcon, loginContainer);
}
What do I need to changenter code heree to get the elements to:
1. expand to the maximum width (no free space on the right)
2. fit within the visual area (for top-to-bottom)
Please note that I'm coding the elements because I find the (new) GUI Builder quite a challenge to use.
Firstly, don't pass a constant value as an argument to Layouts, coz the values might change in future Codename One updates and this will be difficult for you to debug. new BoxLayout(0) should be new BoxLayout(BoxLayout.Y_AXIS) or simply BoxLayout.y().
The above is where the problem arose but not the only problem because BoxLayout doesn't recognize 0 as a valid argument as it has only 3 which are X_AXIS = 1, Y_AXIS = 2, and X_AXIS_NO_GROW = 3.
If you change the above to use BoxLayout.Y_AXIS, it will work, but from the screenshot above, that's not the best solution.
In conclusion, change your code to below:
private final void show() {
loginSignupForm = new Form("Company", new BorderLayout());
Tabs loginSignupTabs = new Tabs();
Style loginSignupStyle = UIManager.getInstance().getComponentStyle("Tab");
prepareAndAddSignupTab(loginSignupTabs, loginSignupStyle);
prepareAndAddLoginTab(loginSignupTabs, loginSignupStyle);
loginSignupForm.add(BorderLayout.CENTER, loginSignupTabs);
loginSignupForm.show();
}

codenameone Picker Alternative to ComboBox

I am getting my feet wet with Codename One. I have looked into more other options like Xamarin, PhoneGap, Ionic for cross platform but I kinda got hooked with Codename one as it really code once and run anywhere.
I've been going through ui elements and I am kinda blocked on populating a combobox (Alternative is Picker)
Let's say I have stores as value pair (storeId, storeName). I want to display the storeName in Picker but keep storeId as the value reference.
Once the store is selected I would like to pass the storeId to an API call.
Is this possible. This might be very simple question but seems bit difficult to implement (I am really new to mobile).
Thank you.
Our recommendation is to avoid ComboBox. It's a UI pattern that doesn't exist on iOS natively and would feel alien on modern phones. It exists in Codename One.
In this code from the sample above you can get a similar effect to a complex multi-field combo box:
Form hi = new Form("Button", BoxLayout.y());
String[] characters = { "Tyrion Lannister", "Jaime Lannister", "Cersei Lannister"};
String[] actors = { "Peter Dinklage", "Nikolaj Coster-Waldau", "Lena Headey"};
int size = Display.getInstance().convertToPixels(7);
EncodedImage placeholder = EncodedImage.createFromImage(Image.createImage(size, size, 0xffcccccc), true);
Image[] pictures = {
URLImage.createToStorage(placeholder, "tyrion","http://i.lv3.hbo.com/assets/images/series/game-of-thrones/character/s5/tyrion-lannister-512x512.jpg"),
URLImage.createToStorage(placeholder, "jaime","http://i.lv3.hbo.com/assets/images/series/game-of-thrones/character/s5/jamie-lannister-512x512.jpg"),
URLImage.createToStorage(placeholder, "cersei","http://i.lv3.hbo.com/assets/images/series/game-of-thrones/character/s5/cersei-lannister-512x512.jpg")
};
MultiButton b = new MultiButton("Pick A Lanister...");
b.addActionListener(e -> {
Dialog d = new Dialog();
d.setLayout(BoxLayout.y());
d.getContentPane().setScrollableY(true);
for(int iter = 0 ; iter < characters.length ; iter++) {
MultiButton mb = new MultiButton(characters[iter]);
mb.setTextLine2(actors[iter]);
mb.setIcon(pictures[iter]);
d.add(mb);
mb.addActionListener(ee -> {
b.setTextLine1(mb.getTextLine1());
b.setTextLine2(mb.getTextLine2());
b.setIcon(mb.getIcon());
d.dispose();
b.revalidate();
});
}
d.showPopupDialog(b);
});
hi.add(b);
hi.show();
If you insist on using a ComboBox you can use a model to give it any object data you want. Then create a cell render to display the data. This is all discussed in depth in the component section of Codname One's developer guide. Notice that since ComboBox derives from List a lot of the List tips and docs apply to ComboBox.

Resources