File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using NUnit . Framework ;
22using OpenQA . Selenium . Environment ;
33using System ;
4- using OpenQA . Selenium . Remote ;
4+ using static NUnit . Framework . Interfaces . ResultState ;
55
66namespace OpenQA . Selenium
77{
@@ -27,7 +27,7 @@ public abstract class DriverTestFixture
2727 public string javascriptPage = EnvironmentManager . Instance . UrlBuilder . WhereIs ( "javascriptPage.html" ) ;
2828
2929 public string loginPage = EnvironmentManager . Instance . UrlBuilder . WhereIs ( "login.html" ) ;
30-
30+
3131 public string clickEventPage = EnvironmentManager . Instance . UrlBuilder . WhereIs ( "clickEventPage.html" ) ;
3232
3333 public string resultPage = EnvironmentManager . Instance . UrlBuilder . WhereIs ( "resultPage.html" ) ;
@@ -113,7 +113,7 @@ public bool IsNativeEventsEnabled
113113 [ OneTimeSetUp ]
114114 public void SetUp ( )
115115 {
116- driver = EnvironmentManager . Instance . GetCurrentDriver ( ) ;
116+ driver = EnvironmentManager . Instance . CreateFreshDriver ( ) ;
117117 }
118118
119119 [ OneTimeTearDown ]
@@ -122,6 +122,15 @@ public void TearDown()
122122 // EnvironmentManager.Instance.CloseCurrentDriver();
123123 }
124124
125+ [ TearDown ]
126+ public void ResetOnError ( )
127+ {
128+ if ( TestContext . CurrentContext . Result . Outcome == Error )
129+ {
130+ driver = EnvironmentManager . Instance . CreateFreshDriver ( ) ;
131+ }
132+ }
133+
125134 /*
126135 * Exists because a given test might require a fresh driver
127136 */
Original file line number Diff line number Diff line change @@ -138,10 +138,7 @@ private EnvironmentManager()
138138 {
139139 webServer . Stop ( ) ;
140140 }
141- if ( driver != null )
142- {
143- driver . Quit ( ) ;
144- }
141+ CloseCurrentDriver ( ) ;
145142 }
146143
147144 public event EventHandler < DriverStartingEventArgs > DriverStarting ;
You can’t perform that action at this time.
0 commit comments