microsoft / EasyRepro

Automated UI testing API for Dynamics 365
MIT License
521 stars 288 forks source link

[BUG] Object reference not set to an instance of an object. #1423

Closed leh-fabros closed 3 months ago

leh-fabros commented 3 months ago

Bug Report

EasyRepro Version N/A

UCI or Classic Web N/A

Online or On Premise N/A

Browser

Describe the bug
Clone the latest version of the UIAutomation repo. Open the Solution in Visual Studio 2022. Build.

I am receiving the following error message when running any tests under the ProjectOps:

Class Initialization method Microsoft.Dynamics365.UIAutomation.Sample.ProjectOps."TestName".Initialize threw exception. System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object..

Checking the line, the issue refers to the following code:

       _username = _testContext.Properties["OnlineUsername"].ToString().ToSecureString();

I assume that the rest of the keys would also cause an error.

        _password = _testContext.Properties["OnlinePassword"].ToString().ToSecureString();
        _mfaSecretKey = _testContext.Properties["OnlinePassword"].ToString().ToSecureString();
        _xrmUri = new Uri(_testContext.Properties["OnlineCrmUrl"].ToString());
        _browserType = (BrowserType)Enum.Parse(typeof(BrowserType), _testContext.Properties["BrowserType"].ToString());
        _azureKey = _testContext.Properties["AzureKey"].ToString();
        _sessionId = _testContext.Properties["SessionId"].ToString() ?? Guid.NewGuid().ToString();
        _driversPath = _testContext.Properties["DriversPath"].ToString();

Expected behavior
The test should execute as expected.

Screenshots

This is the log in information in the AppSettings

image

Additional context

All other test under the UCI folder runs as expected.

leh-fabros commented 3 months ago

I figured out the issue. It wasn't a bug but it was missing the parameter values in the EasyPro.runsettings. After updating and using assigning the EasyPro.runsettings I was able to go past the error message reported.

I am now receiving a different error message but will try to figure it out and see how far I can go.