public static void OpenBrowserMethod_Test() { //instantiating GlobalSeleniumMethods Class GlobalSeleniumMethods selObj = new GlobalSeleniumMethods(); //Opens Browser selObj.OpenBrowser("www.google.com", "gbqfba", 10, (int)CtrlClass.Button); //Close the browser //selObj.CloseAllIEBrowser(); selObj.Quit(); }
public static void SimpleScript_Test() { GlobalSeleniumMethods selObj = new GlobalSeleniumMethods(); bool bRtn; int n = 1; string storyTitle = "Sample TestCase Automation with Selenium Framework in C#"; //string storyTitle2 = "StoryTile 2 Testing creating new section"; Log.Info("***********************************************" + storyTitle + " ========> Started *****************************************************************"); try { //Opens Browser bRtn = selObj.OpenBrowser("www.quickenloans.com", "//*[@id='navigation_primary_home']", 5, (int)CtrlType.XPath); ReportEngine.AddToReport(n++.ToString(), "Goto 'www.quickenloans.com' site", bRtn, "", storyTitle); bRtn = selObj.HoverMenu("navigation_primary_refinance", "//a[contains(text(),'Lower Your Payment')]", (int)CtrlType.ID, (int)CtrlType.XPath); ReportEngine.AddToReport(n++.ToString(), "Goto 'Refinance>Lower Your Payment' page ", bRtn, "", storyTitle); //bRtn = selObj.PerformAction("//a[contains(text(),'Home')]",(int)CtrlType.XPath, (int)CtrlClass.SingleClick); //ReportEngine.AddToReport(n++.ToString(), "Click on 'Home' tab ", bRtn, "", storyTitle); //bRtn = selObj.HoverMenu("//a[contains(text(),'Refinance')]", "//a[contains(text(),'Lower Your Payment')]", (int)CtrlType.XPath, (int)CtrlType.XPath); //ReportEngine.AddToReport(n++.ToString(), "Goto 'Refinance>Lower Your Payment' page", bRtn, "", storyTitle); bRtn = selObj.PerformAction("//*[@id='referral_FirstName']", "FirstName Frank", (int)CtrlType.XPath, (int)CtrlClass.TextBox); ReportEngine.AddToReport(n++.ToString(), "Enters 'Frank' in the FirstName field ", bRtn, "", storyTitle); bRtn = selObj.PerformAction("referral_LastName", "LastName Musabay", (int)CtrlType.ID, (int)CtrlClass.TextBox); ReportEngine.AddToReport(n++.ToString(), "Enters 'Musabay' in the LastName field ", bRtn, "", storyTitle); bRtn = selObj.PerformAction("referral[Zipcode]", "92126", (int)CtrlType.Name, (int)CtrlClass.TextBox); ReportEngine.AddToReport(n++.ToString(), "Enters '92126' value in the Zip: field ", bRtn, "", storyTitle); } catch (Exception ex) { Log.Error(ex); bRtn = false; selObj.Quit(); } selObj.Quit(); Log.Info("***********************************************" + storyTitle + " ========> Ended *****************************************************************"); }
public void AddToReport(string iStepNumber, string sStepName, bool sValidation, string sException, string sStoryTitle) { var StepExecutionTime = DateTime.Now.ToString(); var countStepNumer = iStepNumber; if (!sException.Equals(null) || !sException.Equals("")) { //var sExceptionResult = sException.ToString(); } else { sException = ""; } if (sValidation.Equals(true)) { var sValidationResult = "Passed"; statusValidationPass = 1; statusValidationFailed = 0; addReportColumns(); iStepNumber = "Step #" + iStepNumber; var myRowCount = myTable.Rows.Count; if (myRowCount.Equals(0)) { firstStoryTitleID = sStoryTitle; myTable.Rows.Add(iStepNumber, StepExecutionTime, sStepName, sValidationResult, sException, statusValidationPass, StatusValidationFailed, firstStoryTitleID); //myTable.Rows.[0].AcceptChanges(); CreateSection(); } else { firstStoryTitleID = sStoryTitle; var emptyRow = myTable.Rows.Count + 1; var myNewRow = myTable.Rows.Add(iStepNumber, StepExecutionTime, sStepName, sValidationResult, sException, statusValidationPass, StatusValidationFailed, sStoryTitle); } } else { GlobalSeleniumMethods selObj = new GlobalSeleniumMethods(); IWebDriver webdriver = null; string ScreenShot = ""; webdriver = selObj.GetDriver(); selObj.TakeScreenShot(ref ScreenShot); string ScreenShotLink = "<a href=\"" + ScreenShot + "\">Error_Snapshot</a"; sException = ScreenShotLink; var sValidationResult = "Failed"; statusValidationPass = 0; statusValidationFailed = 1; addReportColumns(); iStepNumber = "Step #" + iStepNumber; var myRowCount = myTable.Rows.Count; if (myRowCount.Equals(0)) { firstSectionStoryID = sStoryTitle; myTable.Rows.Add(iStepNumber, StepExecutionTime, sStepName, sValidationResult, sException, statusValidationPass, StatusValidationFailed, firstSectionStoryID); //myTable.Rows.[0].AcceptChanges(); CreateSection(); } else { firstStoryTitleID = sStoryTitle; var emptyRow = myTable.Rows.Count + 1; var myNewRow = myTable.Rows.Add(iStepNumber, StepExecutionTime, sStepName, sValidationResult, sException, statusValidationPass, StatusValidationFailed, firstStoryTitleID); } //if (!iStepNumber.Equals("Error")) //{ // AssertStatement(sValidationFalse,sStepName); //} } }
public static void ScreenResize_Test() { GlobalSeleniumMethods selObj = new GlobalSeleniumMethods(); selObj.ScreenResize(1024, 680); }