Example #1
0
        public void TestTakeScreenshot()
        {
            using (var xrmBrowser = new XrmBrowser(TestSettings.Options))
            {
                xrmBrowser.LoginPage.Login(_xrmUri, _username, _password);
                xrmBrowser.GuidedHelp.CloseGuidedHelp();

                ScreenshotImageFormat fileFormat = ScreenshotImageFormat.Tiff;  // Image Format -> Png, Jpeg, Gif, Bmp and Tiff.

                xrmBrowser.TakeWindowScreenShot("D:\\Screenshot" + "." + fileFormat, fileFormat);

                xrmBrowser.ThinkTime(500);
                xrmBrowser.Navigation.OpenSubArea("Sales", "Accounts");

                xrmBrowser.ThinkTime(2000);
                xrmBrowser.Grid.SwitchView("Active Accounts");

                xrmBrowser.ThinkTime(1000);
                xrmBrowser.CommandBar.ClickCommand("New");

                xrmBrowser.ThinkTime(4000);
                xrmBrowser.Entity.SetValue("name", "Test API Account");
                xrmBrowser.Entity.SetValue("telephone1", "555-555-5555");
                xrmBrowser.Entity.SetValue("websiteurl", "https://easyrepro.crm.dynamics.com");

                xrmBrowser.CommandBar.ClickCommand("Save & Close");
                xrmBrowser.ThinkTime(2000);
            }
        }
Example #2
0
        public void RunSmokeTest()
        {
            using (var xrmBrowser = new XrmBrowser(_options))
            {
                try
                {
                    xrmBrowser.LoginPage.Login(_xrmUri, _username, _password);
                    xrmBrowser.GuidedHelp.CloseGuidedHelp();

                    xrmBrowser.ThinkTime(500);
                    xrmBrowser.Navigation.OpenSubArea("Sales", "Contacts");

                    xrmBrowser.ThinkTime(2000);
                    xrmBrowser.Grid.SwitchView("Active Contacts");

                    xrmBrowser.ThinkTime(1000);
                    xrmBrowser.CommandBar.ClickCommand("New");

                    xrmBrowser.ThinkTime(5000);

                    string firstname = "Wael";
                    string lastname  = "Test";
                    string tel       = new Random().Next(200000000, 300000000).ToString();

                    var fields = new List <Field>
                    {
                        new Field()
                        {
                            Id = "firstname", Value = firstname
                        },
                        new Field()
                        {
                            Id = "lastname", Value = lastname
                        }
                    };
                    xrmBrowser.Entity.SetValue(new CompositeControl()
                    {
                        Id = "fullname", Fields = fields
                    });
                    xrmBrowser.Entity.SetValue("emailaddress1", "*****@*****.**");
                    xrmBrowser.Entity.SetValue("mobilephone", tel);
                    xrmBrowser.Entity.SetValue("birthdate", DateTime.Parse("11/1/1980"));
                    xrmBrowser.Entity.SetValue(new OptionSet {
                        Name = "preferredcontactmethodcode", Value = "Email"
                    });

                    xrmBrowser.CommandBar.ClickCommand("Save");
                    xrmBrowser.ThinkTime(5000);
                }
                finally
                {
                    string screenShot = string.Format("{0}\\SmokeTest_Final.jpeg", TestContext.TestResultsDirectory);
                    xrmBrowser.TakeWindowScreenShot(screenShot, ScreenshotImageFormat.Jpeg);
                    TestContext.AddResultFile(screenShot);
                }
            }
        }