I am using InteliJ and really love using it. One of the questions I have is this:
Is there a way to create code short cuts?
For instance, while bug testing, I am forever writing:
<?php die(var_dump($var)); ?>
and figured it would be great to have a shortcut key to automate this. i.e.
"Cmd Option D"
or something similar to dump the pre-defined statement into my code...
Any thoughts on this?
You can use Live Templates:
To define a template go to Settings/Live templates, then select group or create new group of templates and hit the green plus button and select Live Template.
In the abbreviation field type for example vd which will be the trigger for your snippet, define context, which represents the languages this template will be available for and put this in the Template Text field:
<?php die(var_dump($SELECTION$)); ?>
The $SELECTION$ part is a variable which represents current selection.
Now when you are in editor, you can just type vd and hit Tab. That will expand your snippet and put your cursor inside var_dump().
You can event type the variable name you want to dump, select it, hit CTRL+ALT+T, which will show you a Surround with dialog, where you can choose your template. After you select it your variable name will be surrounded with the var_dump snippet.
Another way to invoke a live template is to hit CTRL+J which will show you autocomplete popup with the available templates.
Related
Thanks Peter for API,Perf karate framework.
Now I am trying UI automation and it looks perfect as of now.
I have below question:
I have a menu bar with 15 items in it. they are named as following:
-Home
-Account
-groups
-settings
etc etc.
Locator for each one is like this "a[name=Home]" , "a[name=Account]", "a[name=groups]" . So ony the part after name= is something that is dynamic in nature. So my question is that is it possible to somehow make this dynamic locator?
I have written a called feature in which i have written steps to login and select a menu item. and I want to pass the menu item from calling feature in json like below:
if I want to click on Account menu
* call read(menuItem.feature) {menuItem: Account}
menuItem.feature looks something like below:
Given url 'xyz'
And input (username, userID)
And input (password, password)
And click("button[name=login]")
And click("a[name=Home]")
Here I want to make Home as dynamic in last click step on menuItem.feature so that I can pass other menu items and reuse all above steps/feature file to login everytime with different menu items passed from calling feature file in json{.
Again its just a query. I have currently written multiple scenarios to click on menu item and then in calling feature I call the called feature with tags like #Home,#account etc. and this works perfectly fine.
Also if there is any other better way to achieve this then please suggest
Yes. Let me put it this way, the things you see such as input('foo', 'bar') is pure JS behind the scenes. So normal programming-language rules apply. For example:
* def dynamic = 'foo'
* def locator = 'a[name=' + dynamic + ']'
* input(locator, 'some value')
Is there any shortcut/setting/plugin available in intellij where I can create test data structure with some default values ?
e.g.
Map<String,String> stringMap = new HashMap();
stringMap.put("1","A")
stringMap.put("2","B")
stringMap.put("3","C")
I dont want to type all of the above as I want to test very quick with any values.
You can use the 'Live Templates' functionality, for instance. A guide on how to create such a template can be found here.
Use live templates to insert common constructs into your code, such as
loops, conditions, various declarations, or print statements.
To expand a code snippet, type the corresponding template abbreviation
and press Tab
In the screenshot below, I created a custom template called smap in the 'other' template group, added your code to it and selected the language (Java) that this template can be applied to.
Once in the editor, I can type smap and a pop-up will appear suggesting me to use the existing template to replace the abbreviation with code. Hitting Tab or Enter will perform the replacement.
I want to change the header name of the ABAP program. What can I do or where can I find the option to edit the header?
Two ways for this:
Set it in program options. Select the program and check menu Goto / Attributes.
Or you can create a GUI title and set it via ABAP. This overwrites attributes' setting.
More about how to achieve: here.
To change the program header is more easier than it seems.
Just open you program via SE38 -> Goto -> Properties -> Check the title field and change -> Save
And you are done. :)
I have this.
Usually is changing the name in atributes with transaction se38, but sometimes this don't work, you need in the transaction se80, create a title GUI, if yuou don't have a title created, righ clic in the program name, create -> GUI title.
And put your name and code.
and in your program (se38) in PBO, you have to call the title with
SET TITLEBAR '100' (Put your title code)
(100 is the title code), but this instruction have to need inside of a moodle, if is outside don't will work.
I use the first moodle that i have in my PBO (i don't know if is the best decition or the right form, but is a way and works).
finally the title change
The path is SE38 -> (Put Program Name) -> Now open the program in edit mode -> Select the option GOTO -> select Properties Change the program title.
I'm trying to build a live template that will work like the 'wrap in comment' live template (that puts a // before each selected line). For example, select multiple lines of text, click Code > Surround With > Single quotes (custom live template) and quotes will appear around each line.
E.g. from:
text1
text2
text3
to:
'text1'
'text2'
'text3'
Unfortunately the template I define:
'$SELECTION$'
produces:
'text1
text2
text3'
which makes sense.
Is there any way to define a Live Template that will work on each line of my selection?
"Wrap in comment" is not a live template, but an action that is implemented in Java. In the same way, you can't accomplish what you need using a live template, but you can write a small plugin in Java to implement that feature. Please refer to the Editor Basics tutorial to get started with writing the plugin.
I'm trying to replace the parameter name shown on the selection screen.
For example I have:
PARAMETERS pa_age TYPE age_type DEFAULT '18'.
It shows PA_AGE on the screen.
How to change it to How old are you? for instance?
You have to define a text via Goto->text elements->selection text.
If you develop in another language as you execute your code, you need also a translation.
Via menu Goto->Text Elements->Selection Text.