How to read text in Coded UI? [duplicate] - testing

This question already has an answer here:
How to I inject programmatic text into my Coded UI test (as opposed to recorded text) in Visual Studio?
(1 answer)
Closed 7 years ago.
In Coded UI, I have to confirm a particular text is present in text-box.
I am able to reach up to the dialog box and i know how to enter text. However. now i need to read text from the box.
Is there a WinApplication command that can help me to do so?

You can just read the text out in the same way that an assertion reads the text to check its value. One way of learning how to do this on any control is to use the Coded UI recorder to create an assertion method on the text shown and copy its code. Commonly the assertion will be on the DisplayText field. In fact that is a neat way of getting the relevant UI Controls created for you.
The method created for the assertion (in the UIMap.Designed.cs file) will be similar to:
public void AssertMethod1()
{
SomeUIType uITTextItem = this.UISomeWindow.UISomewhere.UITextItem;
Assert.AreEqual(this.AssertMethod1ExpectedValues.UITextItemDisplayText,
uITextItem.DisplayText,
"A message for a failed assertion");
}
Just copy the whole method into the UIMap.cs file, use the commend in the UI Map editor. Then save all the files.
Edit the method that is now in the UIMap.cs file to something like the following:
public string GetTheUITextItem()
{
SomeUIType uITTextItem = this.UISomeWindow.UISomewhere.UITextItem;
return this.AssertMethod1ExpectedValues.UITextItemDisplayText;
}
Now the contents of the test can be obtained by calling GetTheUITextItem().

Related

How to add TextChanged event to the label in xamarin.forms? [duplicate]

This question already exists:
Is there any way to add TextChanged event to a Label? [duplicate]
Closed 3 years ago.
I've been working on a mobile chat application and displaying the messages in the inbox of a user using a label. I need to detect URLs, tags and some special kind of text. text may change at any time. I need to implement the TextChanged event for the Label. So that I can perform my operations to detect URLs, tags, etc.
All the text in the above image will be displayed using a single label. Whenever the text is changed, the label should detect the TextChanged event and update the colors and decorations of the detected URLs and tags using spans.
We did this in WPF using TextBlock control. Now we have to implement it in our mobile application.
Is there any way to implement the TextChanged event for the Label in Xamarin.Forms.
Fist of all you have to implement label that is capable of converting html tags to formatted text or whatever method you are using. Then you should bind your text to method that collects data from probably remote source. Text changed event handler is used rather to detect user input in XF. I don't know how your application works but, using MVVM models and bindings will save you a lot of frustrations when working with Xamarin UI.
Label.OnTextChanged(EventArgs) Method will be there, you can use this.
Entry1 _TextChanged(object sender, TextChangedEventArgs e)
{
if(.... put some condition here....)
{
entryField.Text = e.OldTextValue;
}
}
Reference link - https://learn.microsoft.com/en-us/dotnet/api/Xamarin.Forms.Entry.TextChanged?view=xamarin-forms

Word Macro to add predefined content at the end of document on click of button

