public void CloseBrowsersBeforeTestStartTest() { // Save the value to reset it later bool reset = SWAT.WantCloseBrowsersBeforeTestStart.CloseBrowsersBeforeTestStart; string ieProcessName = "iexplore"; string ffProcessName = "firefox"; bool areAllIEClosed; bool areAllFFClosed; WebBrowser _IEBrowser = new WebBrowser(BrowserType.InternetExplorer); WebBrowser _FFBrowser = new WebBrowser(BrowserType.FireFox); SWAT.Fitnesse.SWATFixture testing; // Open multiple windows to close _IEBrowser.OpenBrowser(); _IEBrowser.NavigateBrowser("www.google.com"); _IEBrowser.OpenBrowser(); _IEBrowser.NavigateBrowser("www.w3schools.com"); // Set the user setting to false SWAT.WantCloseBrowsersBeforeTestStart.CloseBrowsersBeforeTestStart = false; SWAT.UserConfigHandler.Save(); // SWATFixture's constructor should not kill all open IE browsers testing = new InternetExplorerSWATFixture(); // Assert that all the IE browsers have not closed areAllIEClosed = (Process.GetProcessesByName("iexplore").Length == 0); Assert.IsFalse(areAllIEClosed, "CloseBrowsersBeforeTestStart failed: " + "closed all windows when the user setting was turned off."); // Open multiple windows to close again _IEBrowser.OpenBrowser(); _IEBrowser.NavigateBrowser("www.google.com"); _IEBrowser.OpenBrowser(); _IEBrowser.NavigateBrowser("www.w3schools.com"); // Set the user setting to true SWAT.WantCloseBrowsersBeforeTestStart.CloseBrowsersBeforeTestStart = true; SWAT.UserConfigHandler.Save(); // SWATFixture's constructor should kill all open IE browsers testing = new InternetExplorerSWATFixture(); // Assert that all the IE windows have been closed areAllIEClosed = (Process.GetProcessesByName(ieProcessName).Length == 0); Assert.IsTrue(areAllIEClosed, "CloseBrowsersBeforeTestStart failed: " + "did not close all windows."); // Open multiple windows to close again _IEBrowser.OpenBrowser(); _IEBrowser.NavigateBrowser("www.google.com"); _IEBrowser.OpenBrowser(); _IEBrowser.NavigateBrowser("www.w3schools.com"); // Open multiple windows to close again _FFBrowser.OpenBrowser(); _FFBrowser.NavigateBrowser("www.google.com"); _FFBrowser.OpenBrowser(); _FFBrowser.NavigateBrowser("www.w3schools.com"); // SWATFixture's constructor should kill all open IE and FF browsers testing = new FireFoxSWATFixture(); // Assert that all the IE windows have been closed areAllIEClosed = (Process.GetProcessesByName(ieProcessName).Length == 0); Assert.IsTrue(areAllIEClosed, "CloseBrowsersBeforeTestStart failed: " + "did not close all windows."); // Assert that all the FF windows have been closed areAllFFClosed = (Process.GetProcessesByName(ffProcessName).Length == 0); Assert.IsTrue(areAllFFClosed, "CloseBrowsersBeforeTestStart failed: " + "did not close all windows."); // Reset the user config setting SWAT.WantCloseBrowsersBeforeTestStart.CloseBrowsersBeforeTestStart = reset; SWAT.UserConfigHandler.Save(); }
public void TestEndSuspendedTest() { // Save the value to reset it later SWAT.WantSuspendOnFail.SuspendTestOnFail = true; SWAT.UserConfigHandler.Save(); found = false; InternetExplorerSWATFixture testFixture = new InternetExplorerSWATFixture(); Thread thread = new Thread(new ThreadStart(endSuspendTest)); //Begin searching for Suspend Test dialog thread.Start(); fit.Parse testParse = new fit.Parse("<table><tr><td>SWATFixture</td></tr><tr><td>OpenBrowser</td></tr><tr><td>NavigateBrowser</td><td>www.google.com</td></tr><tr><td>AssertElementExists</td><td>Id</td><td>DoesNotExist</td></tr><tr><td>CloseBrowser</td></tr></table>"); testFixture.DoTable(testParse); System.Console.Write("Made it past the DoTable issue"); System.Threading.Thread.Sleep(500); thread.Abort(); Assert.IsTrue(found); Assert.IsTrue(findBrowser()); SWAT.WantSuspendOnFail.SuspendTestOnFail = false; SWAT.UserConfigHandler.Save(); }
public void InverseModifierFailedAPassingCommandTest() { InternetExplorerSWATFixture testFixture = new InternetExplorerSWATFixture(); SetDebugMode(testFixture, true); bool passed = true; fit.Parse testParse = new fit.Parse("<table><tr><td>SWATFixture</td></tr><tr><td><><>AssertEqualTo</td><td>0</td><td>0</td></tr></table>"); try { testFixture.DoTable(testParse); } catch (Exception) { passed = false; } Assert.IsTrue(passed, "Command failed unexpectedly."); SetDebugMode(testFixture, false); }
public void FitnesseVariableThatDoesNotExistRetrieverTest() { InternetExplorerSWATFixture testFixture = new InternetExplorerSWATFixture(); fit.Parse testParse = new fit.Parse("<table><tr><td>SWATFixture</td></tr><tr><td>OpenBrowser</td></tr><tr><td>NavigateBrowser</td><td>http://localhost/swat/TestPage.htm</td></tr><tr><td>SetElementAttribute</td><td>Id</td><td>txtOne</td><td>value</td><td>>>doesNotExit<<</td><td>input</td></tr></table>"); try { testFixture.DoTable(testParse); } finally { ProcessKiller.Kill("iexplore"); } }
public void FitnesseVariableRetrieverTest() { InternetExplorerSWATFixture testFixture = new InternetExplorerSWATFixture(); SetDebugMode(testFixture, true); bool passed = true; fit.Parse testParse = new fit.Parse("<table><tr><td>SWATFixture</td></tr><tr><td>RunScript</td><td>CSHARP</td><td>namespace SWAT{class test{public static string Main(){swatVars.Save(\"key2\", \"yo son\"); return swatVars.Recall(\"key2\");}}}</td><td>yo son</td></tr></table>"); try { testFixture.DoTable(testParse); } catch (Exception) { passed = false; } Assert.IsTrue(passed, "Command failed unexpectedly."); SetDebugMode(testFixture, false); }
public void TestFitnesseWithCommandThatDoesNotPassAndAbandonTest() { InternetExplorerSWATFixture testFixture = new InternetExplorerSWATFixture(); bool passed = true; fit.Parse testParse = new fit.Parse("<table><tr><td>SWATFixture</td></tr><tr><td>OpenBrowser</td></tr><tr><td>NavigateBrowser</td><td>www.google.com</td></tr><tr><td>@@RunScript</td><td>(5==5);</td><td>false</td></tr><tr><td>@@AbandonTest</td></tr><tr><td>@@SetElementAttribute</td><td>Name</td><td>q</td><td>value</td><td>test</td></tr><tr><td>@@ResumeTest</td></tr></table>"); fit.Parse testResultParse = new fit.Parse("<table><tr><td>SWATFixture</td></tr><tr><td>@@AttachToWindow</td><td>Google</td></tr><tr><td>@@AssertElementDoesNotExist</td><td>Expression</td><td>name=q;value=test</td><td>input</td></tr><tr><td>@@CloseBrowser</td></tr></table>"); testFixture.DoTable(testParse); SetDebugMode(testFixture, true); try { testFixture.DoTable(testResultParse); } catch (SWAT.AssertionFailedException) { passed = false; } Assert.IsTrue(passed); SetDebugMode(testFixture, false); }
[TestCase("<table><tr><td>SWATFixture</td></tr><tr><td>GetConfigurationItem</td><td>FindElementTimeout</td><td>configItemVar</td></tr></table>", false)] //GetConfigurationItem public void TestInternetExplorerSWATFixtureTestTable(String parser, bool value) { TestManager.InCompareData = value; InternetExplorerSWATFixture testFixture = new InternetExplorerSWATFixture(); fit.Parse testParse = new fit.Parse(parser); testFixture.DoTable(testParse); }