Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XrmBrowser.LoginPage.Login does not handle "Stay signed in?" menu #48

Closed
trentet opened this issue Nov 21, 2017 · 7 comments
Closed

XrmBrowser.LoginPage.Login does not handle "Stay signed in?" menu #48

trentet opened this issue Nov 21, 2017 · 7 comments

Comments

@trentet
Copy link

trentet commented Nov 21, 2017

Sometimes when signing in to crm.dynamics.com, after entering the username and password, the page will ask if you want to stay signed in, offering a yes or no button. I am using the XrmBrowser.LoginPage.Login(Uri url, SecureString username, SecureString password) overload.

Is there a way for me to handle this with what's already included in the project?

@kaceyarnold
Copy link

kaceyarnold commented Nov 28, 2017

ADFSLoginTest.txt
I am also running into this problem except it isn't occasional CRM asks every-time I login and the login test fails with "
Test Name: TestADFSLogin
Test FullName: Microsoft.Dynamics365.UIAutomation.Sample.ADFSLogin.TestADFSLogin
Test Source: C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Sample\ADFSLogin.cs : line 23
Test Outcome: Failed
Test Duration: 0:00:14.5637165

Result StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary2 parameters) at OpenQA.Selenium.Remote.RemoteWebElement.get_Location() at Microsoft.Dynamics365.UIAutomation.Browser.InteractiveBrowser.EventDriver_ElementClicked(Object sender, WebElementEventArgs e) in C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Browser\InteractiveBrowser.cs:line 458 at OpenQA.Selenium.Support.Events.EventFiringWebDriver.OnElementClicked(WebElementEventArgs e) at OpenQA.Selenium.Support.Events.EventFiringWebDriver.EventFiringWebElement.Click() at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.<>c__DisplayClass2_0.<ClickWhenAvailable>b__0(IWebDriver d) in C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Browser\Extensions\SeleniumExtensions.cs:line 47 at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.WaitUntilClickable(IWebDriver driver, By by, TimeSpan timeout, Action1 successCallback, Action1 failureCallback) in C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Browser\Extensions\SeleniumExtensions.cs:line 540 at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.ClickWhenAvailable(IWebDriver driver, By by, TimeSpan timeout) in C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Browser\Extensions\SeleniumExtensions.cs:line 44 at Microsoft.Dynamics365.UIAutomation.Sample.ADFSLogin.ADFSLoginAction(LoginRedirectEventArgs args) in C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Sample\ADFSLogin.cs:line 35 at Microsoft.Dynamics365.UIAutomation.Api.LoginPage.Login(IWebDriver driver, Uri uri, SecureString username, SecureString password, Action1 redirectAction) in C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Api\Pages\LoginPage.cs:line 126
at Microsoft.Dynamics365.UIAutomation.Browser.DelegateBrowserCommand5.ExecuteCommand(IWebDriver driver, Object[] params) in C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Browser\DelegateBrowserCommand.cs:line 134 at Microsoft.Dynamics365.UIAutomation.Browser.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) in C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Browser\BrowserCommand.cs:line 167
at Microsoft.Dynamics365.UIAutomation.Browser.BrowserCommand1.Execute[T1,T2,T3,T4](IWebDriver driver, T1 p1, T2 p2, T3 p3, T4 p4) in C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Browser\BrowserCommand.cs:line 60 at Microsoft.Dynamics365.UIAutomation.Browser.BrowserPage.Execute[TResult,T1,T2,T3,T4](String commandName, Func6 delegate, T1 p1, T2 p2, T3 p3, T4 p4) in C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Browser\BrowserPage.cs:line 102
at Microsoft.Dynamics365.UIAutomation.Api.LoginPage.Login(Uri uri, SecureString username, SecureString password, Action`1 redirectAction) in C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Api\Pages\LoginPage.cs:line 84
at Microsoft.Dynamics365.UIAutomation.Sample.ADFSLogin.TestADFSLogin() in C:\Users\kcarn\Documents\Test Studio Projects\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Sample\ADFSLogin.cs:line 26
Result Message:
Test method Microsoft.Dynamics365.UIAutomation.Sample.ADFSLogin.TestADFSLogin threw exception:
OpenQA.Selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=62.0.3202.94)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 10.0.15063 x86_64)

"
Even though the browser window showed that it logged in and is at the "would you like to stay logged in" prompt.
Also of note,
If I set the browser to Firefox the login test indicates that it passes but if I step through the code in the debugger it fails at the "do you want to stay logged in?" screen. My guess is that the failure is masked for a number of people due to the way that EasyRepro fails and the fact that it does not error on stale or not present elements. I have still not figured out exactly what function is causing the failure,
This line, in SeleniumExtensions.cs, is the one that starts the end

        if (success.HasValue && success.Value && successCallback != null)
            successCallback(driver);

This sends us to line 114 in Browser commands.cs

Using Windows 10 Pro Build 15063

Microsoft Visual Studio Enterprise 2017 (2)
Version 15.3.5
VisualStudio.15.Release/15.3.5+26730.16
Microsoft .NET Framework
Version 4.7.02046
Installed Version: Enterprise
Visual C# 2017 00369-60000-00001-AA951
Microsoft Visual C# 2017

USING FireFox;
I put a break-point at the thread sleep after the click event should have been executed in the browser, according to the code,
IWebDriver Cdriver = args.Driver;
Cdriver.FindElement(By.Id("passwordInput")).SendKeys(args.Password.ToUnsecureString());
Cdriver.ClickWhenAvailable(By.Id("submitButton"), new TimeSpan(0, 1, 6));
Thread.Sleep(2500);
And luckily the submit button was not clicked. If I clicked Submit and Clicked yes to stay logged in the code executes "correctly" in Firefox. In Chrome it still errors out, so the click bug in firefox sometimes get's around the failure to handle login.
+++++++++++++++++++++++++++++++++++++++++++++++
The code below works.
IWebDriver Cdriver = args.Driver;
Cdriver.FindElement(By.Id("passwordInput")).SendKeys(args.Password.ToUnsecureString());
//Cdriver.ClickWhenAvailable(By.Id("submitButton"), new TimeSpan(0, 1, 6));
Cdriver.FindElement(By.Id("submitButton")).Submit();
Thread.Sleep(2500);
Cdriver.FindElement(By.Id("idSIButton9")).Submit();
Cdriver.WaitForPageToLoad();


I think the issue is in how .Click works.
If you change the Submit to .Click it fails. So this may be a driver issue. But the work around may be to use Submit instead of Click.

@trentet
Copy link
Author

trentet commented Nov 28, 2017

^This. Right now, if I manually interfere and click the "Yes" or "No" button on that page, it will continue for that test fine; however, considering the whole point of automated testing is so that the user doesn't have to interact manually, I would place an update for this scenario to be of high importance.

@dtu11
Copy link
Member

dtu11 commented Dec 4, 2017

This issue is fixed in the latest release. Please test with the latest build and let us know if you run into any issues.

Thanks

@dtu11 dtu11 closed this as completed Dec 4, 2017
@trentet
Copy link
Author

trentet commented Dec 8, 2017

Same problem.

System.Exception occurred
HResult=0x80131500
Message=Login page failed.
Source=Microsoft.Dynamics365.UIAutomation.Api
StackTrace:
at Microsoft.Dynamics365.UIAutomation.Api.LoginPage.<>c.b__12_2(IWebDriver f) in C:\Users\Trent\Source\Repos\JT_EasyRepro\Microsoft.Dynamics365.UIAutomation.Api\Pages\LoginPage.cs:line 148
at Microsoft.Dynamics365.UIAutomation.Browser.SeleniumExtensions.WaitUntilVisible(IWebDriver driver, By by, TimeSpan timeout, Action1 successCallback, Action1 failureCallback) in C:\Users\Trent\Source\Repos\JT_EasyRepro\Microsoft.Dynamics365.UIAutomation.Browser\Extensions\SeleniumExtensions.cs:line 497
at Microsoft.Dynamics365.UIAutomation.Api.LoginPage.Login(IWebDriver driver, Uri uri, SecureString username, SecureString password, Action1 redirectAction) in C:\Users\Trent\Source\Repos\JT_EasyRepro\Microsoft.Dynamics365.UIAutomation.Api\Pages\LoginPage.cs:line 145 at Microsoft.Dynamics365.UIAutomation.Browser.DelegateBrowserCommand5.ExecuteCommand(IWebDriver driver, Object[] params) in C:\Users\Trent\Source\Repos\JT_EasyRepro\Microsoft.Dynamics365.UIAutomation.Browser\DelegateBrowserCommand.cs:line 134
at Microsoft.Dynamics365.UIAutomation.Browser.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) in C:\Users\Trent\Source\Repos\JT_EasyRepro\Microsoft.Dynamics365.UIAutomation.Browser\BrowserCommand.cs:line 167 at Microsoft.Dynamics365.UIAutomation.Browser.BrowserCommand1.Execute[T1,T2,T3,T4](IWebDriver driver, T1 p1, T2 p2, T3 p3, T4 p4) in C:\Users\Trent\Source\Repos\JT_EasyRepro\Microsoft.Dynamics365.UIAutomation.Browser\BrowserCommand.cs:line 60
at Microsoft.Dynamics365.UIAutomation.Browser.BrowserPage.Execute[TResult,T1,T2,T3,T4](String commandName, Func`6 delegate, T1 p1, T2 p2, T3 p3, T4 p4) in C:\Users\Trent\Source\Repos\JT_EasyRepro\Microsoft.Dynamics365.UIAutomation.Browser\BrowserPage.cs:line 102
at Microsoft.Dynamics365.UIAutomation.Api.LoginPage.Login(Uri uri, SecureString username, SecureString password) in C:\Users\Trent\Source\Repos\JT_EasyRepro\Microsoft.Dynamics365.UIAutomation.Api\Pages\LoginPage.cs:line 71
at Microsoft.Dynamics365.UIAutomation.Testing.Tests.JT.BSCR.CreateAccountTests.TestCreateNewAccountDS() in C:\Users\Trent\source\repos\JT_EasyRepro\Microsoft.Dynamics365.UIAutomation.Testing\Tests\JT\BSCR\CreateAccount.cs:line 25
at Microsoft.Dynamics365.UIAutomation.Testing.Controller.Run() in C:\Users\Trent\source\repos\JT_EasyRepro\Microsoft.Dynamics365.UIAutomation.Testing\Controller.cs:line 18
at Microsoft.Dynamics365.UIAutomation.Testing.Program.Main(String[] args) in C:\Users\Trent\source\repos\JT_EasyRepro\Microsoft.Dynamics365.UIAutomation.Testing\Program.cs:line 9

