Quick start

Yet another selenium wd wrapper

1. Requirements

2. Install

Build from source:

$ git clone git@github.com:Aurococcus/wasd.git
$ cd wasd
$ pip install .

From pypi:

$ pip install wasd

3. Setup

$ mkdir my_project && cd my_project
# activate venv e.g. $ pyenv local my_venv
$ pip install wasd
$ wasd scaffold
$ invoke selenoid.up # if using Selenoid
$ pytest tests

This creates configuration file _wasd_settings.yml, basic project structure and sample test.

4. Configure

# web driver
url: 'https://google.com # your app url
implicit_timeout: 5      # implicit wait, sec.
window_size: 'maximize'  # 'maximize' or explicitly '800x600'

# selenium-server / selenoid
protocol: 'http'
host:     'localhost'
port:     '4444'
path:     '/wd/hub'

# any data
username: 'admin'
password: 'admin'

var_from_env: %MY_VARIABLE%  # Dynamic configuration from environment variables

# caps
capabilities:
    browserName: 'chrome'
    unexpectedAlertBehaviour: 'accept'
    enableVNC: True
    screenResolution: '1920x1080x24'
    loggingPrefs:
        browser: 'INFO'
    chromeOptions:
        args: ['--disable-infobars']

5. Write a test

Create file tests/test_foo.py:

import pytest
from wasd.wd import Element as E


class TestFoo:

    @pytest.mark.want_to('I wanna be the boshy')
    def test_a(self, browser):
        browser.open('/')
        browser.fill_field( E("[name = 'q']"), 'Hello, World!' )
        browser.wait_for_element_visible( E("[name = 'btnK']") )
        browser.click( E("[name = 'btnK']") )

6. Run

Use pytest for running tests:

$ pytest --steps

Add --steps option for verbose log.

7. CLI options

$ pytest --env=<env> - run tests with settings file <env>.yml from _env dir

$ pytest --listener - highlight found element during runtime

$ pytest --save-screenshot - save screenshot on failure in _output dir

$ pytest --steps - enable verbose log

Last updated