Skip to content

Instantly share code, notes, and snippets.

@log0div0
Created August 10, 2020 08:03
Show Gist options
  • Save log0div0/b461a7b8fc4371071d49b0006f58e25a to your computer and use it in GitHub Desktop.
Save log0div0/b461a7b8fc4371071d49b0006f58e25a to your computer and use it in GitHub Desktop.
Автоматизация тестирования анитивируса Dr.Web
include "os_installation.testo"
flash dr_web_flash {
size: 2Gb
fs: "ntfs"
folder: "${DR_WEB_DIR}"
}
macro try_login() {
for (i IN RANGE 30) {
mouse click
if (check("testo")) {
break;
}
sleep 3s
}
}
test dr_web_install: win10_prepare {
win10 {
plug flash dr_web_flash
sleep 5s
mouse click "USB Drive"
sleep 3s
mouse click "Open folder"
mouse click "drweb"
press LeftCtrl + C
mouse click "Edge".move_down(50)
press LeftCtrl + V
wait "Copying"
wait !"Copying" timeout 5m
mouse click "USB Drive".from_top(0)
press LeftAlt + F4
unplug flash dr_web_flash
sleep 3s
mouse dclick "drweb"
wait "Do you want to allow"; mouse click "Yes".from_bottom(0)
wait "Thank you for choosing Dr.Web" timeout 3m
mouse click "I want to connect to Dr.Web Cloud".right_center()
mouse click "Install Dr.Web Firewall"
mouse click "Next".from_bottom(0)
mouse click "Receive license later"
mouse click "Install"
wait "Installation complete" timeout 10m
mouse click "Restart now"
try_login()
type "1111"; press Enter
wait "Type here to search" && "Dr.Web" && "Scanner" timeout 3m
}
}
macro open_app(app) {
mouse click "Type here to search"
wait "Top apps"
type "${app}"
wait "Open"
press Enter
}
flash access_denied {
fs: "ntfs"
size: 16Mb
}
test dr_web_flash_drive_restriction: dr_web_install {
win10 {
open_app("Security Center")
wait "Computer is protected"
mouse click "Click to make changes"
wait "Do you want to allow"
mouse click "Yes".from_bottom(0)
wait "Computer is protected"
plug flash access_denied
wait "USB Drive (E:)"
mouse rclick "This folder is empty"
mouse move "New"; sleep 3s
mouse click "Text Document".from_top(1)
wait "New Text Document";
press Backspace; type "my_file"; press Enter
mouse rclick "USB Drive (E:)".from_left(0); mouse click "Eject"
wait "Safe To Remove Hardware"
unplug flash access_denied
mouse click "Devices and Personal Data"
mouse click "Configure device access rules"
mouse click "Block removable media"
sleep 2s
plug flash access_denied
open_app("File Explorer")
wait "Frequent folders"
mouse click "USB Drive (E:)".from_left(0)
mouse move "Access is denied"
press Enter
mouse rclick "USB Drive (E:)".from_left(0); mouse click "Eject"
wait "Safe To Remove Hardware"
unplug flash access_denied
press LeftAlt + F4
mouse click "Block removable media"
plug flash access_denied
wait "USB Drive (E:)" && "my_file"
mouse rclick "my_file"
mouse click "Delete"
wait "Are you sure"; mouse click "Yes".from_right(0)
mouse rclick "This folder is empty"
mouse rclick "USB Drive (E:)".from_left(0); mouse click "Eject"
wait "Safe To Remove Hardware"
unplug flash access_denied
}
}
test win10_enable_internet: dr_web_install {
win10 {
shutdown
plug nic nat
start
try_login()
type "1111"; press Enter
wait "Networks"
mouse click "No".from_right(0)
wait !"Networks"
sleep 2s
}
}
test dr_web_network_restriction: win10_enable_internet {
win10 {
open_app("Security Center")
wait "Computer is protected"
mouse click "Click to make changes"
wait "Do you want to allow"
mouse click "Yes".from_bottom(0)
wait "Computer is protected"
mouse dclick "Edge"
mouse click "www.microsoft.com"; sleep 1s
press LeftCtrl + A, Backspace; type "www.yandex.ru"; press Enter
wait "Сейчас в СМИ"
press LeftAlt + F4;
wait "Do you want to close all tabs?"; mouse click "Always close all tabs"
mouse click "Close all".from_bottom(0)
wait "Computer is protected"
mouse click "Devices and Personal Data"
mouse click "Configure device access rules"
mouse click "Block data transfer over network"
mouse dclick "Edge"
sleep 6s;
if (check "Search or enter web address" timeout 5s) {
mouse click "Search or enter web address";
} else if (check "www.msn.com" timeout 5s) {
mouse click "www.msn.com";
}
press LeftCtrl + A, Backspace;
type "www.yandex.ru"; sleep 1s; press Enter
wait "can't reach this page"; press LeftAlt + F4;
mouse click "Block data transfer over network"
mouse dclick "Edge"
sleep 6s;
if (check "Search or enter web address" timeout 5s) {
mouse click "Search or enter web address";
} else if (check "www.msn.com" timeout 5s) {
mouse click "www.msn.com";
}
type "www.yandex.ru"; sleep 1s; press Enter
wait "Сейчас в СМИ"
}
}
test win10_install_ga: dr_web_install {
win10 {
unplug dvd
plug dvd "${ISO_DIR}/testo-guest-additions.iso"
open_app("File Explorer")
wait "Frequent folders"
mouse click "This PC".from_left(0)
mouse dclick "CD Drive"
mouse dclick "autorun".from_top(1)
wait "Вас приветствует мастер установки"
press Enter
wait "Выбор папки для установки"
press Enter
wait "Подтверждение установки"
press Enter
wait "Do you want to allow"
mouse click "Yes".from_bottom(0)
wait "Would you like to install"
mouse click "Install".from_left(0)
wait "Установка завершена"
mouse click "Закрыть".from_bottom(0);
wait !"Установка завершена"
press LeftAlt + F4; wait !"CD Drive"
}
}
test win10_install_freecommander: win10_install_ga {
win10 {
copyto "${FREE_COMMANDER_DIR}/FreeCommanderXE-32-public_setup.zip" "C:\\Users\\testo\\Desktop\\FreeCommander.zip"
mouse dclick "FreeComm"
wait "Extract";
mouse dclick "FreeCommanderXE"
wait "Do you wish to continue?"
mouse click "Yes"
wait "Do you want to allow"
mouse click "Yes".from_bottom(0)
wait "English"; mouse click "OK"
wait "License Agreement"
mouse click "I accept the agreement"
mouse click "Next".from_bottom(0).center_bottom()
wait "Destination Location"
mouse click "Next".from_bottom(0).center_bottom()
wait "Would you like the folder to be created?"
mouse click "Yes"
wait "Select Start Menu Folder"
mouse click "Next".from_bottom(0).center_bottom()
wait "Select Additional Tasks"
mouse click "Next".from_bottom(0).center_bottom()
wait "Ready to Install"
mouse click "Install".from_bottom(0).center_bottom()
wait "Completing";
mouse click "View ReadMe"
mouse click "Start FreeCommander"
mouse click "Finish".from_bottom(0)
wait !"Completing" && "Extract";
press LeftAlt + F4; wait !"Extract"
mouse rclick "FreeComm".from_top(0)
mouse click "Delete"
wait js "find_text().match('FreeComm').size() == 1"
}
}
test dr_web_restrict_program: win10_install_freecommander {
win10 {
mouse rclick "Recycle Bin".move_right(100)
mouse move "New"
mouse click "Folder".from_top(0)
type "Protected"; press Enter
mouse dclick "Protected"
mouse rclick "This folder is empty"
mouse move "New"; sleep 3s
mouse click "Text Document".from_top(1)
wait "New Text Document";
press Backspace; type "my_file"; press Enter
open_app("Security Center")
wait "Computer is protected"
mouse click "Click to make changes"
wait "Do you want to allow"
mouse click "Yes".from_bottom(0)
wait "Computer is protected"
mouse click "Devices and Personal Data"
mouse move 0 0
mouse click "Data Loss Prevention"
mouse click "Protected folder".left_top().move_up(20)
wait "Add folder to protect"
mouse click "Browse"
wait "Open folder"
mouse dclick "Users"
mouse dclick "testo"
mouse dclick "Desktop"
mouse click "Protected".from_right(0)
type "C:\\Users\\testo\\Desktop\\Protected"
mouse click "OK".from_top(0)
wait !"Open folder"
mouse click "Application".from_bottom(0).left_top().move_up(20)
wait "Open file"
mouse click "C:\\".from_top(0)
press LeftCtrl + A; press Backspace;
type "C:\\Program Files (x86)\\FreeCommander XE\\FreeCommander.exe";
press Enter
wait !"Open file"
mouse click "OK".from_top(0)
wait "Protected folder" && "C:\\Users\\testo\\Desktop\\Protected"
press LeftAlt + F4
wait !"Protected folder"
mouse click "my_file"; press Delete
wait "administrator permission"
mouse click "Continue"
wait "Modification of the folder contents is blocked"
mouse click "Cancel"
wait !"Modification of the folder contents is blocked"
mouse dclick "FreeComm"
wait "Desktop - FreeCommander XE"
mouse dclick "Protected".from_left(0)
mouse click "my_file.txt"
press Delete; mouse move 0 0
wait !"my_file"
}
}
test win10_add_user: win10_install_ga {
win10 {
open_app("Computer Management")
mouse click "Local Users"
wait "Users" && "Groups"
mouse rclick "Users".from_right(1)
mouse click "New User"
wait "User name"
# Создадим нового пользователя
type "MySuperUser"
mouse click "Create"
# Закроем окно добавления нового опльзователя
mouse click "Close"
wait !"User name"
# Закроем окно "Computer Management"
press LeftAlt+F4
wait !"Computer Management"
press LeftCtrl + LeftAlt + Delete
mouse click "Switch user"
mouse click "MySuperUser"
mouse click "Sign in".center_bottom()
wait "The user's password must be changed"
mouse click "OK"
wait "New password"
type "1111"; press Tab; type "1111"; press Enter
wait "Your password has been changed"; mouse click "OK"
wait "Microsoft puts you in control" timeout 5m
mouse click "Accept".from_bottom(0).center_bottom()
wait "Recycle Bin"
}
}
test dr_web_parental_control_file: win10_add_user {
win10 {
exec cmd """
mkdir C:\\shared_folder
echo Hello world! > C:\\shared_folder\\my_file.txt
"""
open_app("File Explorer")
wait "Frequent folders"
mouse click "This PC".from_left(0)
mouse dclick "Local Disk (C:)"
mouse dclick "shared_folder"
mouse rclick "my_file"
mouse click "Open".from_top(0)
wait "Hello world!"; press LeftAlt + F4
wait !"Hello world!"; press Delete;
wait !"my_file"
exec cmd """
echo Hello world! > C:\\shared_folder\\my_file.txt
"""
mouse move 0 0
wait "my_file"
open_app("Security Center")
wait "Computer is protected"
mouse click "Click to make changes"
wait "Do you want to allow"
type "1111"
mouse click "Yes".from_bottom(0)
wait "Computer is protected"
mouse click "Parental Control"
mouse click "MySuperUser"
mouse click "Files and Folders"
mouse click "Object".from_bottom(0).left_top().move_up(30)
wait "Open file or folder"
mouse dclick "shared_folder".from_right(0)
mouse click "my_file.txt"; press Enter
wait !"Open file or folder"
wait "C:\\shared_folder\\my_file.txt" && "Read-only"
press LeftAlt + F4
wait !"Parental Control"
mouse dclick "my_file"
wait "Hello world!"; press LeftAlt + F4
wait !"Hello world!"; press Delete;
wait "File Access Denied"; mouse click "Continue"
mouse move 0 0
wait "Do you want to allow"; type "1111"; mouse click "Yes"
wait ("This folder is empty" || "Working on it") && !"my_file"
}
}
network internet {
mode: "nat"
}
machine win10 {
cpus: 2
ram: 2Gb
iso: "${ISO_DIR}/Win10_2004_English_x64.iso"
disk main: {
size: 20Gb
}
nic nat: {
attached_to: "internet"
adapter_type: "e1000"
}
}
test win10_installation {
win10 {
unplug nic nat
start
# Экран выбора языка
wait "Language to install" && "English" timeout 10m;
mouse click "Next".from_bottom(0)
# Экран с единственной кнопкой - "Install Now"
mouse click "Install now"
# Экран активации Windows
wait "Activate Windows" timeout 5m
mouse click "I don't have a product key".from_bottom(0)
# Экран выбора редакции
mouse click "Windows 10 Pro".from_top(0)
mouse click "Next"
# Экран с лицензионным соглашением
mouse click "I accept the license terms"
mouse click "Next"
# Экран выбора типа установки
mouse click "Install Windows only"
# Экран выбора диска, на который будет установлена Windows
wait "Where do you want to install Windows?"
mouse click "Next".center_bottom()
# Далее идёт долгий процесс копирования файлов на диск
# с последующей автоматической перезагрузкой
# Экран выбора региона
wait "United States" timeout 30m
mouse click "Yes".from_bottom(0).center_bottom()
# Экран выбора раскладки клавиатуры
wait "keyboard layout"
mouse click "Yes".from_bottom(0).center_bottom()
# Экран выбора дополнительной раскладки клавиатуры
mouse click "Skip".center_bottom()
# Экран подключения к Интернету
mouse click "I don't have internet".center_bottom()
# Экран, на котором Windows перечисляет все прелести
# подключения к Интернету
mouse click "Continue with limited setup"
# Экран задания имени пользователя
wait "What name do you want to use?"
type "testo"
mouse click "Next".center_bottom()
# Экран задания пароля пользователя
wait "Create a super memorable password"
type "1111"
mouse click "Next".center_bottom()
# Экран повторного ввода пароля пользователя
wait "Type your password one last time"
type "1111"
mouse click "Next".center_bottom()
# Экран выбора первого контрольного вопроса
mouse click "Security question (1 of 3)";
mouse click "What was your first pet's name?";
mouse click "Your answer"
type "Snowflake"
mouse click "Next".center_bottom()
# Экран выбора второго контрольного вопроса
mouse click "Security question (2 of 3)";
mouse click "What was your childhood nickname?";
mouse click "Your answer"
type "Snowflake"
mouse click "Next".center_bottom()
# Экран выбора третьего контрольного вопроса
mouse click "Security question (3 of 3)";
mouse click "What's the first name of your oldest cousin?";
mouse click "Your answer"
type "Snowflake"
mouse click "Next".center_bottom()
# Экран настроек приватности
wait "Microsoft puts you in control"
mouse click "Accept".from_bottom(0).center_bottom()
# Экран настроки синхронизации устройств
wait "If you want timeline"
mouse click "No".from_bottom(0).center_bottom()
# Экран настройки Cortana
wait "To let Cortana provide"
mouse click "Not now".from_bottom(0).center_bottom()
# Далее идёт долгий процесс подготовки к первому запуску
# Ждем, когда появится рабочий стол
wait "Recycle Bin" timeout 10m
# Ждем ещё несколько секунд, на всякий случай
sleep 5s
}
}
# Отключим режим экономии электроэнергии для мышки,
# иначе она может "зависнуть"
test win10_prepare: win10_installation {
win10 {
# Открываем окно "Device Manager"
mouse click "Type here to search"
wait "Top apps"
type "Device Manager"
wait "Open"
press Enter
# Открываем окно свойств устройства "USB Input Device"
mouse dclick "Human Interface Devices"
mouse move 0 0
mouse dclick "USB Input Device"
# Переходим на вкладку "Power Management"
# и снимаем галочку с пункта "Allow the computer to turn off ..."
mouse click "Power Management"
mouse click "Allow the computer"
sleep 5s
# Закрываем окно свойств устройства "USB Input Device"
press Enter
wait !"Power Management"
# Закрываем окно "Device Manager"
press LeftAlt+F4
wait !"Device Manager"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment