microsoft / EasyRepro

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

UCI XrmApp test fails, but corresponding Browser test works #635

Open ikeselman opened 5 years ago

ikeselman commented 5 years ago

Hi everyone I am using VSTS Community Edition 2019 and EasyRepro Git Demo Projects

using (var xrmBrowser = new Api.Browser(TestSettings.Options)) { xrmBrowser.LoginPage.Login(_xrmUri, _username, [_password); xrmBrowser.GuidedHelp.CloseGuidedHelp();

        xrmBrowser.ThinkTime(500);
        xrmBrowser.Navigation.OpenSubArea("Sales Hub", "Accounts");

        xrmBrowser.ThinkTime(2000);
        xrmBrowser.Grid.SwitchView("Active Accounts");

        xrmBrowser.ThinkTime(1000);
        xrmBrowser.CommandBar.ClickCommand("New");

        xrmBrowser.ThinkTime(5000);
        xrmBrowser.Entity.SetValue("name", "Test API Account");
        xrmBrowser.Entity.SetValue("telephone1", "555-555-5555");
        //xrmBrowser.Entity.SetValue("websiteurl", "https://easyrepro.crm.dynamics.com");

        xrmBrowser.CommandBar.ClickCommand("Save & Close");
        xrmBrowser.ThinkTime(2000);

Test starts fine and access to Sandbox successful but then while looking for open 'Sales Hub' test fail I am getting following error

Message: Test method Microsoft.Dynamics365.UIAutomation.Sample.Web.CreateAccount.WEBTestCreateNewAccount threw exception: System.Exception: Login page failed. Stack Trace: at <>c.b__12_2(IWebDriver f) at SeleniumExtensions.WaitUntilVisible(IWebDriver driver, By by, TimeSpan timeout, Action1 successCallback, Action1 failureCallback) at LoginDialog.Login(IWebDriver driver, Uri uri, SecureString username, SecureString password, Action1 redirectAction) at DelegateBrowserCommand5.ExecuteCommand(IWebDriver driver, Object[] params) at BrowserCommand1.Execute[T1,T2,T3,T4,T5,T6,T7,T8,T9](IWebDriver driver, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5, T6 p6, T7 p7, T8 p8, T9 p9) at BrowserCommand1.Execute[T1,T2,T3,T4](IWebDriver driver, T1 p1, T2 p2, T3 p3, T4 p4) at BrowserPage.Execute[TResult,T1,T2,T3,T4](BrowserCommandOptions options, Func`6 delegate, T1 p1, T2 p2, T3 p3, T4 p4) at LoginDialog.Login(Uri uri, SecureString username, SecureString password) at CreateAccount.WEBTestCreateNewAccount() in CreateAccount.cs line: 25

Capture1

To fix this issue above, I've added Schema to Source Control like it asked on following link https://stackoverflow.com/questions/6774578/nuget-packages-element-is-not-declared-warning

New error I in-counted when Building Solution:

Severity Code Description Project File Line Suppression State Warning CS0618 'ExpectedConditions' is obsolete: 'The ExpectedConditions implementation in the .NET bindings is deprecated and will be removed in a future release. This portion of the code has been migrated to the DotNetSeleniumExtras repository on GitHub (https://github.com/DotNetSeleniumTools/DotNetSeleniumExtras)' Microsoft.Dynamics365.UIAutomation.Browser C:\Users\ikeselman\Source\Repos\EasyRepro\Microsoft.Dynamics365.UIAutomation.Browser\Extensions\SeleniumExtensions.cs 681 Active

Looking how to fix this

Haywaii commented 5 years ago

Hi @ikeselman

You're last error is a warning not an actual error from what i see but you just need to download through VS the DotNetSeleniumExtra package in your project and use it every time you used the selenium package one. You can find this one by browsing "DotNetSeleniumExtras" on the marketplace and download the page object one at least.

It will be better and you will not get that anymore.

Is that helpful?

ikeselman commented 5 years ago

Hi Haywaii, Appreciate your help I installed packages you suggested, then Clear Solution and Build Solution again. Now new warning coming: Warning CS0436 The type 'Constants' in 'C:\Users\ikeselman\Source\Repos\EasyRepro\Microsoft.Dynamics365.UIAutomation.Browser\Constants.cs' conflicts with the imported type 'Constants' in 'Microsoft.Dynamics365.UIAutomation.Browser, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in 'C:\Users\ikeselman\Source\Repos\EasyRepro\Microsoft.Dynamics365.UIAutomation.Browser\Constants.cs'. Microsoft.Dynamics365.UIAutomation.Browser C:\Users\ikeselman\Source\Repos\EasyRepro\Microsoft.Dynamics365.UIAutomation.Browser\InteractiveBrowser.cs 689 Active

Haywaii commented 5 years ago

This one is just a warning nothing to worry about for failure (it could lead to other problem but it's not a blocker). You can build your solution and run your test. It's just mean you need to choose which constants object you want to use. I don't know your code but will recommand using the one in Constants.cs everytime.

ikeselman commented 5 years ago

Thanks a lot I am using Demo Solution from GitHub named microsoft/EasyRepro UIAutomation with 4 Project inside. I building Solution but getting

Error CS1061 'Navigation' does not contain a definition for 'RetrieveServerVersion' and no accessible extension method 'RetrieveServerVersion' accepting a first argument of type 'Navigation' could be found (are you missing a using directive or an assembly reference?) Microsoft.Dynamics365.UIAutomation.Sample C:\Users\ikeselman\Source\Repos\EasyRepro\Microsoft.Dynamics365.UIAutomation.Sample\Web\ValidationTests\ValidationVersion.cs 28 Active

Regarding recommendation using the one in Constants.cs everytime not sure if I use Microsoft referenced one: https://referencesource.microsoft.com/#System.Deployment/System/Deployment/Application/Constants.cs

Haywaii commented 5 years ago

At this point it will be difficult to help. I am not very skilled with the sample project. I never heard of a method "RetrieveServerVersion" with Navigation object tho.

Maybe someone else would be able to help. Can you give more details for everyone here please? (for which project you got the error, which version of the package by example)

For the package, i would recommend for every class where you using it, removed the namespace and add it again (same one for every class where you are using it). So you can see if you still got the warning and why.

ikeselman commented 5 years ago

I am getting error for Project Microsoft.Dynamics365.UIAutomation.Sample

My packages.config package id="DotNetSeleniumExtras.PageObjects" version="3.11.0" targetFramework="net46" /> package id="Dynamics365.UIAutomation.Api" version="9.0.2.7" targetFramework="net46" />

Haywaii commented 5 years ago

Uhm i am wondering if it's not linked to the error with the new version of the framework that some people are getting now. Can you try to downgrade to an older one and check what happen please?

ikeselman commented 5 years ago

I tried already and I have a feeling it is because Visual Studio 2019 Community Edition I am using and need to downgrade to 2017 one Do you know if it any way to install 2017 Community edition? When I download 2017 from MS and installing it to Windows 10 VM it is installing 2019 instead - I looking for other option Here where I got VS 2017 version from and still get 2019
https://docs.microsoft.com/en-ca/visualstudio/productinfo/vs2017-compatibility-vs

Thanks a lot

ikeselman

Haywaii commented 5 years ago

I don't use Community edition so i don't know but you can normally install two version of VS without any problem (i got two versions here at work).

best shot is to make sure you deinstall everything from VS 2019 to be sure.

Can't help more here i'm afraid. Good luck

ikeselman commented 5 years ago

Thanks @Haywaii I uninstalled 2019 version and install 2017, Installing NuGet Packages required for Dynamics 365 online ver 9.0 When Build Solution getting same Warning The 'packages' element is not declared. Microsoft.Dynamics365.UIAutomation.Sample C:\Users\ikeselman\Documents\Visual Studio 2017\Projects\EasyRepro-develop\Microsoft.Dynamics365.UIAutomation.Sample\packages.config 2

I just looked into Dependencies - I know it causing issues sometimes. But unable to figure out what dependencies I need Uninstall or Install Here Dynamics Dependencies: image

Here Selenium.Support Dependencies: image

Here for Selenium.WebDriver:

image

Here for Newtonsoft.Json image

There are no Dependencies available for Selenium.WebDriver.GeckoDriver.Win64 for Selenium.WenDriver/IEDriver for Selenium.WebDriver.ChromeDriver.Win64

ikeselman commented 5 years ago

Hi Emmanuel, Good news: we figure out how to fix issue with error when Building Solution. I was getting error "Does not contain a static 'main' method suitable for an entry point" Here is Solution under this link: https://stackoverflow.com/questions/9607702/does-not-contain-a-static-main-method-suitable-for-an-entry-point

That great. Now I have small issue with Chrome Browser versions When I try Run Test "Create Account: WEBTestCreateNewAccount" it is Fail and I am getting into error message: SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 74 though Chrome v74 is installed

Steps I found and done so far, I followed Solution from this link https://stackoverflow.com/questions/54927496/how-to-download-older-versions-of-chrome-from-a-google-official-site

My issue that when I found version mentioned on NuGet Packages 74.0.3729.6 and attach to "Version Information Tool" I am getting following link https://commondatastorage.googleapis.com/chromium-browser-snapshots/index.html?prefix=Win_x64/638880/ it is installation for Chromium instead of Chrome Browser for Windows 10 64 bit

Any thoughts or may be you come across issues like that

Best regards

@ikeselman

Haywaii commented 5 years ago

Hi, @ikeselman

Good to see you solved your issue. The issue you are having right know, i think, is linked to the chrome driver packages and your version of chrome.

You need to make sure both of your packages (in your project) and chrome version are the same version/supported. packages are :

So let's say my chrome version is v0.76 then my packages must be 0.76.

I hope it helps.

ikeselman commented 5 years ago

Thank you @Haywaii Updated all as you suggested Now when run Test getting new errors

Severity Code Description Project File Line Suppression State Error Unable to copy file "C:\Users\ikeselman\Documents\Visual Studio 2017\Projects\EasyRepro1\EasyRepro-develop\packages\Selenium.WebDriver.ChromeDriver.76.0.3809.12600\build..\driver\win32\chromedriver.exe" to "C:\Users\ikeselman\Documents\Visual Studio 2017\Projects\EasyRepro1\EasyRepro-develop\Microsoft.Dynamics365.UIAutomation.Sample\bin\Debug\chromedriver.exe". The process cannot access the file 'C:\Users\ikeselman\Documents\Visual Studio 2017\Projects\EasyRepro1\EasyRepro-develop\Microsoft.Dynamics365.UIAutomation.Sample\bin\Debug\chromedriver.exe' because it is being used by another process. Microsoft.Dynamics365.UIAutomation.Sample

Severity Code Description Project File Line Suppression State Error Could not copy "C:\Users\ikeselman\Documents\Visual Studio 2017\Projects\EasyRepro1\EasyRepro-develop\packages\Selenium.WebDriver.ChromeDriver.76.0.3809.12600\build..\driver\win32\chromedriver.exe" to "C:\Users\ikeselman\Documents\Visual Studio 2017\Projects\EasyRepro1\EasyRepro-develop\Microsoft.Dynamics365.UIAutomation.Sample\bin\Debug\chromedriver.exe". Exceeded retry count of 10. Failed. The file is locked by: "chromedriver.exe (3456), chromedriver.exe (6700), chromedriver.exe (844)" Microsoft.Dynamics365.UIAutomation.Sample

ikeselman commented 5 years ago

Running Test CreateAccount and getting now

Microsoft.Dynamics365.UIAutomation.Sample.Web.CreateAccount.WEBTestCreateNewAccount threw exception:Login page failed

LoginDialog.cs line 150

Haywaii commented 5 years ago

From now you need to debug to see why the login doesn't work.

Good luck

ikeselman commented 5 years ago

Yes you right, by Debugging code I getting into few conclusions:

image

OR/AND

image