Demo

http://izlt.xyz

demo/demo

Introduction

V2Test is a lightweight data driven testing framework based on Python 3.

https://github.com/deepjia/v2test

Now intergrated with WebGUI: V2Test Management.

Engines:

Modes:

Todos:

It’s easy to develop new engines.

login add testsuite run reports case case run

Prerequisites

Python 3.5+ with modules:

ddt html-testRunner openpyxl PyMySQL requests selenium locustio

Installation

Install Git and Python 3 with pip. Homebrew is recommended for macOS.

Then, clone the repo:

git clone https://github.com/deepjia/v2test.git

For macOS without venv, I recommend pip3 with --user so that sudo is unnecessary:

pip3 install -r requirements.txt --user -U
PATH=$PATH:~/Library/Python/3.6/bin

For Linux/Windows with Python 3 installed or for venv:

pip3 install -r requirements.txt

or if Python 3 is the default:

pip install -r requirements.txt

Run

Local

./run.py

Run cases in TestCases.

Test report will be generated in TestReports.

LOG_LEVEL and LEN_MSG are configurable in config.ini.

Receiver

./receiver.py

Run cases in TestCases which are received from sender.

Test report will be generated in TestReports, and send back to sender.

PORT is configurable in config.ini.

Sender

./sender.py

Send cases in RemoteReport/ReceiverName to receivers and reports will be gathered in RemoteReports.

Set ReceiverName=IP:PORT in config.ini.

WebGUI

./v2testmgr.sh

The default url: https://127.0.0.1:5000/

Structure

.
├── TestCases: Case files(xlsx).
│   └── Example.xlsx: Example for case file.
├── RemoteCases: Case files to send.
│   └── RECEIVER1: Case files to run in RECEIVER1.
│       └── Example.xlsx
├── TestEngines: V2Test engines.
│   ├── __init__.py
│   ├── config.py
│   ├── excel.py
│   ├── http.py
│   ├── linux32: UI driver for 32bit browser, Linux.
│   │   ├── chromedriver
│   │   └── geckodriver
│   ├── linux64: UI driver for 64bit browser, Linux.
│   │   ├── chromedriver
│   │   └── geckodriver
│   ├── mac64: UI driver for macOS.
│   │   ├── chromedriver
│   │   └── geckodriver
│   ├── shell.py
│   ├── ui.py
│   ├── win32: UI driver for 32bit browser, Windows.
│   │   ├── IEDriverServer.exe
│   │   ├── chromedriver.exe
│   │   └── geckodriver.exe
│   └── win64: UI driver for 64bit browser, Windows.
│       ├── IEDriverServer.exe
│       └── geckodriver.exe
├── TestFiles: Test files, for example scripts to run and files to upload.
│   └── example.sh: One example for test file, a shell script.
├── README.md: What you are reading.
├── TestReports: Test reports will be generated here.
├── RemoteReports: Test reports from receivers will be gathered here.
├── config.ini: Configuration for framwork and engines.
├── requirements.txt: Requirements generated by pip.
├── run.py: V2Test standalone mode, where local tests start.
├── sender.py: V2Test sender mode.
└── receiver.py: V2Test receiver mode..

Usage - Framework

Config

LOG_LEVEL=INFO or DEBUG or WARNING or ERROR

For most users, set LOG_LEVEL=INFO

Case

V2Test will scan TestCases for all excel files, and load all cases with Run = y from all sheets.

One line is one step; Cases will be run step by step, and each case can have more than one lines.

Run, Case ID, Case Name, Engine should and should only be in the 1st line.

Run

Whether or not the case will be run. Set to y or n for the 1st line of each case.

(Required for each case)

ID, Name

Case/Logic/Model ID. Case/Logic/Model Name.

(Required for each case/logic/model)

Engine

The engine for the case.

Engine ui, http, shell are now built in. Engine mysql is coming soon.

(Required for each case)

Locator/Encapsulator and Value

Used to locate elements in web pages or encapsulate parameters.

Action and Value

Used to interact with engines (some with framework), which is also known as “keyword”.

Case - Action

wait

Wait for value seconds.

equal[.arg][.arg2]…, in[.arg][.arg2]…

Check whether Value equals or in the returned value. arg is the attar of the returned value, or method defined in engines.

!equal[.arg], !in[.arg], log[.arg]

! means not. log is used to show the value.

You can refer to the examples in TestCases, it is easy to understand how to create test cases.

All settings are in config.ini.

save_var[.arg][.arg2]…

Save the returned value into var ${Value}.

arg is the attar of the returned value, or method defined in engines.

logic

Call logic with the id of Value.

Usage - UI Engine

Config

DRIVER=Safari

Since OS X El Capitan, safaridriver(macOS only) is preinstalled.

Keep Safari > Preferences > Show Develop checked.

Keep Develop > Allow Remote Automation checked.

Set DRIVER=Safari in config.ini

DRIVER=IE, Firefox, Chrome

