riezebosch / Consoleum

Selenium for Console Apps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AppVeyor NuGet Consoleum NuGet Consoleum.PageObjects

Consoleum

A Selenium-like solution for automating console applications.

action

Origin

This project is a spin-off from a SpecFlow exercise. Don't get bogged down with automation-id's or css selectors but write UI tests against a good-ol' console application while still using practices like Page Object Design Pattern.

How

Use the IConsoleDriver and ConsoleDriver to start the process and the provided ICaptureOutput and IKeyboardSimulator to interact with the console.

Page Objects

You can use this package without or use plain POCO's, but you might want to use the Page base class from the Consoleum.PageObjects package instead.

public void SomeTestMethod()
{
    using (var driver = new ConsoleDriver("some-app.exe"))
    {
        driver.Start();

        Page
            .StartWith<Main>(driver)
            .SomeActionOnCurrentPage()
            .SomeNavigationAction()
            .ShouldBeLoggedInByNow();
    }
}
class Main : Page
{
    public override bool IsOpen => ExistsInOutput("pattern-matching-output-on-this-page");

    public Main SomeActionOnCurrentPage()
    {
        Driver
            .Keyboard
            .KeyPress(...)
            .Sleep(200);
        
        return this;
    }

    public Another SomeNavigationAction()
    {
        Driver
            .Keyboard
            .KeyPress(...)
            .Sleep(200);
        
        return NavigateTo<Another>();
    }
}

Look at the tests for more inspiration on reusing the driver over multiple tests and assertions using Shouldly.

Why not xplat?

This package relies heavily on Windows Desktop functions for starting the process, capturing the output on the clipboard using keystrokes and native Win32 invocations to grab that data from the clipboard. You do the math why it can't be xplat.

About

Selenium for Console Apps


Languages

Language:C# 93.4%Language:PowerShell 6.6%