Solution for automated verification of document movements in Vanessa Automation

In this article I want to share my solution for checking document movements. I think there is no need to describe in detail why they are needed. If you are interested, you can find a lot of detailed information on the Internet.

Therefore, just a little, let me remind you that movements are certain entries in registers and they are formed when posting documents in the 1C system. For clarity, let’s take, as an example, the document Sick Leave. When creating and posting a document, a unique number is assigned and movements (records) are created in the registers. In the future, this data can be used for reports, etc.

Movement of the document Sick leave

Movement of the document Sick leave

Problem

Each document posted in the 1C system creates entries in registers. The number of movements depends on the document itself and the logic that is included in it.

To conduct testing, all these factors must be taken into account. Of course, it’s worth thinking about automating these checks and how to implement them.

What we have:

  • A certain number of documents in the system.

  • Each individual document forms a specific set of movements.

  • Registers store structured information – and different documents form similar movements.

Solution

To conduct manual testing, you can write one test case for creating a specific document and indicate which movements should be formed during the execution. I think this will be quite enough.

For automation, you can use the same approach – but you can simplify your work. If the movements are of the same type, then you can try to make their checks unified.

But, in any case, a separate script is needed to create and post a document – because various data are required to create them. But to check movements, come up with a standard approach. You can make separate scripts for each movement and, depending on the document, use a different set of such checks.

To implement this approach, the following scenario is suitable. It turns out that in one .feachure file we use not one script, but a whole group.

Structure of a .feature file with multiple scripts

Structure of a .feature file with multiple scripts

This script structure provides certain advantages:

  • General group variables, i.e. they work for all scenarios in the group.

  • If one of the scripts fails, the others will be executed. Those. they turn out to be independent of each other and in the report we will get a complete picture of the test results.

But for this to work, we need to use a global variable – a link to the created document. Because local variables from one script are not passed to another.

Global variable - document reference

Global variable – document reference

First, we declare a global variable – write “” into it. And when our document is created and processed, we remember the link to the document and write down its ContextStored.

Global variables are stored outside the context of the script and must be deleted after the script we need has executed.

I think you can skip the check for creating a document and its execution. The main thing is that in the end the document was posted in the system and we saved its link. Next, let's start writing a script for checking movements. It can be divided into 4 parts:

1. Opening a document

2. Data storage

3. Search (filtering) for motion

4. Movement check

First stage – Opening a document:

You can simply open a document using a link, but there is a possibility that an error will appear when saving or posting the document. It turns out that the document will not exist in the system and there is no point in checking its movements. Therefore, it is worth adding a condition for such a case. This is why the above first creates a global variable with the value “”. Because if the variable does not exist, the check will not work correctly. It will look something like this:

Opening a document

Opening a document

Second stage – We remember the necessary data from the document (number, date of creation, etc.)

Data storage

Data storage

The third stage – go to the Document Movements screen. And set the filter according to the Register we need.

  Motion search (filtering)

Motion search (filtering)

We create a template for checking this table and insert the previously saved variables into it. This can be conveniently done through Tools – getting the entire form in steps. Also, don’t forget that Vanessa Automation has a convenient table editor Gherkin (Ctrl + Shift + T).

Motion check

Motion check

As a result, we get the following code for checking movement:

Сценарий: <Проверка движения №1>

* Открываем документ
Если '"$$ГлобальнаяСсылкаНаДокумент$$" <> ""' тогда
    Дано Я открываю навигационную ссылку "$$ГлобальнаяСсылкаНаДокумент$$"

*  Запоминаем данные из документа
    И я запоминаю значение поля с именем 'Номер' как 'НомерДок'
    И я запоминаю заголовок текущего окна как "НаименованиеДок"
    И я запоминаю значение поля с именем 'Дата' как 'ДатаДок'

* Поиск (фильтр) движений
    И я нажимаю на кнопку 'Движения документа'
    Тогда открылось окно 'Движения документа (Горизонтально)'

    И я нажимаю кнопку выбора у поля с именем "КомпоновщикНастроекПользовательскиеНастройки"
    Тогда открылось окно 'Выводить только'
    И я нажимаю на кнопку с именем 'СписокСнятьФлажки'
    И в таблице "Список" я перехожу к строке:
        | 'Значение'                      |
        | 'Регистр сведений Движения (1)' |
    И в таблице "Список" я устанавливаю флаг с именем 'СписокПометка'
    И в таблице "Список" я завершаю редактирование строки
    И я нажимаю на кнопку с именем 'КомандаОК'
    Тогда открылось окно 'Движения документа (Горизонтально)'
    И я нажимаю на кнопку с именем 'СформироватьОтчет'

* Проверка движений
    И табличный документ "ОтчетТабличныйДокумент" равен:
        | 'Движения документа Больничный лист $НомерДок$ от $ДатаДок$'  | ''                   |
        | ''                                                            | ''                   |
        | 'Регистр сведений "Движения (1)"'                             | ''                   |
        | 'Стандартные реквизиты'                                       | 'Измерения'          |
        | 'Активность'                                                  | 'Документ основание' |
        | 'Да'                                                          | '$НаименованиеДок$'  |

И я закрываю все окна клиентского приложения

Bottom line

An example script for checking one movement of a document has been prepared. It can be adapted to any other register – by changing the remembered variables, filter, and table template.

If you have something to share, write, it will be interesting to learn about other implementations of checking document movements.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *