# Live server & client

These instruments allows you to lunch a live servers and live clients, e.g. for UI testing purposes.

class pytest_djangoapp.fixtures.live.LiveClient(*, browser: str)

  Base class for live clients.

class pytest_djangoapp.fixtures.live.SeleniumLiveClient(*, browser: str)

  This live client wraps Selenium.

  https://selenium-python.readthedocs.io/

pytest_djangoapp.fixtures.live.liveclient()

  Runs a live client. Available as a context manager.

  Example:

      def test_live(liveserver, liveclient):

          with liveserver() as server:

              # Let's run Firefox using Selenium.
              with liveclient('selenium', browser='firefox') as client:
                  selenium = client.handle  # Selenium driver is available in .handle

                  # Let's open server's root URL and check heading 1 on that page
                  selenium.get(server.url)
                  assert selenium.find_element('tag name', 'h1').text == 'Not Found'

pytest_djangoapp.fixtures.live.liveserver() → Type[LiveServer]

  Runs a live server. Available as a context manager.

  Warning

  For Django >= 4.0

  Example:

      def test_live(liveserver):

          with liveserver() as server:
              print(f'Live server is available at: {server.url}')