示例#1
0
        public static void PopulateInCollection(string fileName, string SheetName)
        {
            ExcelLib.ClearData();
            DataTable table = ExcelToDataTable(fileName, SheetName);

            //Iterate through the rows and columns of the Table
            for (int row = 1; row <= table.Rows.Count; row++)
            {
                for (int col = 0; col < table.Columns.Count; col++)
                {
                    Datacollection dtTable = new Datacollection()
                    {
                        rowNumber = row,
                        colName   = table.Columns[col].ColumnName,
                        colValue  = table.Rows[row - 1][col].ToString()
                    };


                    //Add all the details for each row
                    dataCol.Add(dtTable);
                }
            }
        }
示例#2
0
        internal void LoginSteps()
        {
            // Populating the data from Excel
            ExcelLib.PopulateInCollection(InventoryTest.ExcelPath, "LoginPage");
            //Luanch the URL
            CommonMethods.driver.Navigate().GoToUrl(ExcelLib.ReadData(2, "URL"));
            Thread.Sleep(1000);
            Email.SendKeys(ExcelLib.ReadData(2, "Email"));
            Thread.Sleep(1000);
            Password.SendKeys(ExcelLib.ReadData(2, "Password"));
            Thread.Sleep(1000);
            LogOnBtn.Click();
            Thread.Sleep(1000);
            String Expectedresult = CommonMethods.driver.FindElement(By.XPath(".//*[@id='StickyBar']/div/div[1]/div")).Text;

            try
            {
                //Verify Login successful/not

                if (Expectedresult == "QA Applicant (Technical Exercise)")

                {
                    SaveScreenShotClass.SaveScreenshot(CommonMethods.driver, "Login Success");
                    Thread.Sleep(1000);
                }

                else
                {
                    SaveScreenShotClass.SaveScreenshot(CommonMethods.driver, "Login Fail");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Homepage not launched,Test failed" + e.Message);
            }
        }