如何在 Dynamics 365 on-premises 中使用 EasyRepro 自动登录 [英] How to automatically login using EasyRepro in Dynamics 365 on-premise

查看:12
本文介绍了如何在 Dynamics 365 on-premises 中使用 EasyRepro 自动登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to do Automated UI Testing using EasyRepro in Dynamics 365 On-Premise. I managed to the testing with one issue, I can't automatically login to my Dynamics 365 Organization. Below are the code that I used:

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 用户名/密码)后,脚本就会顺利运行.

When I run it, the newly open chrome page will still ask me to put my credential, after I enter my credential (the CRM username/password), the script will run smoothly.

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

Since, I plan to use this as part of our automated testing. Is there any way for the EasyRepro to automatically login?

推荐答案

这个github问题 讨论本地 CRM 实例自动登录脚本的登录部分.

This github issue talks about the login part for on-premise CRM instance automatic login scripting.

这就是我绕过 Windows 身份验证登录的方法(无法在我们的本地 CRM 安装上使用 ADFS 登录).刚刚定义了登录元素:

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 回购.

I hope you are, but make sure you are using EasyRepro Release Branch - OnPremise repo.

这篇关于如何在 Dynamics 365 on-premises 中使用 EasyRepro 自动登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