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

Error with ADFSLoginAction function #37

Closed
troyyer opened this issue Oct 9, 2017 · 2 comments
Closed

Error with ADFSLoginAction function #37

troyyer opened this issue Oct 9, 2017 · 2 comments

Comments

@troyyer
Copy link

troyyer commented Oct 9, 2017

I am getting the a stale element reference when I try to use the ADFSLoginAction with the code that is currently present (it is commented out in the code). Everything seems to work (the initial login page loads, code enters the username, waits for page to reload to redirected login page, enters the password and then clicks submit) but it gets a stale element reference error

public void ADFSLoginAction(LoginRedirectEventArgs args)
{
var d = args.Driver;
d.FindElement(By.Id("passwordInput")).SendKeys(args.Password.ToUnsecureString());
d.ClickWhenAvailable(By.Id("submitButton"), new TimeSpan(0, 0, 2));
d.WaitForPageToLoad();
}

I tried changing how I submit with a different line of code but it also failed with the same error
d.FindElement(By.Id("passwordInput")).SendKeys(Keys.Enter);

it ended up working if I put in the submit()

d.FindElement(By.Id("passwordInput")).Submit();

Test Name: TestOpenActiveContact
Test FullName: Microsoft.Dynamics365.UIAutomation.Sample.OpenContact.TestOpenActiveContact
Test Source: C:\Code\EasyRepro-master\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Sample\OpenContact.cs : line 21
Test Outcome: Failed
Test Duration: 0:00:55.4222568

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_ElementValueChanged(Object sender, WebElementEventArgs e) in C:\Code\EasyRepro-master\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Browser\InteractiveBrowser.cs:line 490 at OpenQA.Selenium.Support.Events.EventFiringWebDriver.OnElementValueChanged(WebElementEventArgs e) at OpenQA.Selenium.Support.Events.EventFiringWebDriver.EventFiringWebElement.SendKeys(String text) at Microsoft.Dynamics365.UIAutomation.Sample.OpenContact.ADFSLoginAction(LoginRedirectEventArgs args) in C:\Code\EasyRepro-master\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Sample\OpenContact.cs:line 58 at Microsoft.Dynamics365.UIAutomation.Api.LoginPage.Login(IWebDriver driver, Uri uri, SecureString username, SecureString password, Action1 redirectAction) in C:\Code\EasyRepro-master\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Api\Pages\LoginPage.cs:line 126
at Microsoft.Dynamics365.UIAutomation.Browser.DelegateBrowserCommand5.ExecuteCommand(IWebDriver driver, Object[] params) in C:\Code\EasyRepro-master\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:\Code\EasyRepro-master\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:\Code\EasyRepro-master\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:\Code\EasyRepro-master\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:\Code\EasyRepro-master\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Api\Pages\LoginPage.cs:line 84
at Microsoft.Dynamics365.UIAutomation.Sample.OpenContact.TestOpenActiveContact() in C:\Code\EasyRepro-master\EasyRepro-master\Microsoft.Dynamics365.UIAutomation.Sample\OpenContact.cs:line 25
Result Message:
Test method Microsoft.Dynamics365.UIAutomation.Sample.OpenContact.TestOpenActiveContact threw exception:
OpenQA.Selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
(Session info: chrome=61.0.3163.100)
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 10.0.15063 x86_64)

@dtu11
Copy link
Member

dtu11 commented Oct 10, 2017

Yea we see that quite a bit in our API's. Our wait extension methods are setup to ignore those exceptions types but it looks like we're not handling that in the Click extension methods. I'll add that to our tasks.

Thanks for the feedback.

@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
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

2 participants