Browser.cs
using System; using System.Collections.Generic; using System.Diagnostics; using System.Drawing.Imaging; using System.Linq; using System.Text; using OpenQA.Selenium; using OpenQA.Selenium.IE; using OpenQA.Selenium.Support; using OpenQA.Selenium.Support.UI; using OpenQA.Selenium.Support.PageObjects; namespace TestFramework { public static class Browser { private static IWebDriver webDriver = new InternetExplorerDriver(@"D:\DEVL\C#\Solutions\TestFramework\TestFramework\_Objects\drivers"); // have the driver wait for a period of time public static WebDriverWait Wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(30)); public static string Title { get { return webDriver.Title; } } static Browser() { Debug.WriteLine("Browser Class: Constructor Called........................"); webDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30)); } public static void GoTo(string url) { webDriver.Url = url; } public static void Screencap() { ITakesScreenshot ssdriver = webDriver as ITakesScreenshot; Screenshot screenshot = ssdriver.GetScreenshot(); screenshot.SaveAsFile(@"D:\Temp\ScreenCap.png", ImageFormat.Png); // Screenshot ss = webDriver.GetScreenshot(); // ITakesScreenshot ssdriver = driver as ITakesScreenshot; //21 Screenshot screenshot = ssdriver.GetScreenshot(); //22 screenshot.SaveAsFile(saveLocation, ImageFormat.Png); } public static void Close() { webDriver.Close(); } public static void Quit() { webDriver.Quit(); } public static ISearchContext Driver { get { return webDriver; } } public static void Tests() { // } } }
Pages.cs
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using OpenQA.Selenium; using OpenQA.Selenium.Support; using OpenQA.Selenium.Support.PageObjects; namespace TestFramework { public static class Pages { public static PageSubmitActions PageSubmitActions { get { var qwSubmitPage = new PageSubmitActions(); PageFactory.InitElements(Browser.Driver, qwSubmitPage); return qwSubmitPage; } } public static QwWipPage QwWipPage { get { var qwWipPage = new QwWipPage(); PageFactory.InitElements(Browser.Driver, qwWipPage); return qwWipPage; } } /* public static HomePage HomePage { get { var homePage = new HomePage(); PageFactory.InitElements(Browser.Driver, homePage); return homePage; } } public static QwWipPage QwWipPage { get { var qwWipPage = new QwWipPage(); PageFactory.InitElements(Browser.Driver, qwWipPage); return qwWipPage; } } */ } }
GlobalData.cs
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Text; namespace TestFramework { public static class GlobalData { public static string DataFileNameFormData = @"D:\DEVL\C#\Solutions\TestFramework\TestFramework\_Objects\XML\FormData.xml"; public static string DataFileNameJobData = @"D:\DEVL\C#\Solutions\TestFramework\TestFramework\_Objects\XML\JobDataXLb1.xml"; public static string logPath = @"D:\Temp\Logs\logfile.txt"; #region // LOGFILES public static string LogfileMain = @"D:\TEMP\logfile.txt"; public static string LogfileBios = @"D:\Temp\logfileBios.txt"; public static int ErrCountBiosIni = 0; public static string LogfileRegCfg = @"D:\TEMP\logfileRegCfg.txt"; public static int ErrCountRegCfg = 0; public static string LogfileProjectSi = @"D:\TEMP\logfileProjSi.txt"; public static int ErrCountProjectSi = 0; public static string LogfileAcctCfg = @"D:\TEMP\logfileAcctCfg.txt"; public static int ErrCountAcctCfg = 0; #endregion public static string serverName = @"ftp://ausps1cfidev04"; public static string serverPath = @"ftp://ausps1cfidev04/SYS3/DELLSFTW/450500/4505zu/"; public static string localPath = @"D:\Temp\450500\Runs\450500\4505zu\"; //private static string fileName = "testfile.txt"; //private static string ftpSpec = serverName + serverPath + fileName; //public static string logonName = @"AMERICAS\servicequickimage"; //public static string logonPass = "image123"; public static string logonName = @"AMERICAS\processpetunc"; public static string logonPass = "DELL@12345"; //public static string logonName = @"silo1048"; //public static string logonPass = "lortnoc_2012L"; ////private static string fileNameUploadSrc = @"D:\Temp\testfile.txt"; ////private static string fileNameUploadSrc = @"D:\PROJECTS\ISOs\images\ImageModelv1.01.xml"; //private static string fileNameUploadSrc = @"D:\PROJECTS\ISOs\images\mdt.iso"; //private static string fileNameDownloadDest = @"D:\Temp\testfile2.txt"; #region //Formatting string elements public static string LineBar5 = "=========================================================="; public static string Loud1 = "[ ]------------------------------------------------------"; public static string Loud2 = "[ ]******************************************************"; public static string Loud3 = "[ ]======================================================="; public static string Loud4 = "[ ]======================================================="; public static string cursor = "[ ]"; public static string LineBar1 = "-------------------------------------------------"; public static string LineBar2 = "[- - - - - - - - - - - - - - - - - - - - - - - - ]"; public static string LineBar3 = "[- - - - - - ]"; public static string LineBar4 = "___________________________________________________"; #endregion /// <summary> /// Method to standardize comparing two text files /// []Usage: /// string filePath1 = @"D:\Temp\4505n2\bios.ini"; /// string filePath2 = @"D:\Temp\4505n3\bios.ini"; /// string currentLogFile = GlobalData.LogfileBios; /// GlobalData.CompareFiles2(filePath1, filePath2, currentLogFile); /// </summary> /// <param name="contents1">Array to hold text file lines</param> /// <param name="contents2">Array to hold text file lines</param> /// <param name="path1">File1 to be compared</param> /// <param name="path2">File2 to be compared</param> /// <param name="logFileName"></param> /// <returns></returns> public static int CompareFiles(string path1, string path2, string logFileName) { int errCount = 0; // intialize the logfile File.WriteAllText(logFileName, DateTime.Now.ToString() + "\n\n"); File.AppendAllText(logFileName, "Comparing the following files:\n"); File.AppendAllText(logFileName, path1 + " <---> " + path2 + "\n\n"); File.AppendAllText(logFileName, LineBar5 + "\n"); if (File.Exists(path1) && File.Exists(path2)) { string[] contents1, contents2; // Read the contents of the file using ReadAllLines contents1 = File.ReadAllLines(path1); contents2 = File.ReadAllLines(path2); // Loop through the contents of both files, Compare, and send results to a logfile // if file2 is smaller thabn file1, use file2 length to prevent data shortage for (int i = 0; i < ((contents2.Length < contents1.Length) ? contents2.Length : contents1.Length); i++) { //Formatting Output to logfile string data1 = "* ] " + contents1[i]; string data2 = " *] " + contents2[i]; string lineBreak = LineBar4 + "\n"; //// Write To Console ////Console.WriteLine(LineBar5); Console.WriteLine(LineBar1); Console.WriteLine(data1); Console.WriteLine(data2); // Write To File File.AppendAllText(logFileName, lineBreak); File.AppendAllText(logFileName, "[" + i + "]"); if (!contents1[i].Equals(contents2[i])) { errCount++; File.AppendAllText(logFileName, " NOMATCH****# " + errCount + "\n"); } else { File.AppendAllText(logFileName, "[\n"); } File.AppendAllText(logFileName, data1 + "\n"); File.AppendAllText(logFileName, data2 + "\n"); } // Tag the error count at the end of the logfile Debug.WriteLine(logFileName + ": Compare Error Count: " + errCount); File.AppendAllText( logFileName, "\n\n" + LineBar5 + "\n" + "Total Error Count on Compare: " + errCount + "\n" ); } else { Debug.WriteLine("[][GlobalData]One or more text files do not exist"); } //Return the error count in case it is needed for further reporting return errCount; } } }
- Log in to post comments