public void Origin_CanBeSerialized()
        {
            var expectations = Expectations.GetCompositionElements();

            foreach (var e in expectations)
            {
                var element = CreateSerializableCompositionElement(e);

                var result = SerializationTestServices.RoundTrip(element);

                ElementAssert.AreEqual(e, result);
            }
        }
        public void Element_CanBeSerialized()
        {
            var expectations = Expectations.GetCompositionElementsWithNull();

            foreach (var e in expectations)
            {
                var exception = CreateComposablePartException(e);

                var result = SerializationTestServices.RoundTrip(exception);

                ElementAssert.AreEqual(exception.Element, result.Element);
            }
        }
        public void FromICompositionElement_ValueAsElementArgument_ShouldSetOriginProperty()
        {
            var expectations = Expectations.GetCompositionElements();

            foreach (var e in expectations)
            {
                var element = ElementFactory.Create(e);

                var result = SerializableCompositionElement.FromICompositionElement(element);

                ElementAssert.AreEqual(e, result.Origin);
            }
        }
Exemplo n.º 4
0
        public void TestCase()
        {
            try
            {
                this.driver = new TWebDriver();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Initializing Driver.....");
                if (ex.ToString().Contains("InternetExplorer"))
                {
                    InternetExplorerOptions options = new InternetExplorerOptions();
                    //options.AddAdditionalCapability("version", "11");
                    options.IgnoreZoomLevel = true;
                    this.driver             = new InternetExplorerDriver(sInternetExplorerPath, options);
                }
                if (ex.ToString().Contains("Chrome"))
                {
                    ChromeOptions options = new ChromeOptions();
                    options.AddArgument("test-type");
                    options.AddArguments("start-maximized");
                    this.driver = new ChromeDriver(sChromePath, options);
                }
            }
            finally
            {
                driver.Manage().Window.Maximize();
            }
            ICapabilities capabilities = ((RemoteWebDriver)driver).Capabilities;

            SetupClass.BrowserName = capabilities.BrowserName;
            TimeSpan timespan = TimeSpan.FromSeconds(60);
            int      timesp   = 50;

            foreach (DataTable dt in SetupClass.DS.Tables)
            {
                if (dt.TableName.Contains("Sheet1"))
                {
                    continue;
                }
                int rowCount  = dt.Rows.Count;
                int collCount = dt.Columns.Count;

                for (int i = 0; i < rowCount; i++)
                {
                    Boolean  TestCase  = false;
                    Boolean  Developer = false;
                    DateTime StartTestCase;
                    DateTime EndTestCase;
                    try
                    {
                        StartTestCase = DateTime.Now;
                        string childURL = dt.Rows[i][0].ToString().Trim();
                        if (dt.Rows[i][1].ToString().Trim() != "")
                        {
                            TestCaseId = dt.Rows[i][1].ToString();

                            if (childURL != "")
                            {
                                WebDriverWait wait     = new WebDriverWait(driver, timespan);
                                string        FinalUrl = SetupClass.masterPath + childURL;
                                Console.WriteLine(FinalUrl);
                                driver.Navigate().GoToUrl(FinalUrl);
                                Thread.Sleep(timesp);
                            }
                            string ElementParameter;
                            string ElementAction;
                            string ElementAssert;

                            ElementParameter = dt.Rows[i].ItemArray[3].ToString().Trim();

                            Thread.Sleep(timesp);
                            ColumnNo = 3;
                            if (ElementParameter != "")
                            {
                                IWebElement WebElement = null;

                                //Get the Web element
                                Thread.Sleep(timesp);

                                //Created by David to fetch the element
                                WebElement = ReturnWebElement(ElementParameter);

                                Thread.Sleep(timesp);

                                //Perform Action on web element
                                ElementAction = dt.Rows[i].ItemArray[4].ToString().Trim();

                                Thread.Sleep(timesp);

                                //Created by David to prform the action in the element
                                Developer = PerformActionOnElement(WebElement, ElementAction);
                                SetupClass.Outputds.Tables[dt.TableName].Rows[i][collCount] = (Developer ? "Pass" : "Fail");

                                Thread.Sleep(timesp);
                            }

                            ElementAssert = dt.Rows[i].ItemArray[5].ToString().Trim();

                            if (ElementAssert.Contains("Body:")) //Verify the action yields the expected result
                            {
                                Thread.Sleep(timesp);

                                //Check the assert Value
                                TestCase = CheckAssertValue(ElementAssert);
                                SetupClass.Outputds.Tables[dt.TableName].Rows[i][collCount + 1] = (TestCase ? "Pass" : "Fail");
                            }

                            EndTestCase = DateTime.Now;
                            String LoadTimeInSec = "Time Consumed - " + EndTestCase.Subtract(StartTestCase).TotalSeconds.ToString("#.##") + "Sec";
                            if (SetupClass.BrowserName == "internet explorer")
                            {
                                SetupClass.Outputds.Tables[dt.TableName].Rows[i][collCount + 2] = LoadTimeInSec;
                            }
                            else if (SetupClass.BrowserName == "firefox")
                            {
                                SetupClass.Outputds.Tables[dt.TableName].Rows[i][collCount + 3] = LoadTimeInSec;
                            }
                            else if (SetupClass.BrowserName == "chrome")
                            {
                                SetupClass.Outputds.Tables[dt.TableName].Rows[i][collCount + 4] = LoadTimeInSec;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            Console.WriteLine(TestCaseId + " - " + dt.Rows[i].ItemArray[ColumnNo].ToString().Trim());

                            CurrentBrowser = SetupClass.BrowserName;

                            Screenshot ss     = ((ITakesScreenshot)driver).GetScreenshot();
                            DateTime   today  = DateTime.Today;
                            string     sToday = today.ToString("MM-dd-yyyy");

                            ImageURL  = TestCaseId + "_" + sToday + "_" + SetupClass.BrowserName + ".jpg";
                            ErrorText = ex.Message;

                            if (SetupClass.BrowserName == "internet explorer")
                            {
                                //ErrorValueIE = 1;
                                SetupClass.Outputds.Tables[dt.TableName].Rows[i][collCount + 2] = ErrorText + " - " + ImageURL;
                            }
                            else if (SetupClass.BrowserName == "firefox")
                            {
                                //ErrorValueMozilla = 1;
                                SetupClass.Outputds.Tables[dt.TableName].Rows[i][collCount + 3] = ErrorText + " - " + ImageURL;
                            }
                            else if (SetupClass.BrowserName == "chrome")
                            {
                                //ErrorValueChrome = 1;
                                SetupClass.Outputds.Tables[dt.TableName].Rows[i][collCount + 4] = ErrorText + " - " + ImageURL;
                            }

                            SetupClass.Outputds.Tables[dt.TableName].Rows[i][collCount + 1] = "Fail";

                            ss.SaveAsFile(SetupClass.sScreenShotPath + TestCaseId + "_" + sToday + "_" + SetupClass.BrowserName + ".jpg", System.Drawing.Imaging.ImageFormat.Gif);
                        }
                        catch (Exception Ex)
                        {
                            Console.WriteLine("Something went wrong with the diver capabilities...\r\n" + Ex);
                        }
                    }
                }
            }
            driver.Quit();
        }