TestResults.io
  • What is TestResults.io
  • System Architecture
  • Regulated Markets
    • Health Care Industry
    • Financial Services Industry
  • What's new?
    • Update Instruction
      • Update of the Designer extension in Visual Studio
      • Update the Execution Engine
      • Update the Base- and Environment Models
    • Migration to new project file
  • Designer
    • Overview
    • First Steps
    • Installation
    • TestResults.io solution
    • The development environment
      • Tool Window Overview
        • Test Environments
          • Steps to configure a SUT VM
          • How to access files on the system under test
        • Remote Viewer
          • Control Mode
          • Capture Mode
          • Screen Editor
          • Capture Single Image
        • Screen Explorer
        • Test Case Designer
        • Image Explorer
        • API Testing
        • TestResults.io options
          • Engines
          • Servers
    • Test Cases
      • Adding Test Cases
      • Test Case structure
      • Simple Test Case (Example)
      • Executing your Test Case
      • Generating Test Containers
      • Publishing Test Cases
      • Execution Variables
    • Software Models
      • Adding SW Models
      • Referencing the Model in the Test Case
      • Generating Test Containers
      • Publishing SW Models
      • Screens and Screen Elements
        • Tables
        • Visual Sense
        • Custom Screen Elements
    • Installers
      • Adding Installers
      • Generating Test Containers
      • Publishing Installers
    • Automation Framework Reference
      • Attributes
      • Enumerations
      • Filters
        • IImageFilter Interface
        • Select
        • Resize
      • GlobalEngineParameters
      • ImageDetectionParameters
      • ImageReference
      • Interfaces
        • ITester Interface
          • ITester Methods
          • ITester Properties
        • ITestee Interface
          • ITestee Methods
        • IConnections Interface
          • IConnections Methods
          • IConnections Properties
        • IDebug Interface
        • IEngineResult
        • IHelpers Interface
        • IImageHelper Interface
          • IImageHelper Methods
        • IKeyboard Interface
          • IKeyboard Methods
        • IMouse Interface
          • IMouse Methods
          • IMouse Properties
        • IReport Interface
          • IReport Methods
        • ISUTConnection Interface
      • OcrEngineParameters
        • Best practise
        • IronOcrEngineParameters
        • LEADOcrEngineParameters
        • OcrEngineRelatedCharacters
        • OcrPreprocessingParameters
      • ResultRectangle
      • SutNotReadyException
      • TestStepAbortedException
    • FAQ
      • Two-factor authentication (2FA) and One Time Passwords (OTP)
      • Receive and verify Emails
      • Using Excel as test data source
      • Verify PDF Content
  • Portal
    • Overview
    • First Steps
    • User's Guide
      • Login
      • Projects
      • Dashboard
      • Test Cases
      • Software & Environments
      • Test Sets
      • Job Queue
      • Management
      • Notifications Summary
    • Automation Engineer's Guide
      • Test Automation Workflow
      • Automating a test case
      • Enabling Software & Environments
    • REST API Reference
      • Authentication
      • Projects
      • Test Sets
      • Test Cases
      • Test Plans
      • Test Reports
      • Files
      • Software
      • Environments
      • Untitled
      • Executions
      • Favorites
      • Statistics
      • User Management
      • Customer Management
      • Notifications
      • Configurations
      • Invoicing
  • Models
    • Overview
    • Base Model
      • BaseScreen
        • BaseScreen Properties
        • BaseScreen Methods
      • OnScreenElement
        • OnScreenElement Methods
        • OnScreenElement Properties
      • Primitives
        • Button
          • Button Methods
          • Button Properties
        • Checkbox
          • Checkbox Methods
        • ContextMenu
          • ContextMenu Methods
          • ContextMenu Properties
        • Dropdown
          • Dropdown Methods
          • Dropdown Properties
        • DropdownMenu
          • DropdownMenu Methods
          • DropdownMenu Properties
        • GenericScroller
          • GenericScroller Methods
          • GenericScroller Properties
        • HorizontalScroller
        • IconButton
          • IconButton Properties
        • Label
        • LabelWithButton
          • LabelWithButton Properties
        • LabelWithCheckbox
          • LabelWithCheckbox Properties
        • LabelWithValue
          • LabelWithValue Methods
          • LabelWithValue Properties
        • PwTextBox
          • PwTextBox Methods
        • TextBox
          • TextBox Methods
          • TextBox Properties
        • Tables and lists
          • Column
            • Column Methods
            • Column Properties
          • ItemList
            • ItemList Methods
            • ItemList Properties
          • Row
            • Row Methods
            • Row Properties
          • TableBase
            • TableBase Methods
            • TableBase Properties
        • LabelWithElementBase
          • LabelWithElementBase Properties
      • Enumerations
      • Extensions
        • EngineResultExtensions Methods
        • EnumExtensions Methods
        • ReportExtensions Methods
        • StringExtensions Methods
        • TesterConnectionExtensions Methods
        • TesterDebugExtensions Methods
        • TesterHelperExtensions Methods
        • TesterMouseExtensions Methods
        • TesterOnScreenElementExtensions
        • TesterSelectExtensions Methods
      • Helper Classes
        • BaseModelHelpers
          • BaseModelHelpers Methods
          • BaseModelHelpers Properties
        • Attributes for Designer
        • ListHelpers
      • Exceptions
        • ElementNotFoundException
        • InteractionFailedException
        • ScreenNotFoundException
      • Interfaces
        • IAppBasics Interface
          • IAppBasics Methods
          • IAppBasics Properties
        • IBrowser
        • ICommandLineWindow
        • IScroller Interface
          • IScroller Methods
          • IScroller Properties
        • ISutLocale Interface
          • ISutLocale Methods
          • ISutLocale Properties
        • ISystemHelpers
        • ISystemInteractions
        • IWindow
    • Environment Model
      • Windows
        • Screens
          • CmdWindow
            • CmdWindow Methods
            • CmdWindow Properties
          • FileDialog
            • FileDialog Methods
            • FileDialog Properties
          • FileExplorer
            • FileExplorer Properties
          • RunWindow
            • RunWindow Methods
            • RunWindow Properties
          • Window
            • Window Methods
            • Window Properties
        • SutLocale
          • SutLocale Methods
          • SutLocale Properties
        • SystemHelpers
          • SystemHelpers Methods
          • SystemHelpers Properties
        • SystemInteractions
        • WebBrowser
          • Browser
            • Browser Methods
            • Browser Properties
          • BrowserScroller
            • BrowserScroller Methods
            • BrowserScroller Properties
          • AuthenticationDialog
            • AuthenticationDialog Methods
            • AuthenticationDialog Properties
          • DownloadDialog
            • DownloadDialog Methods
            • DownloadDialog Properties
        • EnvironmentModel Enumerations
        • Interfaces
          • IWebAppBasics
            • IWebAppBasics Property