I have an document in word, which has some fields to be filled, and an button to which I want to assign a macro. When that button is clicked, that same form with empty fields needs to be appended to the end of document, including the button (which can be clicked again and do the same thing).
Here is the document I have:
https://drive.google.com/file/d/0B_2kyqxMx5x4UkxfOHJhOGVPdnc/view?usp=sharing
The main problem with what you want to do is dynamically linking the button to the macro code to be executed. The most obvious type of button to use is the legacy ActiveX control in the Ribbon's Developer tab. But that requires its own procedure entry in the document's ThisDocument class module. While it's possible to add code to modules "on the fly" this involves disabling a security option.
A more straignt forward approach is to use the MacroButton field. This creates a clickable text within the document. It can display text or a graphic (so that it looks like a button) and is assigned the name of any public Sub that takes no parameters:
{ MACROBUTTON NameOfMacro Click here }
Ctrl+F9 to insert the field code brackets; Alt+F9 to toggle between field code and field result.
Graphics in Word 2010 and later:* The was a change to the graphics engine in Word 2010 which affects the behavior of graphics objects in the MacroButton field. Clicking the object triggers the Ribbon utility for working with graphics - the field code no longer "hides" the graphic. There are a number of ways you can work around this:
Use an IncludePicture field (which works with the old graphics format) to bring in an outside picture file. Once the linked picture is in the field it can be converted to a static picture by selecting the IncludePicture field and pressing Ctrl+Shift+F9. Word respects the old graphic format and the picture is click-able.
{ MacroButton NameOfMacro {IncludePicture "C:\\Path\\picture.jpg" } }
Use the old *.doc file format. Note that this will restrict some of the things that can be done with the document, but it will force use of the old graphics engine.
Instead of a MacroButton field, use the WindowBeforeDoubleClick event or WindowSelectionChange event to run the code.
*With the exception of unlinking the IncludePicture field (which I discovered myself), this information came from this discussion on the Microsoft Answers site
If you want to run the macro with a single rather than a double-click (the default) you need to run the following line of code. This applies to the entire Word application and needs to be run everytime Word restarts. You could put it in an AutoNew macro in the template / AutoOpen macro in the document:
Application.Options.ButtonFieldClicks = 1
The simplest way to store the entire content you want to insert repeatedly is as a Building Block (formerly known as AutoText).
BuildingBlocks are stored in templates. If your document is being created from a template, that would be the logical place. Another possibility would be a special template you use for this purpose. Normal.dotm can also be used but keep in mind this does sometimes get removed.
(Note: if you're using a template for the document that would also be the best place to store the macro attached to the macro button.)
Once this is set up, all your code needs to do is insert the BuidlingBlock at the end of the document.

pass value to a web browser and print it in a particular textbox

I have a win-form application that generates passwords that I would like to send directly over to a web page textbox like input as apart of a new user sign up. I found a similair question. (Fill Form C# & Post Error) But I dont think I am after the same goal. Is it possible to do this without using a macro or manually copy n pasting? The above post is in C# however I will ever using vb. If there is a answer on here please link, but I have gone through the forum.

Create json text from Visual Basic GUI input

I'm trying to create an app in Visual Basic that will allow a user to input an address, state, zip, some radio buttons and other data that will then add information into a json file.
The JSON text is set up like this:
{"ChapterId":1,
"ChapterName":"Batesville",
"Region":1,
"Field1":"TestField1aData",
"Field2":"TestField2aData",
"Field3":"TestField3aData",
"Address":"72501",
"Latitude":35.775765,
"Longitude":-91.641083,
"ChapterType":"Active"},
The current Visual basic app is divided into two forms. The first form shows all "chapter" names which can then be clicked on and edited or create a new "chapter" which will then open a chapter editor. One thing I'm having trouble with is opening a current JSON file and formatting it to show up in the txtboxes I have set up for editing. Also, I want the chapter names to show up in a collection. When the user highlights a collection in a combobox and clicks a button it will open a window (having trouble with that too).
So the Visual Basic program opens up the JSON file (unable to get that to open)
Imports "Chapter Name" into a collection.
When a user clicks on a item in the combobox and then presses add new chapter or edit chapter it is then able to edit said JSON file.
IF ADDING NEW CHAPTER
The text will be able to create a new "chaptername" and add a new region address state as seen in the JSON script example. When the user clicks the update button, the new JSON text is added to the original JSON file.
IF EDITING A NEW CHAPTER
The text boxes show the original data from the selected chapter and will then be able to update that original "chapter" section.
OPTION TO REMOVE CHAPTERS
How to remove one of those sections of code within the visual basic .exe file
I'm doing this for a charitable organization (I know it seems like I'm asking for a lot of info, but I have to get this done within 30 hours and I'm pretty new to visual basic)
Thanks for your help.
Use Json.net or Json serialization. Have a look at MSDN article - An Introduction to JavaScript Object Notation (JSON) in JavaScript and .NET

QInputDialog like thing in Cocoa/Xcode?

I'm fairly new to Xcode and Cocoa/Objective-C and I'm trying to implement something as simple as a QInputDialog that can be re-used throughout the program - with a unique message to the user each time it is launched and return a string as a result.
I have searched the web and found multiple methods but nothing seems to be quite clear or concise - well enough for me to understand anyway.
Is there anything out there as simple as:
Create/Launch a window from a method with a new message label to the user in the form of a string.
Has an NSTextField to receive the users input.
Close the window and return the string from the text field (if accepted) to the calling method.
??
Modal prompts for input are very un-Mac-like. It's like smashing the user's face in with a cricket bat and yelling “TELL ME THE ANSWER NOW!”
The correct solution is to put your text field into a non-modal window, so that the value is already ready when the user invokes whatever action needs the value. Beep and show the “hey, you forgot this” icon if the user hasn't filled in the field and you need a value there. If the field is not relevant in the window the user starts the action from, or if you're going to need several facts as input, then show another window, non-modally, with its own window controller, to take in all the input you'll need for the action.
A separate, non-modal window will also enable the user to fill out and/or perform multiple such actions in parallel.
If you must demand the value with a modal dialog, you can and should make it a sheet, but you'll still need to build the panel and its contents from scratch in IB or code.
See also the Sheet Programming Guide and the chapter on windows in the Human Interface Guidelines.