@dtu11
Copy link
Member

dtu11 commented Dec 8, 2017

This is a different error. Looks like you are logging in fine but it's timing out when waiting for the CRM Application.

                driver.WaitUntilVisible(By.XPath(Elements.Xpath[Reference.Login.CrmMainPage])
                    , new TimeSpan(0, 0, 60),
                    e => { e.WaitForPageToLoad(); },
                    f => { throw new Exception("Login page failed."); });

We've seen the login take longer then 60 seconds to load unfortunately.

@trentet
Copy link
Author

trentet commented Dec 11, 2017

It's logging in correctly but it does not handle the "Stay Logged In?" menu, which is why the main CRM page does not load.

dtu11 added a commit that referenced this issue Dec 21, 2017
Issue #49
Issue #50
Issue #58
Issue #57
Issue #55
Issue #48
Issue #46
Issue #40
dtu11 added a commit that referenced this issue Dec 21, 2017
Issue #49
Issue #50
Issue #58
Issue #57
Issue #55
Issue #48
Issue #46
Issue #40
dtu11 added a commit that referenced this issue Dec 21, 2017
Issue #49
Issue #50
Issue #58
Issue #57
Issue #55
Issue #48
Issue #46
Issue #40
@dtu11 dtu11 mentioned this issue Dec 21, 2017
dtu11 added a commit that referenced this issue Dec 21, 2017
Issue #49
Issue #50
Issue #58
Issue #57
Issue #55
Issue #48
Issue #46
Issue #40
@deshazer722
Copy link

I am having this issue with this line of code in the login page. EasyRepro logs me in and I get to my dynamics dashboard.

image
I comment it out and wait it works but for some reason I am not sure why this fails.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants