microsoft / EasyRepro

Automated UI testing API for Dynamics 365
MIT License
513 stars 285 forks source link

I am using specflow, Easy Repro, Selenium and C#, facing issue while closing app, #1334

Open chandramohand opened 1 year ago

chandramohand commented 1 year ago

I am using Specflow, Easy Repro, Selenium and C#, facing issue while closing app, To createapp I am using the following method. public static void AdfsLoginAction(LoginRedirectEventArgs args) { args.Driver.FindElement(By.Name("passwd")).SendKeys(args.Password.ToUnsecureString()); //Input webelemnt has been changed from Password to Passwd args.Driver.ClickWhenAvailable(By.Id("idSIButton9"), new TimeSpan(0, 0, 2)); Thread.Sleep(500); args.Driver.WaitForPageToLoad(); if (args.Driver.HasElement(By.Id("idSIButton9"))) { args.Driver.ClickWhenAvailable(By.Id("idSIButton9")); }
}

    public static void CreateApp(BrowserOptions options = null)
    {
        Trace.WriteLine($"Start ({CrmUrl})");
        options = options ?? TestSettings.Options;
        SetOptions(options);
        _client = new WebClient(options);
        _xrmApp = new XrmApp(_client);
        _xrmApp.OnlineLogin.Login(CrmUrl, Username1, Password2, null, AdfsLoginAction);
        Trace.WriteLine("Success");
       // return _xrmApp;
    }

where I see the driver is getting invoked through LoginRedirectEventArgs, after the test execution how to close the browser? Can anyone please help.
Thanks, Chandra.

RaviYenumula commented 1 year ago

@chandramohand You can close the browser AfterScenario using the following dispose method. xrmApp.Dispose();

Hope that helps

chandramohand commented 1 year ago

Hi @RaviYenumula, Thanks for your reply.
The issue has been resolved while initialling the webdriver xrmApp declared as Private, I was unable to quit that browser. Once declared as public its working fine. Thanks, Chandra.

RaviYenumula commented 1 year ago

@chandramohand Glad it sorted out.