gpt4 book ai didi

automated-tests - 如何在内部部署的 Dynamics 365 中使用 EasyRepro 自动登录

转载 作者:行者123 更新时间:2023-12-05 00:44:27 26 4
gpt4 key购买 nike

我正在尝试在 Dynamics 365 On-Premise 中使用 EasyRepro 进行自动化 UI 测试。我设法通过一个问题进行了测试,我无法自动登录到我的 Dynamics 365 组织。以下是我使用的代码:

var client = new WebClient(TestSettings.Options);
using (var xrmApp = new XrmApp(client))
{
xrmApp.OnlineLogin.Login(_xrmUri, _username, _password);
xrmApp.Navigation.OpenSubArea("My Work", "Companies");
xrmApp.CommandBar.ClickCommand("New");
xrmApp.Entity.SetValue("name", TestSettings.GetRandomString(5,15));
xrmApp.Entity.Save();
}

当我运行它时,新打开的chrome页面仍然会要求我输入我的凭据,在我输入我的凭据(CRM用户名/密码)后,脚本将顺利运行。

因为,我计划将其用作我们自动化测试的一部分。 EasyRepro 有没有办法自动登录?

最佳答案

github issue谈本地CRM实例自动登录脚本的登录部分。

This is how I got around Windows Authentication Login (Could not use the ADFS Login on our On-Premise CRM Install). Just defined the Login elements:


using (var xrmBrowser = new Browser(TestSettings.Options))
{
DateTime dt = DateTime.Now;
String xpath = "//*[@id='search']";
// String logoffcrm = "#navBarUserInfoTextId > span.navTabButtonUserInfoText.navTabButtonUserInfoCompany";
Actions keyAction = new Actions(xrmBrowser.Driver);
xrmBrowser.GoToXrmUri(_xrmUri);
xrmBrowser.Driver.FindElement(By.Id("ContentPlaceHolder1_UsernameTextBox")).SendKeys(_username);
xrmBrowser.ThinkTime(1000);
xrmBrowser.Driver.FindElement(By.Id("ContentPlaceHolder1_PasswordTextBox")).SendKeys(_password);
xrmBrowser.ThinkTime(1000);

try
{
if (_browser == "Chrome")
{
xrmBrowser.Driver.FindElement(By.Id("ContentPlaceHolder1_SubmitButton")).Click();
}

if (_browser == "IE")
{
xrmBrowser.Driver.FindElement(By.Id("ContentPlaceHolder1_SubmitButton")).Submit();
}

xrmBrowser.Driver.WaitUntilVisible(By.XPath(xpath)
, new TimeSpan(0, 0, 60),
e => { xrmBrowser.Driver.WaitForPageToLoad(); },
f => { throw new Exception("Login failed."); });
}
catch (StaleElementReferenceException)
{
//old element has gone

//Console.WriteLine(g);
xrmBrowser.Driver.WaitUntilVisible(By.XPath(xpath)
, new TimeSpan(0, 0, 60),
e => { xrmBrowser.Driver.WaitForPageToLoad(); },
f => { throw new Exception("Login failed."); });
}

我希望你是,但请确保你正在使用 EasyRepro Release Branch - OnPremise repo 。

关于automated-tests - 如何在内部部署的 Dynamics 365 中使用 EasyRepro 自动登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60056050/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com