NullReferenceException thrown in BrowserWorkflowPlugin.ShutdownBrowser

Home Forum Web General Discussion NullReferenceException thrown in BrowserWorkflowPlugin.ShutdownBrowser

  • Author
    Posts
  • #3547
    Helpful
    Up
    0
    Down
    Not Helpful

    Nick Verheyden
    Participant
    @nick-verheyden

    I’m debugging through Bellatrix.SpecFlow.Web.MSTest.Tests in the templates, and finding that all of the scenarios are failing.

    The common exception across all scenarios is a NullReferenceException in the post-scenario cleanup…

    E.g.
    CookiesServiceCommonSteps
    Source: CrossBrowserTestingIntegration.feature line 28
    Duration: 15 sec

    Message:
    TestCleanup method Bellatrix.SpecFlow.Web.MSTest.Tests.CrossBrowserTestingIntegrationFeature.TestTearDown threw exception. System.NullReferenceException: System.NullReferenceException: Object reference not set to an instance of an object..
    Stack Trace:
    BrowserWorkflowPlugin.ShutdownBrowser(IServicesCollection container) line 115
    BrowserWorkflowPlugin.PostAfterScenario(Object sender, TestWorkflowPluginEventArgs e) line 88
    TestWorkflowPluginProvider.RaiseTestEvent(EventHandler1 eventHandler, TestOutcome testOutcome, String featureName, String scenarioName, List1 featureTags, List`1 scenarioTags, String message, String stackTrace) line 95
    TestWorkflowPluginProvider.PostAfterScenario(TestOutcome testOutcome, String featureName, String scenarioName, List1 featureTags, List1 scenarioTags, String message, String stackTrace) line 62
    BaseSpecFlowHooks.PostAfterScenario(FeatureContext featureContext, ScenarioContext scenarioContext) line 141
    BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration)
    TestExecutionEngine.InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, HookType hookType)
    TestExecutionEngine.FireEvents(HookType hookType)
    TestExecutionEngine.OnScenarioEnd()
    TestRunner.OnScenarioEnd()
    CrossBrowserTestingIntegrationFeature.TestTearDown()

    Looking more closely, in file BrowserWorkflowPlugin.Workflow.cs, the TestWorkflowPluginEventArgs e.Container is not initialised when passed to ShutdownBrowser() from PostAfterScenario(). TestWorkflowPluginEventArgs are initialised in RaiseTestEvent() in TestWorkflowPluginProvider.cs, and the Container member is never initialised.

    I demonstrated this behaviour using the source code downloaded from Bellatrix.solutions today (30th October 2020), using Google Chrome 86.0.4240.111 (Official Build) (64-bit) and v1.9.5.86 of Bellatrix.Web.Chrome webdriver, and have not changed any code or the default configuration of the solution.

    Perhaps related is that DetermineTestClassFullName() called from InitializeDriverOptions() in BrowserWorkflowPlugin.Workflow.cs is unable to determine the scenario name from the stack trace, so the driverOptions are never initialised.

    Is this something that you are able to replicate, or is it perhaps specific to my environment?

  • #3548
    Helpful
    Up
    0
    Down
    Not Helpful

    Nick Verheyden
    Participant
    Participant
    @nick-verheyden

    May also be relevant, I’m running the tests via Test Explorer in Visual Studio Professional 2019, version 16.7.7.

  • #3550
    Helpful
    Up
    0
    Down
    Not Helpful

    aangelov
    Keymaster
    @anton1

    Hello Nick,

    Thank you for reporting this issue. We found the problem and a fixed version will be uploaded probably tomorrow.

    Anton

    Best,
    Anton
    Co-Founder and CTO Automate The Planet
    Inventor Bellatrix Test Automation Framework

  • #3557
    Helpful
    Up
    0
    Down
    Not Helpful

    aangelov
    Keymaster
    @anton1

    The fix is LIVE.

    Best,
    Anton
    Co-Founder and CTO Automate The Planet
    Inventor Bellatrix Test Automation Framework

  • #3558
    Helpful
    Up
    0
    Down
    Not Helpful

    aangelov
    Keymaster
    @anton1

    The fix is LIVE.

    Best,
    Anton
    Co-Founder and CTO Automate The Planet
    Inventor Bellatrix Test Automation Framework

  • #3561
    Helpful
    Up
    0
    Down
    Not Helpful

    Nick Verheyden
    Participant
    Participant
    @nick-verheyden

    I downloaded the source zip for Aquila Release 2.1.0.0, and I’m still able to replicate the same behaviour.

    Please can I check I’ve got the source code that includes the fix? Zip is 3.186 KB, and only change to BrowserWorkflowPlugin.Workflow.cs is the inclusion of System.Threading and Bellatrix.Logging?

    Regards,
    Nick

  • #3562
    Helpful
    Up
    0
    Down
    Not Helpful

    aangelov
    Keymaster
    @anton1

    There are other changes too. Keep in mind that you cannot run CrossBrowserTesting tests without using the cloud platform’s valid account. The two feature files that are intended to work without specific configuration locally are CommonServicesFeature and NavigateToBELLATRIXOnline… All other tests are related to cloud providers, where you need to provide account data in the config. I tried the tests on the screenshot on two different machines from the same zip you have downloaded.

    Attachments:
    You must be logged in to view attached files.

    Best,
    Anton
    Co-Founder and CTO Automate The Planet
    Inventor Bellatrix Test Automation Framework

  • #3592
    Helpful
    Up
    0
    Down
    Not Helpful

    Nick Verheyden
    Participant
    Participant
    @nick-verheyden

    Hello again,

    I do appreciate that you’re seeing different results that I am, and that you’ve verified this on two separate machines suggests that it’s perhaps down to my environment that’s causing this issue.

    All said, I’m still unable to get any tests to complete successfully when the conditional statement in the PostAfterScenario member of the BrowserWorkflowPlugin class in BrowserWorkflowPlugin.Workflow.cs evaluates to true, and the ShutdownBrowser(e.container); call is made with e.container = NULL, causing a runtime exception.

    Does your browser configuration on your test machines include restarting every time or restarting on failures? The Belatrix.SpecFlow.Web.MSTest.Tests that I’m using BrowserBehaviour takes a value of RestartEveryTime, which seems to be the default?

    Would be keen to get past this problem so we can start using the Bellatrix framework as part of our ART solution, and hopefully help identify this unexpected Bellatrix behaviour that maybe also frustrating other users. Please shout if I can provide any more replication details to allow you to replicate the same behaviour I’m experiencing.

    Many Thanks for your help so far,
    Nick

  • #3593
    Helpful
    Up
    0
    Down
    Not Helpful

    djburo
    Participant
    @djburo

    Hey Nick,

    I am sorry to hear that you still have this issue. We are working for a better fix for it and hopefully, it will go Live next days.
    But till then I can suggest a workaround for the problem.

    ShutdownBrowser(e.Container); => ShutdownBrowser(ServicesCollection.Current);

    It will fix your problem right now, We need some time to test if everything other works like expected with such a change.
    For now, it looks fine but we need some more time for the official release, but most probably this will be the official change too.

    Best,
    Ventsislav Ivanov

You must be logged in to reply to this topic.