-
Notifications
You must be signed in to change notification settings - Fork 291
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
Any idea why login field loading but not password field when running on azure self hosted agent? #958
Comments
@shiyamtj I also faced the same issue, but it is reproduced really now. Issue that test switch to the password field too fast. Previously I implementation custom login with additional sleep after navigation to the password field. |
@Shakevg Yeah. Yes, it is reproducible always on CI. This behavior can be seen when after a test got fail. |
@shiyamtj Can try custom login implementation (but it is without MFA support)? using System;
using System.Linq;
using System.Security;
using System.Threading;
using Microsoft.Dynamics365.UIAutomation.Api.UCI;
using Microsoft.Dynamics365.UIAutomation.Browser;
using OpenQA.Selenium;
namespace Dynamics365WebTAF.Pages
{
public class LoginPages
{
private readonly By SubmitButtonLocator = By.XPath("//input[@type='submit']");
private readonly WebClient Client;
private readonly IWebDriver Driver;
public LoginPages(WebClient client)
{
Client = client;
Driver = Client.Browser.Driver;
}
public void Login(
Uri uri,
SecureString username,
SecureString password)
{
PerformLogin(uri, username, password);
if (!Client.Browser.Options.UCITestMode)
return;
InitializeModes(true);
}
private void PerformLogin(
Uri uri,
SecureString username,
SecureString password)
{
var num = Client.OnlineDomains == null || Client.OnlineDomains.Any(d => uri.Host.EndsWith(d)) ? 1 : 0;
Driver.Navigate().GoToUrl(uri);
if (num != 0)
{
if (Driver.IsVisible(By.Id("use_another_account_link")))
Driver.ClickWhenAvailable(By.Id("use_another_account_link"));
Driver.WaitUntilAvailable(By.XPath(Elements.Xpath[Reference.Login.UserId]),
$"The Office 365 sign in page did not return the expected result for UserName form and the user '{username.ToUnsecureString()}' could not be signed in.");
Driver.WaitUntilAvailable(By.XPath(Elements.Xpath[Reference.Login.UserId])).Click();
Thread.Sleep(TimeSpan.FromSeconds(2));
Driver.WaitUntilAvailable(By.XPath(Elements.Xpath[Reference.Login.UserId]))
.SendKeys(username.ToUnsecureString());
Thread.Sleep(TimeSpan.FromSeconds(2));
Driver.WaitUntilAvailable(SubmitButtonLocator).Click();
Thread.Sleep(TimeSpan.FromSeconds(2));
if (Driver.IsVisible(By.Id("aadTile")))
Driver.WaitUntilAvailable(By.Id("aadTile")).Click(true);
Driver.WaitUntilAvailable(By.XPath(Elements.Xpath[Reference.Login.LoginPassword]),
$"The Office 365 sign in page did not return the expected result for Password form and the user '{username.ToUnsecureString()}' could not be signed in.");
Driver.WaitUntilAvailable(By.XPath(Elements.Xpath[Reference.Login.LoginPassword]))
.SendKeys(password.ToUnsecureString());
Driver.WaitUntilAvailable(SubmitButtonLocator).Click();
Thread.Sleep(1000);
Driver.WaitUntilVisible(By.XPath(Elements.Xpath[Reference.Login.StaySignedIn]), new TimeSpan(0, 0, 5));
if (Driver.IsVisible(By.XPath(Elements.Xpath[Reference.Login.StaySignedIn])))
Driver.ClickWhenAvailable(By.XPath(Elements.Xpath[Reference.Login.StaySignedIn]));
WaitForCrmPageToLoad(Driver);
}
}
private void InitializeModes(bool onlineLoginPath = false)
{
var uri = Driver.Url;
var queryParams = "";
if (Client.Browser.Options.UCITestMode) queryParams += "&flags=testmode=true,easyreproautomation=true";
if (!string.IsNullOrEmpty(queryParams) && !uri.Contains(queryParams))
{
var testModeUri = uri + queryParams;
Driver.Navigate().GoToUrl(testModeUri);
Driver.WaitForPageToLoad();
if (!onlineLoginPath) Driver.WaitForTransaction();
}
}
/// <summary>
/// Wait for Dynamics 365 web app load
/// </summary>
/// <param name="driver">Web driver</param>
public static void WaitForCrmPageToLoad(IWebDriver driver)
{
var timeout = new TimeSpan?(Constants.DefaultTimeout);
Action<IWebElement> SuccessCallback(IWebDriver webDriver)
{
return _ =>
{
if (!webDriver.HasElement(By.XPath(Elements.Xpath[Reference.Login.CrmUCIMainPage])))
return;
webDriver.WaitForTransaction(new TimeSpan?());
};
}
var successCallback = SuccessCallback(driver);
var by = By.XPath(Elements.Xpath[Reference.Login.CrmMainPage]);
driver.WaitUntilVisible(by, timeout, successCallback);
}
}
} |
I have self-hosted agents, it works properly, no custom login is required. What is an azure self-hosted agent? Looks like the PC is too slow, you can use:
|
Isuue microsoft#958 -> Add Option TimeFactor If not use incognito mode, create a Temporal Chrome Profite in to avoid ask for login every time
Question
Any idea why login field loading but not password field when running on azure self hosted agent?
This behavior not showing when I execute automated tests on local machine, but showing this issue when executing on self hosted agents.
Am I missing any configuration on repro?
The text was updated successfully, but these errors were encountered: