@@ -9,32 +9,44 @@ namespace FlaUI.WebDriver.UITests
99 [ TestFixture ]
1010 public class ActionsTests
1111 {
12+ private RemoteWebDriver _driver ;
13+
14+ [ SetUp ]
15+ public void Setup ( )
16+ {
17+ var driverOptions = FlaUIDriverOptions . TestApp ( ) ;
18+ _driver = new RemoteWebDriver ( WebDriverFixture . WebDriverUrl , driverOptions ) ;
19+ }
20+
21+ [ TearDown ]
22+ public void Teardown ( )
23+ {
24+ _driver ? . Dispose ( ) ;
25+ }
26+
1227 [ Test ]
1328 public void PerformActions_KeyDownKeyUp_IsSupported ( )
1429 {
15- var driverOptions = FlaUIDriverOptions . TestApp ( ) ;
16- using var driver = new RemoteWebDriver ( WebDriverFixture . WebDriverUrl , driverOptions ) ;
17- var element = driver . FindElement ( ExtendedBy . AccessibilityId ( "TextBox" ) ) ;
30+ var element = _driver . FindElement ( ExtendedBy . AccessibilityId ( "TextBox" ) ) ;
1831 element . Click ( ) ;
1932
20- new Actions ( driver ) . KeyDown ( Keys . Control ) . KeyDown ( Keys . Backspace ) . KeyUp ( Keys . Backspace ) . KeyUp ( Keys . Control ) . Perform ( ) ;
21-
22- Assert . That ( driver . SwitchTo ( ) . ActiveElement ( ) . Text , Is . EqualTo ( "Test " ) ) ;
33+ new Actions ( _driver ) . KeyDown ( Keys . Control ) . KeyDown ( Keys . Backspace ) . KeyUp ( Keys . Backspace ) . KeyUp ( Keys . Control ) . Perform ( ) ;
34+ string activeElementText = _driver . SwitchTo ( ) . ActiveElement ( ) . Text ;
35+ Assert . That ( activeElementText , Is . EqualTo ( "Test " ) ) ;
2336 }
2437
2538 [ Test ]
2639 public void ReleaseActions_Default_ReleasesKeys ( )
2740 {
28- var driverOptions = FlaUIDriverOptions . TestApp ( ) ;
29- using var driver = new RemoteWebDriver ( WebDriverFixture . WebDriverUrl , driverOptions ) ;
30- var element = driver . FindElement ( ExtendedBy . AccessibilityId ( "TextBox" ) ) ;
41+ var element = _driver . FindElement ( ExtendedBy . AccessibilityId ( "TextBox" ) ) ;
3142 element . Click ( ) ;
32- new Actions ( driver ) . KeyDown ( Keys . Control ) . Perform ( ) ;
43+ new Actions ( _driver ) . KeyDown ( Keys . Control ) . Perform ( ) ;
3344
34- driver . ResetInputState ( ) ;
45+ _driver . ResetInputState ( ) ;
3546
36- new Actions ( driver ) . KeyDown ( Keys . Backspace ) . KeyUp ( Keys . Backspace ) . Perform ( ) ;
37- Assert . That ( driver . SwitchTo ( ) . ActiveElement ( ) . Text , Is . EqualTo ( "Test TextBo" ) ) ;
47+ new Actions ( _driver ) . KeyDown ( Keys . Backspace ) . KeyUp ( Keys . Backspace ) . Perform ( ) ;
48+ string activeElmentText = _driver . SwitchTo ( ) . ActiveElement ( ) . Text ;
49+ Assert . That ( activeElmentText , Is . EqualTo ( "Test TextBo" ) ) ;
3850 }
3951 }
4052}
0 commit comments