question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Cannot login to Dynamics due issue in Login method

See original GitHub issue

Bug Report

Login method fails due trying to click to not existing controls, but do not check that is is exists before

EasyRepro Version

  • Microsoft Dynamics 365 Online Version 8.2 (8.2.x) (DB 8.2.x) online
  • Microsoft Dynamics 365 Online Version 9.0 (9.0.x) (DB 9.0.x) online
  • Microsoft Dynamics 365 Online Version 9.0.2 (9.0.2) (DB 9.0.2) online
  • [ + ] Microsoft Dynamics 365 Online Version 9.1 (9.1.x) (DB 9.1.x) online

UCI or Classic Web

  • [ + ] UCI (XrmApp)
  • Classic Web (XrmBrowser)

Online or On Premise

  • [ + ] Online
  • On Premise

Browser

  • [ + ] Chrome
  • Firefox
  • IE
  • Edge

Describe the bug
During login test trying to click to not existing controls, but do not check that is is exists before

driver.ClickWhenAvailable(By.Id("aadTile"));
driver.ClickWhenAvailable(By.Id("use_another_account_link"));

Stack Trace:

Test method Microsoft.Dynamics365.UIAutomation.Sample.UCI.OpenContactUCI.UCITestOpenContactRetrieveHeaderValues threw exception: 
System.InvalidOperationException: Unable to click element.
    at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.<>c__DisplayClass50_0.<WaitUntilClickable>b__0() in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Browser\Extensions\SeleniumExtensions.cs:line 500
   at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.WaitUntil(ISearchContext driver, Func`2 searchFunc, Nullable`1 timeout, Action`1 successCallback, Action failureCallback) in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Browser\Extensions\SeleniumExtensions.cs:line 558
   at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.WaitUntilClickable(ISearchContext driver, By by, Nullable`1 timeout, Action`1 successCallback, Action failureCallback) in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Browser\Extensions\SeleniumExtensions.cs:line 508
   at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.WaitUntilClickable(ISearchContext driver, By by, Nullable`1 timeout, Action`1 successCallback, String exceptionMessage) in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Browser\Extensions\SeleniumExtensions.cs:line 500
   at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.ClickWhenAvailable(ISearchContext driver, By by, Nullable`1 timeout, String errorMessage) in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Browser\Extensions\SeleniumExtensions.cs:line 38
   at Microsoft.Dynamics365.UIAutomation.Api.UCI.WebClient.Login(IWebDriver driver, Uri uri, SecureString username, SecureString password, SecureString mfaSecrectKey, Action`1 redirectAction) in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Api.UCI\WebClient.cs:line 127
   at Microsoft.Dynamics365.UIAutomation.Browser.DelegateBrowserCommand`6.ExecuteCommand(IWebDriver driver, Object[] params) in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Browser\DelegateBrowserCommand.cs:line 163
   at Microsoft.Dynamics365.UIAutomation.Browser.BrowserCommand`1.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) in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Browser\BrowserCommand.cs:line 136
   at Microsoft.Dynamics365.UIAutomation.Browser.BrowserCommand`1.Execute[T1,T2,T3,T4,T5](IWebDriver driver, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5) in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Browser\BrowserCommand.cs:line 66
   at Microsoft.Dynamics365.UIAutomation.Browser.BrowserPage.Execute[TResult,T1,T2,T3,T4,T5](BrowserCommandOptions options, Func`7 delegate, T1 p1, T2 p2, T3 p3, T4 p4, T5 p5) in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Browser\BrowserPage.cs:line 242
   at Microsoft.Dynamics365.UIAutomation.Api.UCI.WebClient.Login(Uri orgUri, SecureString username, SecureString password, SecureString mfaSecrectKey, Action`1 redirectAction) in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Api.UCI\WebClient.cs:line 116
   at Microsoft.Dynamics365.UIAutomation.Api.UCI.OnlineLogin.Login(Uri orgUrl, SecureString username, SecureString password, SecureString mfaSecrectKey) in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Api.UCI\Elements\OnlineLogin.cs:line 38
   at Microsoft.Dynamics365.UIAutomation.Sample.UCI.OpenContactUCI.UCITestOpenContactRetrieveHeaderValues() in C:\BCD\EasyRepro-develop.747\Microsoft.Dynamics365.UIAutomation.Sample\UCI\Read\OpenContact.cs:line 150

Code to reproduce
Run UCITestOpenContactRetrieveHeaderValues test

xrmApp.OnlineLogin.Login(_xrmUri, _username, _password);

Expected behavior
It should be verification that controls exists before click

if (driver.IsVisible(By.Id("aadTile")))
	driver.ClickWhenAvailable(By.Id("aadTile"));
if (driver.IsVisible(By.Id("use_another_account_link")))
	driver.ClickWhenAvailable(By.Id("use_another_account_link"
```));

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rsObjektkulturcommented, Feb 10, 2020

Can we get the fixes into the Nuget Package asap please?

My whole test suited is blocked by this failed login issue. And I can not simply roleback because the previous (working) version is no longer on Nuget available (only some very old versions, which have other breaking changes).

1reaction
Shakevgcommented, May 16, 2020

@TYLEROL, @AngelRodriguez8008 Login is performed now but after Login method is hang on EnterOneTimeCode(driver, mfaSecrectKey); command inside Login method. Looks like it should be something like:

private LoginResult Login(IWebDriver driver, Uri uri, SecureString username, SecureString password, SecureString mfaSecrectKey = null, Action<LoginRedirectEventArgs> redirectAction = null)
        {
            bool online = !(OnlineDomains != null && !OnlineDomains.Any(d => uri.Host.EndsWith(d)));
            driver.Navigate().GoToUrl(uri);
....
            if(mfaSecrectKey != null)
            {
                EnterOneTimeCode(driver, mfaSecrectKey);
            }
.....
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when signing in to Dynamics 365
You have signed in with a user ID that cannot log into Dynamics 365. Contact your administrator to make sure that you have...
Read more >
Login failed for user - Dynamics GP
This problem will occur if you don't have a domain user name and a domain password set up in the COM+ application in...
Read more >
Dynamics365 CRM - Unable to login to Dynamics CRM
To resolve the issue, I went to MMC, added certificated to my view, then in personal folder I have my certificates, right click...
Read more >
Unable to connect to Dynamics CE v.9.0 on-Premises
I have a problem with connecting my .net 4.6.2 console app to our on-Premises Dynamics CE v.9.0 installation. I have the following code...
Read more >
Troubleshooting Issues Connecting to your CRM ...
Troubleshooting Issues Connecting to your CRM Organization. · Username or password is incorrect · Discovery or Organization URL is incorrect · WS-Trust Deprecation....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found