public void SelectFrame(string locator) { bool actRes = false; string errStr = ""; try { selenium.SelectFrame(locator); actRes = true; } catch (System.Exception ex) { errStr = ex.ToString(); } res = new ResultClass() { Decp = "SelectFrame, " + locator, Res = actRes ? "pass" : "fail", Tdev = " ms", Err = errStr, }; BaseListOfResItems.Add(res); }
/// <summary> Update the Handicap Value of a selection /// Author : Yogesh M /// </summary> /// Date Created: Feb 03 2012 /// eg: updatehandicapValue = UpdateHandicapValue(browser, "1234555", "2"); /// Note: You need to specify the list number present in the Handicap list box & not the value in the list box /// <param name="browser">Selenium Browser Instance</param> /// <param name="selectionId">Selection Id of the selection</param> /// <param name="handicapListNumber">The list number in the handicap list box(1 to 81)</param> /// <returns> Updated handicap value</returns> public string UpdateHandicapValue(ISelenium browser, string selectionId, int handicapListNumber) { try { //Clicking on Event Link in LHN LHNavigation(AdminSuite.CommonControls.AdminHomePage.EventNameLink, browser); //Selecting TopFrame Thread.Sleep(2000); browser.WaitForPageToLoad("60000"); browser.SelectFrame("relative=top"); browser.SelectFrame("MainArea"); browser.WaitForPageToLoad("10000"); //SelectMainFrame(browser); browser.Type("//input[@name='openbet_id']", selectionId); // browser.Select(AdminSuite.CommonControls.AdminHomePage.OpenBetHierarchyLevelDrpLst, AdminSuite.CommonControls.AdminHomePage.OpenBetHeierarchyName); browser.Select("//select[@name='hierarchy_level']", AdminSuite.CommonControls.AdminHomePage.OpenBetHeierarchyName); browser.Focus(AdminSuite.CommonControls.AdminHomePage.EventFindBtn); browser.Click(AdminSuite.CommonControls.AdminHomePage.EventFindBtn); _frameworkCommon.WaitUntilAllElementsLoad(browser); browser.WaitForPageToLoad(Framework.FrameGlobals.PageLoadTimeOut); browser.Focus(AdminSuite.CommonControls.EventDetailsPage.BackButton); //click on back button present in the selection page browser.Click(AdminSuite.CommonControls.EventDetailsPage.BackButton); //click on back button present in the selection page browser.WaitForPageToLoad(Framework.FrameGlobals.PageLoadTimeOut); //update the handicap value in the market page IWebDriver driver = ((WebDriverBackedSelenium)browser).UnderlyingWebDriver; _frameworkCommon.WaitUntilAllElementsLoad(browser); Thread.Sleep(5000); _frameworkCommon.WaitUntilElementPresent(browser, AdminSuite.CommonControls.EventDetailsPage.HandicapValueListBox, "20000"); int labels = driver.FindElements(By.XPath(AdminSuite.CommonControls.EventDetailsPage.HandicaValueLabels)).Count; // verify if the user has entered the handicap list number present in the handicap list box in market page Assert.IsTrue(handicapListNumber <= labels, "Please select a handicap list number <= " + labels + ""); string updatedHandicapValue = driver.FindElement(By.XPath("//select[@name='MktHcapValue']/option[" + handicapListNumber + "]")).Text; browser.Select(AdminSuite.CommonControls.EventDetailsPage.HandicapValueListBox, updatedHandicapValue); // Handicap list drop down in the market page // Updating the event details page browser.Click(AdminSuite.CommonControls.EventDetailsPage.ModifyMarketButton); browser.WaitForPageToLoad(Framework.FrameGlobals.PageLoadTimeOut); Console.WriteLine("Handicapped value is updated to : " + updatedHandicapValue + ""); return updatedHandicapValue; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.Message); return null; } }
///<summary> /// To Select Top Bar Frame /// Author: Yogesh /// Ex:SelectMainFrame(myBrowser) /// <returns>Selection of Top Bar frame in Admin home page</returns> /// Created Date: 22-Dec-2011 /// Modified Date: 22-Dec-2011 /// Modification Comments: public void SelectTopBarFrame(ISelenium myBrowser) { try { myBrowser.SelectFrame("relative=top"); myBrowser.SelectFrame("TopBar"); } //throw new NotImplementedException(); catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } }
///<summary> /// To Select Main Frame /// Author: Yogesh /// Ex:SelectMainFrame(myBrowser) /// <returns>None</returns> /// Created Date: 22-Dec-2011 /// Modified Date: 22-Dec-2011 /// Modification Comments: public void SelectMainFrame(ISelenium myBrowser) { try { myBrowser.SelectFrame("relative=top"); myBrowser.SelectFrame("MainArea"); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } }
/// <summary> /// Author : Roopa /// Date : 22-1-2013 /// </summary> /// <param name="browser"></param> /// <param name="selectionId"></param> /// <returns></returns> public string GetHandicapValue(ISelenium browser, string selectionId) { string handicapValue = null; try { //Clicking on Event Link in LHN LHNavigation(AdminSuite.CommonControls.AdminHomePage.EventNameLink, browser); Thread.Sleep(2000); //Selecting TopFrame browser.WaitForPageToLoad("60000"); browser.SelectFrame("relative=top"); browser.SelectFrame("MainArea"); browser.WaitForPageToLoad("10000"); // SelectMainFrame(browser); browser.Type(AdminSuite.CommonControls.AdminHomePage.OpenBetIdTextBox, selectionId); browser.Type("//input[@name='openbet_id']", selectionId); browser.Select(AdminSuite.CommonControls.AdminHomePage.OpenBetHierarchyLevelDrpLst, AdminSuite.CommonControls.AdminHomePage.OpenBetHeierarchyName); browser.Focus(AdminSuite.CommonControls.AdminHomePage.EventFindBtn); browser.Click(AdminSuite.CommonControls.AdminHomePage.EventFindBtn); _frameworkCommon.WaitUntilAllElementsLoad(browser); browser.WaitForPageToLoad(Framework.FrameGlobals.PageLoadTimeOut); browser.Focus(AdminSuite.CommonControls.EventDetailsPage.BackButton); //click on back button present in the selection page browser.Click(AdminSuite.CommonControls.EventDetailsPage.BackButton); //click on back button present in the selection page browser.WaitForPageToLoad(Framework.FrameGlobals.PageLoadTimeOut); Thread.Sleep(3000); //get the handicap value in the market page if (browser.IsElementPresent(AdminSuite.CommonControls.EventDetailsPage.currentHandicapValue)) { // handicapValue = browser.GetSelectedLabel(AdminSuite.CommonControls.EventDetailsPage.currentHandicapValue); handicapValue = browser.GetSelectedLabel(AdminSuite.CommonControls.EventDetailsPage.HandicapValueListBox); //browser.Gets } else { return null; } return handicapValue; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); Console.WriteLine(ex.Message); return null; } }
private void uploadFile(int i) { StartRC(); i++; try { selenium.Open("/GEDA15/index.html"); selenium.WaitForPageToLoad("50000"); selenium.Type("username", "YQ_LI"); selenium.Type("password", "Reuters5"); //selenium.Click("ext-gen27"); selenium.Click("//button[@class=' x-btn-text'][text()='Login']"); selenium.WaitForPageToLoad("50000"); System.Threading.Thread.Sleep(2000); selenium.Click("css=img.x-tree-ec-icon.x-tree-elbow-end-plus"); System.Threading.Thread.Sleep(2000); selenium.DoubleClick("//ul[@class='x-tree-node-ct']/li[@class='x-tree-node']/descendant::a[@class='x-tree-node-anchor']/span[text()='Message Editor']"); selenium.SelectFrame("IFFMEditor"); System.Threading.Thread.Sleep(4000); //Upload the first file selenium.Click("ext-gen163"); System.Threading.Thread.Sleep(2000); selenium.Click("//div[@class='x-combo-list-inner']/descendant::div[contains(@class, 'x-combo-list-item')][text()='HK_BULK']"); selenium.Click("ext-gen168"); System.Threading.Thread.Sleep(2000); selenium.Click("css=#ext-gen182 > div.x-combo-list-item"); selenium.Click("//button[@class=' x-btn-text search'][text()='Search']"); System.Threading.Thread.Sleep(2000); selenium.Click("//button[@class=' x-btn-text import'][text()='Upload File']"); System.Threading.Thread.Sleep(2000); selenium.Type("form-file", "D:\\HKRicTemplate\\HKG_EQLB.txt"); System.Threading.Thread.Sleep(3000); //Upload selenium.Click("//button[@class=' x-btn-text'][text()='Upload']"); System.Threading.Thread.Sleep(2000); //Ok selenium.Click("//button[@class=' x-btn-text'][text()='OK']"); System.Threading.Thread.Sleep(3000); //Upload the second file selenium.Click("ext-gen163"); System.Threading.Thread.Sleep(2000); selenium.Click("//div[@class='x-combo-list-inner']/descendant::div[contains(@class, 'x-combo-list-item')][text()='HK_CBBC1']"); selenium.Click("ext-gen168"); System.Threading.Thread.Sleep(2000); selenium.Click("css=#ext-gen182 > div.x-combo-list-item"); selenium.Click("//button[@class=' x-btn-text search'][text()='Search']"); System.Threading.Thread.Sleep(2000); selenium.Click("//button[@class=' x-btn-text import'][text()='Upload File']"); System.Threading.Thread.Sleep(2000); selenium.Type("form-file", "D:\\HKRicTemplate\\HKG_EQLB_CBBC.txt"); System.Threading.Thread.Sleep(2000); //Upload selenium.Click("//button[@class=' x-btn-text'][text()='Upload']"); System.Threading.Thread.Sleep(2000); //Ok selenium.Click("//button[@class=' x-btn-text'][text()='OK']"); System.Threading.Thread.Sleep(3000); //Upload the third file selenium.Click("ext-gen163"); System.Threading.Thread.Sleep(2000); selenium.Click("//div[@class='x-combo-list-inner']/descendant::div[contains(@class, 'x-combo-list-item')][text()='HK_EQLBMI']"); selenium.Click("ext-gen168"); System.Threading.Thread.Sleep(2000); selenium.Click("css=#ext-gen182 > div.x-combo-list-item"); selenium.Click("//button[@class=' x-btn-text search'][text()='Search']"); System.Threading.Thread.Sleep(2000); selenium.Click("//button[@class=' x-btn-text import'][text()='Upload File']"); System.Threading.Thread.Sleep(2000); selenium.Type("form-file", "D:\\HKRicTemplate\\HKG_EQLBMI.txt"); System.Threading.Thread.Sleep(2000); //Upload selenium.Click("//button[@class=' x-btn-text'][text()='Upload']"); System.Threading.Thread.Sleep(2000); //Ok selenium.Click("//button[@class=' x-btn-text'][text()='OK']"); selenium.Close(); selenium.Stop(); } catch (SeleniumException ex) { if (ex.Message.Contains("Timed out") && i < 4) { uploadFile(i); } MessageBox.Show(ex.Message); selenium.Close(); selenium.Stop(); } }
/// <summary> /// Uploads the specified csv files to create Events/Markets/Selections /// </summary> /// <param name="filepath">Exact file name along with full path</param> /// <param name="browser">Browser instance</param> public void UploadCsvFilesToAdmin(string filepath, ref ISelenium browser) { try { browser.SelectFrame("relative=top"); browser.SelectFrame("TopBar"); //browser.Click("//li[a[text()='Events']]/following-sibling::li[a[text()='Event Upload']]"); IWebDriver driver = ((WebDriverBackedSelenium)browser).UnderlyingWebDriver; driver.FindElement(By.LinkText("Event Upload")).Click(); browser.WaitForPageToLoad("60000"); browser.SelectFrame("relative=top"); browser.SelectFrame("MainArea"); browser.WaitForPageToLoad("10000"); string[] filename = filepath.Split('\\'); Console.WriteLine(filename[filename.Length - 1] + " : Is the file name"); switch (filename[filename.Length - 1]) { case "EVENTS.CSV": //events,markets,selections,results,fbscores browser.Select("name=filetype", "Events"); browser.Type("name=filename", filepath); browser.Focus("//table/tbody/tr/th[@class='buttons' and @colspan='2']/input[@type='submit' and @value='Upload File' and @name='DoIt']"); browser.Click("//table/tbody/tr/th[@class='buttons' and @colspan='2']/input[@type='submit' and @value='Upload File' and @name='DoIt']"); browser.WaitForPageToLoad("10000"); Assert.IsTrue(browser.IsElementPresent("//td/a[(text()='EVENTS.CSV')]"), ""); browser.Click("//td/a[contains(text(),'EVENTS.CSV')]"); browser.WaitForPageToLoad("10000"); browser.Click("name=SetResult"); browser.WaitForPageToLoad("10000"); // to handle javascript pop up if (browser.IsAlertPresent()) browser.ChooseOkOnNextConfirmation(); Thread.Sleep(2000); //string fileUploadmsg = browser.GetText("//tr[@class=infoyes/tb/b"); //Console.WriteLine(fileUploadmsg + "is the message displayed after File upload, Expected message is 'File uploaded OK'"); browser.Click("//input[@value='Delete File']"); browser.WaitForPageToLoad("10000"); break; case "market.CSV": browser.Select("name=filetype", "Markets");//events,markets,selections,results,fbscores browser.Type("name=filename", filepath); browser.Focus("//table/tbody/tr/th[@class='buttons' and @colspan='2']/input[@type='submit' and @value='Upload File' and @name='DoIt']"); browser.Click("//table/tbody/tr/th[@class='buttons' and @colspan='2']/input[@type='submit' and @value='Upload File' and @name='DoIt']");//upload file browser.WaitForPageToLoad("10000"); Assert.IsTrue(browser.IsElementPresent("//td/a[(text()='market.CSV')]"), ""); browser.Click("//td/a[contains(text(),'market.CSV')]"); browser.WaitForPageToLoad("10000"); browser.Click("name=SetResult"); browser.WaitForPageToLoad("10000"); /// to handle javascript pop up if (browser.IsAlertPresent()) browser.ChooseOkOnNextConfirmation(); Thread.Sleep(2000); //string fileUplodmsg = browser.GetText("//tr[@class=infoyes/tb/b"); //Console.WriteLine(fileUplodmsg + "is the message displayed after File upload, Expected message is 'File uploaded OK'"); browser.Click("//input[@value='Delete File']"); browser.WaitForPageToLoad("10000"); break; case "SELECTIONS.CSV": browser.Select("name=filetype", "Selections");//events,markets,selections,results,fbscores browser.Type("name=filename", filepath); browser.Focus("//table/tbody/tr/th[@class='buttons' and @colspan='2']/input[@type='submit' and @value='Upload File' and @name='DoIt']"); browser.Click("//table/tbody/tr/th[@class='buttons' and @colspan='2']/input[@type='submit' and @value='Upload File' and @name='DoIt']");//upload file browser.WaitForPageToLoad("10000"); Assert.IsTrue(browser.IsElementPresent("//td/a[(text()='SELECTIONS.CSV')]"), ""); browser.Click("//td/a[contains(text(),'SELECTIONS.CSV')]"); browser.WaitForPageToLoad("10000"); browser.Click("name=SetResult"); browser.WaitForPageToLoad("10000"); Thread.Sleep(2000); /// to handle javascript pop up if (browser.IsAlertPresent()) browser.ChooseOkOnNextConfirmation(); Thread.Sleep(2000); //string fileUplodmessage = browser.GetText("//tr[@class=infoyes/tb/b"); //Console.WriteLine(fileUplodmessage + "is the message displayed after File upload, Expected message is 'File uploaded OK'"); browser.Click("//input[@value='Delete File']"); browser.WaitForPageToLoad("10000"); break; default: break; } } catch (Exception Ex) { Framework.BaseTest.CaptureScreenshot(browser, ""); Console.WriteLine(Ex.StackTrace); Framework.BaseTest.Fail(Ex.Message); } }