0

My tests in Selenium Xunit 2.0 from different collection class run parallel and dispose method call once only. I want to call to dispose the method after each test run even if they run in parallel.

[TestClass]
    public class Basic : IDisposable
    {
       
        protected void StopDriver()
        {
            #capture screenshot here
        }

        public void Dispose()
        {
            StopWebDriver();
            WebDriver.Dispose();
        }
    }
Gkm
  • 237
  • 1
  • 5
  • 19
  • Why don't you just stop the web driver and dispose of it in the `StopDriver` function? – Robert Harvey Mar 16 '21 at 18:28
  • I am sorry I dont understand your point. I need to implement dispose method if I donot then will get this message "Basic class doesnt implement interface member 'IDisposable.Dispose()'" – Gkm Mar 16 '21 at 18:34
  • I never said you couldn't implement IDisposable. But if it doesn't do what you need it to do ... – Robert Harvey Mar 16 '21 at 18:41
  • Can you please give example how to do this without IDisposable? – Gkm Mar 16 '21 at 18:52
  • Move your calls to `StopWebDriver()` and `WebDriver.Dispose()` into your `StopDriver` method (assuming that's what StopDriver actually does). Don't change anything else. – Robert Harvey Mar 17 '21 at 01:27
  • StopDriver is not a method of any SDK, it will not do as you expecting it to do. – Gkm Mar 22 '21 at 08:40

0 Answers0