In Visual Studi you can do recording in IE as an example. You enter an url, insert some data and finish your recording. After that some code are generated. What if you want to change the recording? How do you resume a recording if something in the user interface changes? Do you have to sart all over start a recording based on the generated code?
You can add new recordings without losing the old. The normal recorder is used. When you save a part of the recording you name the action or assertion method. If the same name as an existing method is used than that method is replaced. However a completely new method can be created.
Assuming that you are using the default UT Map then position the cursor in the c where the new method should be called. Use the context (right-click) menu at that cursor position (I find adding a empty line makes it obvious where the new call will be inserted) and select the command Generate code for Coded UI test => Use Coded UI test builder. The normal Coded UI recorder will start.
If you are using multiple UI Maps then select the UI Map to have the new code and from its context menu select the ""Edit with Coded UI test builder" command. After recording a new method, add a call of it in the required test method.
If the new recording is wanted to replace a small part of an existing method, or to go in the middle, then I recommend using the UI Map editor to split the existing method into two or more pieces and then use the recorder to replace the unwanted part leaving the wanted parts as originally recorded.
A breakpoint can be set within a Coded UI test then, when the test is run in debug mode, execution will stop at the breakpoint. This lets the test be executed as so as to move the application being tested to a specific place within the test. Having reached the desired breakpoint, the test execution (ie the debug session) should be stopped. At this time the application is waiting for further input and the recording actions described above can be used. There are several ways of startng the test in debug mode, including the options on the "Run test" icon and the context menu of the [TestMethod].
Related
I come from Unity, and there you can use ContextMenu method attribute. It will add a button in the editor you can click and the method in your script will be invoked.
This is very helpful for testing/debugging purposes. When you are testing a functionality and you want an easy way to trigger it.
Is there something similar in Godot, or any workaround I can use?
(Godot 3.5 here)
There are multiple ways to run code in the editor.
In fact, Godot games and the Godot editor are built on the same core. One way to say is that Godot is build on Godot… But a more accurate way to say it is that your games are Godot without the editor, plus whatever you built on top.
As a consequence, you have a lot of freedom when extending the Godot editor.
For starters you will be making a tool script. To do that you the tool keyword on the top of the script file. This allows the script to run in the editor.
Warning: Remember that in Godot the Game is not running inside the Editor. Anything that your script moves while running in the Editor would be a modification to the project, for good or ill. And it does not come with build-in undo functionality. It is possible to add undo functionality (with the UndoRedo class), but that is also something you would have to program.
By the way, you might want to know if your code is running on the editor or not. For that, you can check Engine.editor_hint which will be true in the editor.
Read more on the article Running code in the editor.
Since the tool script modify the project. What I present below is more often used to setup parts of the scene or to automate parts of the development workflow. Not for testing features. However since the linked documentation about ContextMenu mentions that it is useful for…
automatically setting up Scene data from the script
I believe what present below is not out of place.
With that said, some modifications of the editor are harder than others. I believe you don't really want to go into the trouble of adding a button to the editor (which is perfectly possible) or an option to the menus (which is also possible, but not everywhere, at least not easily). Instead, I'll stay with the easy options for this answer:
You can make an EditorScript. That is a script that extends the EditorScript class and overrides the _run method. For example:
tool
extends EditorScript
func _run():
print("Hello from the Godot Editor!")
To execute it, have it open in the Script Editor, and to the File menu, and select Run. You can also use secondary click on the script on the "Scripts Panel (on the left of the Script Editor) and select Run in the contextual menu.
The drawback is that is script does not work in the game. It is only for the editor.
Although Godot 3.x does not have official (there is a plugin) support for inspector actions (it might land in Godot 4), we can workaround that. What we will do is export a bool property, and handle (with a setter, which we specify with setget) what happens when you set it. Like this:
tool
extends Node # or whatever
export var do_something:bool setget on_do_something
func on_do_something(_mod_value:bool) -> void:
# do whatever you want
pass
The property should show up as a checkbox in the Inspector panel when the node is selected. And clicking the checkbox will trigger the setter method on_do_something… Which will do whatever you want it to do. Notice also that I'm discarding the value that Godot is trying to set to the property (_mod_value) so it will remain false.
This pattern has got popularity among Godot developers.
If you want to add elements to the Godot UI you would have to make an EditorPlugin (see the Editor Plugins section in the documentation).
Alright but, since the tool script could cause modifications to the project, which might be a problem for testing… What do we do for testing?
Well, I will remind you that you can tell Godot to execute specific scenes (it does not have to run the main scene), and that can another way to test your code.
Furthermore, when your game is running you can go to the Scene panel and select the Remote tab to see the Nodes that exist in the game. Which will allow you to select them, which shows their properties in the Inspector, which would be able to modify (having an effect in real time on the executing game).
… And thus something similar to what I described above about using a setter would work. Except it does not need the tool keyword since it won't be running in the editor:
# No tool
extends Node # or whatever
export var do_something:bool setget on_do_something
func on_do_something(_mod_value:bool) -> void:
# do whatever you want
pass
By the way, in the inspector, when the game is executing and you have the relevant Node selected, you will see your property twice. The first one will trigger the setter, while the second one bypasses it. So pay attention which one you are using.
You might also be interested in the "Project Camera Override" feature, which allows you to freely move the game camera from the editor. You access the feature via the top bar in the editor.
You will also find that it is possible to modify Resources in the editor and see the effect in real time while the game is running. And a Script is a Resource… However pause the game from the Debugger panel (or use a breakpoint) and make sure the script you want to modify is not being executed before you modify it.
I want to clear treeview items(ListStore) and reassign items in a button click event.
I made the same program using with Python, Go and C#. But Rust is very hard...
Can it be done or not?
I couldn't go through the process. Until now, my program collects data when it executes (one time).
I am executing few QTP scripts through excel macro. But sometimes QTP throws some pop up where we have to click on OK manually after entering some value. I want to simulate this action in my macro code.
Below is the screenshot of Input Box that I want to handle:
Problem is that this Input Box is launched through QTP Script But I want to click on OK button using excel macro code. So, How can I get this Input Box and perform desired action?
It looks like the QTP script is explicitly asking for user input during the test run. This means that you lose a lot of the advantages of automation by forcing a human being to sit next to the machine while the test is run.
I would suggest modifying the test so that it uses data automatically. In QTP this can be done via the data table or via test (or action) parameters.
I want to get a better idea how a program I have operates, and rather than print the code out and try to see which method calls which method, it'd be easier to just run a debugger that steps through every line.
But manually putting a breakpoint on every line seems a bit laborious.
Is there any option to step through every line of the program as it runs(without manually putting in all the breakpoints)?
So that I could then see, ah MainActivity launches and runs onCreate and I could see it running through the code of onCreate how it then goes to a fragment class's onCreateView method.. and so on.. I want to see who is calling who as it happens and step through.
You don't need to add breakpoints on each line. Just add a breakpoint to the entry point of your application and then simply use the step-in and step-out buttons of the debugger to execute the code line by line.
In order to prevent the debugger from stepping through the code that wasn't written by you, go to File > Settings > Debugger > Stepping and then on the right, click the plus icon with the question mark that says Add Pattern to add the following patterns:
android.*
dalvik.*
com.android.*
I am new to Android/Java and am trying to learn in order to create an app. I have done a lot of programming in Microsoft Access Visual Basic, but this is the first that I am doing in Java.
My (very basic) question is how to open a new screen from another?
All of the examples that I have found online either did not work when I tried them or crashed when I tried to customize them to open my own screen.
Also, all of the examples have so much extraneous stuff in them that I cannot figure out which parts are essential to just opening the next screen and what parts are doing other things.
In VB, to open one screen from another (using a button), you create a screen (form) and then add the following code to the onclick event of the button docmd.openform("form1"). It is that simple.
What is the Android/Java version of this command?
What I am looking for is a barebones piece of code that opens another screen when a button is clicked on the first screen. The second screen would have nothing on it except a text field that says "this is the second screen." No buttons, returns, etc.
I know how to create the screens as layout.xml files. I just can't figure out how to display that second (or subsequent) screen.
You can launch a new activity from your current activity through an intent like this:
startActivity( new Intent(this, YourActivity.class) );