private void teardown() { if (selenium != null) { selenium.Stop(); } }
//Shut down RC server private void shutDownServer() { try { if (seleniumInstance != null) { seleniumInstance.Stop(); seleniumInstance.ShutDownSeleniumServer(); } System.Diagnostics.Process[] allProcess = System.Diagnostics.Process.GetProcessesByName("java"); if (allProcess.Length != 0) { for (int i = 0; i < allProcess.Length; i++) { allProcess[i].Kill(); } } } catch (SeleniumException e) { Exception friendlyEx = new Exception("Selenium sever shut down failed.", e); throw friendlyEx; } }
public void TeardownTest() { try { selenium.Stop(); List <Order> orders = orderRepo.Orders.Where(o => o.job_name == "Salsa Impulse").ToList(); var histories = (from oh in orderHistoryRepo.OrderHistories where orders.Any(o => o.orderID == oh.orderId) select oh).ToList(); Table <OrderHistory> ohTable = (Table <OrderHistory>)orderHistoryRepo.OrderHistories; ohTable.DeleteAllOnSubmit(histories); ohTable.Context.SubmitChanges(); Table <Order> orderTable = (Table <Order>)orderRepo.Orders; orderTable.DeleteAllOnSubmit(orders); orderTable.Context.SubmitChanges(); User user = userRepo.Users.First(u => u.email.Trim() == "*****@*****.**"); userRepo.DeleteUser(user.userID); userRepo.SubmitChanges(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); }
public void ShutdownSelenium() { if (selenium != null) { selenium.Stop(); selenium = null; } }
public void TeardownTest() { try { selenium.Stop(); } catch (Exception) { // Ignore errors if unable to close the browser } }
public void TeardownTest() { try { selenium.Stop(); } catch (Exception) { } Assert.AreEqual(String.Empty, verificationErrors.ToString()); }
public void TeardownTest() { try { selenium.Stop(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); }
public void TeardownTest() { try { _selenium.Stop(); TearDown(); } catch (Exception) { Console.WriteLine(_verificationErrors.ToString()); } Assert.AreEqual("", _verificationErrors.ToString()); }
public void Logout() { selenium.Click("link=Logout"); selenium.WaitForPageToLoad("30000"); try { selenium.Stop(); } catch (Exception) { // Ignore errors if unable to close the browser } }
public void TeardownTest() { selenium.Click("//a[contains(@href, '/Account/Logout')]"); selenium.WaitForPageToLoad(UpgradeSeleniumTester.browserWait); try { selenium.Stop(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); }
public void Logout() { selenium.Open("/"); selenium.Click("//a[contains(@href, '/Account/Logout')]"); selenium.WaitForPageToLoad("30000"); try { selenium.Stop(); } catch (Exception) { // Ignore errors if unable to close the browser } }
public void TeardownTest() { try { selenium.Stop(); User user = userRepo.Users.First(u => u.email.Trim() == "*****@*****.**"); userRepo.DeleteUser(user.userID); userRepo.SubmitChanges(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); }
/// <summary> /// Disposes of an instance of selenium /// </summary> /// <param name="instance">The instance to be disposed</param> /// <remarks>This method only needs to be called if a specific instance of selenium has been created /// and used rather than the default instance provided by the class</remarks> public void DisposeInstance(ISelenium instance) { try { if (SeleniumServerStarted) { instance.Stop(); } } catch { // If we get an error here not so worried as currently removing the instance. // We don't want to throw an error in case it stops the tests running } Instances.Remove(instance); }
public ActionResult ParseTourFromUrl(ParseUrlModel model) { selenium = new DefaultSelenium("localhost", 4444, "*firefox", "http://localhost"); selenium.Start(); selenium.SetTimeout("120000"); selenium.Open(model.Url); selenium.WaitForPageToLoad("60000"); var html = selenium.GetHtmlSource(); selenium.Stop(); // string html = HtmlDownloader.GetHtml(model.Url); string s = new ForecastParser(QueryFactory, log, UnitOfWorkFactory).ParseHtml(html, model.Url); return(View(new ParseUrlModel { Result = s })); }
private static void StopSelenium() { if (seleniumCache == null) { return; } try { seleniumCache.Stop(); } catch (Exception ex) { Debug.WriteLine(ex, "Selenium stop error"); } seleniumCache = null; Console.WriteLine("-> Selenium stopped"); }
/** * ClearTest used to stop selenium running * */ private void ClearTest() { try { selenium.Stop(); System.Diagnostics.Process[] allProcess = System.Diagnostics.Process.GetProcessesByName("java"); if (allProcess.Length != 0) { for (int i = 0; i < allProcess.Length; i++) { allProcess[i].Kill(); } } } catch (SeleniumException e) { logger.LogErrorAndRaiseException("Error found in ClearTest:" + e.ToString()); } }
// Purpose: To Stop WebDriver public static void WebDriverStop() { if (WebDriver == null) { return; } try { WebDriver.Manage().Cookies.DeleteAllCookies(); WebDriver.Dispose(); Selenium.Stop(); Process[] iexppro = Process.GetProcessesByName("iexplore"); if (iexppro.Length > 0) { foreach (Process clsProcess in iexppro) { clsProcess.Kill(); } } Process[] selcomwin = Process.GetProcessesByName("mshta"); if (selcomwin.Length > 0) { foreach (Process clsProcess in selcomwin) { clsProcess.Kill(); } } Process[] ieDriverserver = Process.GetProcessesByName("IEDriverServer"); if (ieDriverserver.Length > 0) { foreach (Process clsProcess in ieDriverserver) { clsProcess.Kill(); } } } catch (Exception) { throw new Exception("Unable To Stop WebDriver: Please Try Again."); } WebDriver = null; Console.WriteLine("WebDriver Stopped"); }
public void Run() { try { string[] files = Directory.GetFiles(log_path + "a"); for (int i = 0; i < files.Length; i++) { File.Delete(files[i]); } files = Directory.GetFiles(log_path + "b"); for (int i = 0; i < files.Length; i++) { File.Delete(files[i]); } Console.WriteLine("Start selenium instance: host={0}", selenium1_url); selenium1 = new DefaultSelenium(selenium_server, selenium_server_port, browser, selenium1_url); selenium1.Start(); Console.WriteLine("Start selenium instance: host={0}", selenium2_url); selenium2 = new DefaultSelenium(selenium_server, selenium_server_port, browser, selenium2_url); selenium2.Start(); compare_showcase(); } catch (Exception ee) { Console.WriteLine("Exception: {0}", ee.Message); } finally { try { selenium1.Stop(); selenium2.Stop(); } catch (Exception ee) { Console.WriteLine("Exception: {0}", ee.Message); } } Console.WriteLine("Press any key to continue......"); //Console.ReadKey(); }
public void TestMethod1() { selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://www.google.com/"); selenium.Start(); selenium.Open("/"); selenium.Type("q", "selenium rc"); selenium.Click("btnG"); selenium.WaitForPageToLoad("30000"); Assert.AreEqual("selenium rc - Google Search", selenium.GetTitle()); try { selenium.Stop(); } catch (Exception) { // Ignore errors if unable to close the browser } }
public void TestMethod2() { selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://localhost:1987"); selenium.Start(); selenium.Open("/WebSite1/"); selenium.Type("MainContent_TextBox1", "HUM"); selenium.Click("MainContent_Button1"); selenium.WaitForPageToLoad("3000770"); //Get the Table Value of Row 1 and Coulumn 2 object GG = selenium.GetTable("MainContent_GridView1.1.2"); Assert.AreEqual("1", "1"); try { selenium.Stop(); } catch (Exception) { // Ignore errors if unable to close the browser } }
/// <summary> /// Disposes of an instance of selenium /// </summary> /// <param name="instance">The instance to be disposed</param> /// <remarks>This method only needs to be called if a specific instance of selenium has been created /// and used rather than the default instance provided by the class</remarks> public void DisposeInstance(ISelenium instance) { try { if(SeleniumServerStarted) instance.Stop(); } catch { // If we get an error here not so worried as currently removing the instance. // We don't want to throw an error in case it stops the tests running } Instances.Remove(instance); }
public void Stop() { selenium.Stop(); }
}//end ClearTest ///<summary> ///Grab warrant data from http://www.hkex.com.hk/eng/dwrc/newissue/newlaunch.htm ///</summary> ///<returns> void </returns> private void WarrantDataCapture() { int start_position = startPosition; try { selenium1.OpenWindow("/eng/dwrc/newissue/newlaunch.htm", "WarrantListWindow"); selenium1.WaitForPopUp("WarrantListWindow", "30000"); selenium1.SelectWindow("WarrantListWindow"); //Get English Content //while (selenium1.IsElementPresent("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[1]")) while (start_position <= endPosition && selenium1.IsElementPresent("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[1]")) { String launchDateStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[11]"); DateTime tempLaunchDateDT = DateTime.ParseExact(launchDateStr, "dd-MM-yyyy", null); DateTime temp = coreObj.DateCalculate(scheduleDate, tempLaunchDateDT, holidayCount); if (temp.Date == scheduleDate.Date) { HKRicTemplate hkRic = new HKRicTemplate(); hkRic.launchDateDT = DateTime.ParseExact(launchDateStr, "dd-MM-yyyy", null); hkRic.ricCodeStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[2]"); hkRic.ricNameStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[3]"); hkRic.issuerIDStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[4]"); hkRic.underlyingStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[5]"); hkRic.callPutStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[6]"); hkRic.boardLotStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[7]"); hkRic.strikeLevelStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[8]"); hkRic.entitlementRatioStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[9]"); hkRic.issueSizeStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[10]"); hkRic.clearingCommDateDT = DateTime.ParseExact(selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[12]"), "dd-MM-yyyy", null); hkRic.listingDateDT = DateTime.ParseExact(selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[13]"), "dd-MM-yyyy", null); hkRic.maturityDateDT = DateTime.ParseExact(selenium1.GetText("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[14]"), "dd-MM-yyyy", null); //Get issue price String url = selenium1.GetAttribute("//table[@id='bodytable']/tbody/tr/td/table/tbody[1]/tr[" + start_position + "]/td[2]/a@href"); String id = url.Substring(url.IndexOf('=') + 1, 5); String summaryUrl = "http://www.hkex.com.hk/eng/dwrc/dwsummary.asp?id=" + id; selenium1.OpenWindow(summaryUrl, "WarrantSummaryWindow" + start_position); selenium1.WaitForPopUp("WarrantSummaryWindow" + start_position, "30000"); selenium1.SelectWindow("WarrantSummaryWindow" + start_position); //For Equity Get underlying name if (Char.IsDigit(hkRic.underlyingStr, 0)) { hkRic.underlyingNameForStockStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr[3]/td[2]").Substring(8); } hkRic.issuePriceStr = selenium1.GetText("//table[@id='bodytable']/tbody/tr[11]/td[2]").Substring(4); selenium1.Close(); ricList.Add(hkRic); selenium1.SelectWindow("WarrantListWindow"); }//end if start_position++; }//end while ChineseNameCapture(start_position); //Get gearing and premium //search on page http://www.hkexnews.hk/listedco/listconews/advancedsearch/search_active_main.asp DataCaptureFromPDF(0); }//end try catch (SeleniumException ex) { String errLog = ex.ToString(); selenium1.Close(); selenium1.Stop(); CaptureRetry(start_position); } }//end WarrantDataCapture()
public void Dispose() { _selenium.Stop(); }
public void TeardownTest() { selenium.Stop(); }
public void TearDown() { selenium.Stop(); }
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> /// Ends the test session, killing the browser /// </summary> public void Close() { _selenium.Stop(); }
public void FixtureTearDown() { selenium.Stop(); }