304NotModified / 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 use the Page base class instead to make navigation a bit more straightforward.

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>();
    }
}
public void SomeTestMethod()
{
    using (var driver = new ConsoleDriver("some-app.exe"))
    {
        driver.Start();

        var page = driver
            .StartWith<Main>(driver)
            .SomeActionOnCurrentPage()
            .SomeNavigationAction();
    }
}

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

.NET Core?

This package heavily relies 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 can figure out why it's not plain core.

About

Selenium for Console Apps


Languages

Language:C# 93.2%Language:PowerShell 6.8%