Record user actions in the Human Emulator Studio browser using the Macros

User actions record using tool the Macros

In the article we in detail explain how you can use the Macros in the Human Emulator Studio.

One of the first tools built into the program, which was added to simplify the creation of scripts, is the Macros.

How does it work?

When you enable the Macros, your actions in the browser are recorded, such as going to pages in the browser, all possible clicks on elements, and entering data in various browser fields. In this case, there are two modes of operation, this is when all actions are recorded via mouse control or using functions for working with individual objects.

Configuring the Macros

Before you start recording, you need to configure the Macros. The Macros settings are located in the General settings of the program, the Macros tab.

Now let’s go through all the settings.

Add focus by click — when you select this check box, the focus command will be added to each of your clicks.
Add mouse move to click — when you select this check box, the send_mouse_move command will be added to each of your clicks.
Add pause to click — if you select this check box, the sleep(1) command will be added after each click, i.e. wait for one second.

In other words, when you select these settings, your code will look like this:

without selecting these settings like this:

Check boxes Full mouse emulation and Full keyboard emulation. When you select these check boxes, functions will be substituted that fully emulate mouse movements and keyboard input to the active window. When script run in full emulation mode you will not be able to use your computer or work in multithreaded mode, as any actions with the mouse cursor or using the keyboard may interfere with the script.

In the script code it will be like this:

and

instead of

The group of radio button Catch events. In this group, exhibited the device of the action which will be to record a Macros.

When you select the Mouse, all actions in the script will be recorded as actions with the mouse.
In the script it will be written like this:

When you select the Keyboards option, all input actions will be recorded via the $keybord object
in the script, this will be

If the item Click on elements is selected, then writing to the script will go through the objects of these elements.
In the script :

The radio button group Create function. Responsible for the priority parameter with the program define the element to work with. By default, the item is selected Auto, in other words, the item is determined by the first available parameter, starting with the item ID and ending with the item number.

The check box Create new script. If you select this check box, a new script will be created when you start recording the Macros and all actions will be recorded in this script. If the check box is removed, then the entry will go to the current script, in the place where the carriage is installed in the editor.

Start the Macros

Use the Actions menu to enable the Macros.

Press menu item Start Record or use hotkey Ctrl+Shift+R.

Create simple script using the Macros.

Now let’s write a simple script. In built-in bowser enter google.com and press Go.

Turn on the Macros using menu item Start Record. Enter phrase human emulator in the Google search field. Press Enter. Click on the first link in the output. Turn off the Macros using menu item Stop Record. And we have the script like as:

Slightly change the Macros settings and disable the check boxes with focus, mouse movement and pause. And instead of Enter, press the Google search button.
We get the script like as:

Features of working with the Macros.

As it is not difficult to notice, the work in the Macros goes through the Dom Interface of objects. That is when you get the element itself you can do various actions with it such as:

Actions with an element
click – click on an element
meta_click – focus, move the mouse to the element at random coordinates, and click
event – send an event to the element
check – check the element
focus – set the input focus on the element
scroll_to_view – scroll the page so that the element is visible (via java script)
ensure_visible – scroll the page so that the element is visible (via scrolling)
scroll – scroll the element
screenshot – take a screenshot of an item

Change an item
set_value – set a value
set_inner_text-set internal text
set_inner_html-set internal htmlml
add_attribute – add an attribute
set_attribute – set an attribute
remove_attribute – remove an attribute

etc.

And all these actions can be performed with any element, be it a anchor or a button. You can also get a page element as an interface using the same functions for all page elements:

Getting the DOM interface
get_by_number – get the DOM interface by number
get_by_name – get the DOM interface by name
get_by_id – get the DOM interface by id
get_by_inner_text – get the DOM interface by internal text
get_by_inner_html – get the DOM interface from internal html
get_by_outer_text – get the DOM interface from external text
get_by_outer_html – get the DOM interface from external html
get_by_href – get the DOM interface by href
get_by_alt – get the DOM interface by alt
get_by_src – get the DOM interface by src
get_by_value – get the DOM interface by value
get_by_attribute – get the DOM interface by attribute value
get_by_properties – get the DOM interface by the value of several properties
get_by_xpath – is to obtain the DOM interface by its XPath

In other words, as in other functions, we work with page elements by several parameters, such as name, id, sequence number, and so on. All this can be viewed through the element inspector or use the same context menu.

Use of macros.

The macros is useful when you need to write simple scripts or some parts of scripts, when you can’t define some elements with other tools. At the same time, you should understand that the scripts recorded by the Macros will still have to be edited, since we use the Macros to record actions with page elements. You can add commands that are not related to page elements using another tool, the code Helper.