Powered by GitBook
On this page
  • Demo Testcase
  • Step by Step Guide

Was this helpful?

  1. Designer
  2. FAQ

Two-factor authentication (2FA) and One Time Passwords (OTP)

PreviousFAQNextReceive and verify Emails

Last updated 1 year ago

Was this helpful?

To test 2FA usually one of the many Authentication Apps is required. TestResults.io has build a NuGet Package with the same functionality.

The Nuget can be found online:

Demo Testcase

Check out the Demo Testcase using our NuGet to generate Codes from a QR-Code.

[TestStep(1, 
    TestInput = "Activate 2FA with a QR code displayed on the Screen.", 
    ExpectedResults ="2FA can be activated.")
]
public void Step1(ITester t)
{
    //make sure to add the NuGet Package "TestResults.AddOn.OTP" to this testcase project
    //in your application navigate to the screen where you enable 2FA
    //make sure the QR code is visible on the screen
    var code = OtpReader.GetOtpCode(t.Connections.Active.CurrentScreenAsImage, out string otpAuthUri); //reads the QR code from the screen and returns the code
    t.Report.PassStep($"Received code for 2FA: \"{code}\" and URI: \"{otpAuthUri}\"");

    //enter the code in your Application to activate 2FA
    //WARNING: if you activate 2FA, make sure you save the otpAuthUri string or you will later be locked out of your account

    //if the code is rejected, it is most likely already expired. Call "OtpReader.GetOtpCode(_otpAuthUri)" to get a new code
    //if you logout and login again you can also request a new code like this
    var newCode = OtpReader.GetOtpCode(otpAuthUri);
}

Step by Step Guide

  1. Navigate to "Manage NuGet Packages" in the context menu of the Testcase Project.

  1. Search and install the current version of the NuGet "TestResults.Addon.OTP".

  1. Navigate back to your test case. At the top add the using of the new Nuget.

using TRIO.AddOn.OTP;
  1. Inside a teststep make sure to navigate to the screen where you enable 2FA and make sure the QR code is visible on the screen.

  2. The following code can be used to generate a one time password with the QR-Code currently shown on the Screen:

//reads the QR code from the screen and returns the code
string code = OtpReader.GetOtpCode(t.Connections.Active.CurrentScreenAsImage, out string otpAuthUri); 
t.Report.PassStep($"Received code for 2FA: \"{code}\" and URI: \"{otpAuthUri}\"");
  1. WARNING: make sure to save the logged "otpAuthUri" string if you enable 2FA or you will be later locked out of this account

  2. If the password gets rejected, it is most likely already expired as a password is usally only valid for one minute. Use the following code to request a new one. The same code can be used to request a password if you logout and login again.

var newCode = OtpReader.GetOtpCode(otpAuthUri);

https://github.com/TestResultsIO/DemoAutoScout24/blob/05a81c99261d1d65abf9a96f6bad0c0aba5960c9/TC006_Rev1/_2FA.cs
LogoTestResults.AddOn.OTP 1.0.0nuget
Right-Click the Testcase Project to the "Manage Nuget Packages" menu entry
Search and install the NuGet "TestResults.Addon.OTP"