microsoft / EasyRepro

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

[BUG] ChromeDriver not found after updating NuGet package from 9.1.0.5230 to 9.1.0.6210 #615

Open mVermaat opened 4 years ago

mVermaat commented 4 years ago

Bug Report

Issues should only be created for items related to covered functionality.

Not covered functionality, feature requests, and questions should use the Feature Request or Question templates.

EasyRepro Version

UCI or Classic Web

Online or On Premise

Browser

Describe the bug
I updated the NuGet package from 9.1.0.5230 to 9.1.0.6210. When i try to login (which starts the browser) I now get an error message that the ChromeDriver cannot be found. For some reason it searches in the TestResults folder.

Error Message

OpenQA.Selenium.DriverServiceNotFoundException: The file C:\Github\mVermaat\Crm.Specflow\TestResults\chromedriver.exe does not exist. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html

StackTrace:

   at OpenQA.Selenium.DriverService..ctor(String servicePath, Int32 port, String driverServiceExecutableName, Uri driverServiceDownloadUrl)
   at OpenQA.Selenium.Chrome.ChromeDriverService..ctor(String executablePath, String executableFileName, Int32 port)
   at Microsoft.Dynamics365.UIAutomation.Browser.BrowserDriverFactory.CreateWebDriver(BrowserOptions options)
   at Microsoft.Dynamics365.UIAutomation.Browser.InteractiveBrowser.get_Driver()
   at Microsoft.Dynamics365.UIAutomation.Browser.BrowserPage.Execute[TResult,T1,T2,T3,T4](BrowserCommandOptions options, Func`6 delegate, T1 p1, T2 p2, T3 p3, T4 p4)
   at Microsoft.Dynamics365.UIAutomation.Api.UCI.WebClient.Login(Uri orgUri, SecureString username, SecureString password)
   at Microsoft.Dynamics365.UIAutomation.Api.UCI.OnlineLogin.Login(Uri orgUrl, SecureString username, SecureString password)
   at Vermaat.Crm.Specflow.EasyRepro.UCIBrowser.Login(Uri uri, UserDetails connectionString) in C:\Github\mVermaat\Crm.Specflow\Vermaat.Crm.Specflow\EasyRepro\UCIBrowser.cs:line 44
   at Vermaat.Crm.Specflow.EasyRepro.BrowserManager.GetBrowser(BrowserOptions options, UserDetails userDetails, Uri uri) in C:\Github\mVermaat\Crm.Specflow\Vermaat.Crm.Specflow\EasyRepro\BrowserManager.cs:line 37
   at Vermaat.Crm.Specflow.SeleniumTestingContext.GetBrowser() in C:\Github\mVermaat\Crm.Specflow\Vermaat.Crm.Specflow\SeleniumTestingContext.cs:line 37
   at Vermaat.Crm.Specflow.Commands.CreateRecordCommand.ExecuteBrowser() in C:\Github\mVermaat\Crm.Specflow\Vermaat.Crm.Specflow\Commands\CreateRecordCommand.cs:line 32
   at Vermaat.Crm.Specflow.Commands.BrowserCommandFunc`1.Execute(CommandAction commandAction) in C:\Github\mVermaat\Crm.Specflow\Vermaat.Crm.Specflow\Commands\BrowserCommand.cs:line 29
   at Vermaat.Crm.Specflow.CommandProcessor.Execute[TResult](ICommandFunc`1 command, CommandAction commandAction) in C:\Github\mVermaat\Crm.Specflow\Vermaat.Crm.Specflow\CommandProcessor.cs:line 22
   at Vermaat.Crm.Specflow.Steps.GeneralSteps.GivenEntityWithValues(String entityName, String alias, Table criteria) in C:\Github\mVermaat\Crm.Specflow\Vermaat.Crm.Specflow\Steps\GeneralSteps.cs:line 40
   at lambda_method(Closure , IContextManager , String , String , Table )
Haywaii commented 4 years ago

Yes got the same problem, i guess it's the way the new package try to find the chromedriver extension. I tried to solve it but nothing works so far so I did downgraded to 9.1.0.5230. @tylerd for you information :)

rsObjektkultur commented 4 years ago

I got a similar issue:

The file C:\Users\rs\AppData\Local\Temp\chromedriver.exe does not exist. The driver can be downloaded at http://chromedriver.storage.googleapis.com/index.html

Is anyone looking into this problem, which makes the latest version completely useless and persists for almost two months?

rsObjektkultur commented 4 years ago

Ok, found a workaround: one needs to set the DriversPath in the options object:

var options = new BrowserOptions
            {
                BrowserType = BrowserType.Chrome,
                UCITestMode = true,
                DriversPath = GetDriverPath()
            };

var webClient = new WebClient(options);    
crm = new XrmApp(webClient);

I still think this behaviour should be fixed, because it worked without an explicit path before the mentioned updated. Moreover the default selenium webdriver does not require an explicit path, so why does EasyRepro?

Luckily in my case the driver is in the same location as the executing assembly:

protected static string GetDriverPath()
        {
            var assemblyPath = Assembly.GetExecutingAssembly().Location;
            Logger.Debug($"Assembly Path: {assemblyPath}");

            var indexFileName = assemblyPath.LastIndexOf('\\');
            return assemblyPath.Substring(0, indexFileName);
        }