Download IEDriverServer (Windows only), geckodriver, chromedriver, then unpack it and put the binary file in TestEngines/.../

(Current version of binary is already there, but an update is recommended)

Set DRIVER=IE or Firefox or Chrome, BIT=32 or 64 (depend on your browser) in config.ini

DRIVER=Remote

(Untested)

Make sure Standalone Selenium Server is running.

Set DRIVER=Remote, REMOTE_SERVER=(url), REMOTE_BROWSER=Chrome or Firefox or Safari in config.ini

URL

The default URL if Value of Action=open is null.

WAIT

Implicit waits, wait for Value seconds before before looking for elements.

Case - Locator

id, name, xpath, css_selector, class_name, tag_name, link_text, partial_link_text

Find elements by id, name, xpath etc.

saved_elem

Find previously saved elements. (Saved by the save_elem action.)

model

Find elements from models.

Case - Action

open, close

Open the URL in Value, the default URL is in config.ini. Or close current browser window.

type, press, click

Input Value in text areas, or press Key Value of the keyboard, or click the element.

[de]select[.Key]

Select/Deselect the option by Key in (‘value’, ‘visible_text’, ‘index’)

Select/Deselect all when Key and Value are null.

within

Explicit waits, wait for the element to appear, up to Value seconds.

save_elem

Save the element with the name Value, in order to be found by locator saved_elem.

is_displayed, is_enabled, is_selected

If the element is displayed/enabled/selected, return ‘True’. Otherwise ‘False’.

get_attribute.Key

Gets the given attribute or property of the element. Eg: get_attribute.value

get_property.Key

Gets the given property of the element.

text, tag_name

Gets the text/tag_name of the element.

switch_to.Key

Switch to an element, frame etc.

Usage - Appium Engine

Config

Refer to the document of appium.

Case - Locator

ios_uiautomation, android_uiautomator, ios_predicate, accessibility_id, class_name, xpath

Refer to finding-and-interacting-with-elements of appium.

x, y

(x, y) location of touch area.

Case - Action

Refer to automating-mobile-gestures of appium.

touch_action{

}

All actions between touch_action{ and } will run as a touch action chain.

tap, press, long_press, move_to

Touch actions that can be chained by touch_action{ and } or be used standalone.

Vaule is count for tap or duration for long_press

zoom, pinch, scroll

Zoom, pinch or scroll to an element.

Actions of UI Engine can also be used.

Usage - HTTP Engine

Config

BASEURL

BASEURL is the base URL for Value without base URL, and the default URL for null Value

TIMEOUT is the default timeout for all requests.

Case - Parameter

headers, params, data, files …{

}

All Parameter: Value between Tag{ and } will be encapsulated to dict: Tag={Encapsulator1: Value1, Encapsulator2: Value2, …}, and added to the parameter of your request.

Nesting is supported.

data, …[

]

All Parameter: Value between Tag[ and ] will be encapsulated to list: Tag=[(Encapsulator1, Value1), (Encapsulator2, Value2), …], and added to the parameter of your request.

Nesting is supported.

files{}

Specially, files{}: Value will be encapsulated to files={‘file’: open(Value, ‘rb’)}

params, headers, data, timeout, …

Parameters of requests. Value should be valid python types, such as strings, numbers, tuples, lists, dicts, booleans, and None. For example, strings should be quoted.

Case - Action

get, post, (head, put, delete, options)

Send HTTP requests with parameters to the Value URL.

equal[.arg][.arg2]…, in[.arg][.arg2]…

Check whether Value equals or in the returned value. arg is the attar of the returned value, or method defined in engines.

For HTTP Engine, arg=json can conver json text to list/dict. Eg:

response = ‘[{“number”: 1,“title”: “Snapshot for README.md”}]’

equal.json.0.title means to compare value with ‘Snapshot for README.md’

Usage - Shell Engine

Case - Action

command

Run shell command.

bash/python/ruby/perl

Run bash/python/ruby/perl script.

file

Run executable file.

Usage - MySQL Engine

Config

HOST, USERNAME, PASSWORD, DATABASE, CHARSET

Basic info of MySQL database.

Case - Action

commit

Run SQL Query and commit.

fetchone.[*]

Run SQL Query and fetch one record, or fetch the value of key * from the record.

fetchall.*

Run SQL Query and fetch one records.

fetchmany.*

Run SQL Query and fetch as many as * records.

sql

Run SQL scrpit.

Usage - Locust Engine

Config

CLIENT

Default number of concurrent clients.

RATE

The default rate per second in which clients are spawned.

NUMBER

Default number of requests to perform.

HOST

Default host to load test in the following format: https://10.21.32.33

BACKGROUND

Set BACKGROUND=Y to run load tests in the background.

Case - Parameter

client/rate/number/host

Normal parameters for action file.

Case - Action

file

Run locust file.

<推广> 本站使用 NameSilo 提供的域名服务。