Skip to content

Your First Test

Create a test file

Create a file called login.vanya:

Vanya test scenario (vanya-lang.org/v0.1)
Script title: "User can log in"
Within the Browser (plugin: playwright-python, type: browser, url: 'https://example.com')
go to "/login"
Within the Login Form (type: element, id: 'login_form')
Define email-input (label: 'Email')
Define password-input (label: 'Password')
Define submit-button (testid: 'sign_in')
type "user@example.com" into email-input
type "password123" into password-input
click submit-button
see a div (text: 'Welcome back')

Check the syntax

Run the checker to validate your test:

Terminal window
vanya check login.vanya

If everything is correct, you’ll see:

login.vanya: OK

Build the test

Transpile to Python:

Terminal window
vanya build login.vanya -o out/

This creates out/login.py (and out/login.py.vanyamap for source mapping) ready to run with pytest.

Run the generated test

Terminal window
cd out
pip install pytest playwright
playwright install
pytest login.py

Next steps