@@ -56,25 +56,24 @@ public void Should_BePossibleTo_NavigateBackAndForward()
5656 [ Test ]
5757 public void Should_BePossibleTo_OpenNewBrowserAfterQuit ( )
5858 {
59- var url = new WelcomeForm ( ) . Url ;
60- var browser = BrowserManager . Browser ;
61- browser . GoTo ( url ) ;
62- browser . Quit ( ) ;
59+ var welcomeForm = new WelcomeForm ( ) ;
60+ welcomeForm . Open ( ) ;
61+ BrowserManager . Browser . Quit ( ) ;
6362
64- Assert . AreNotEqual ( url , BrowserManager . Browser . CurrentUrl ) ;
63+ Assert . AreNotEqual ( welcomeForm . Url , BrowserManager . Browser . CurrentUrl ) ;
6564 }
6665
6766 [ Test ]
6867 public void Should_BePossibleTo_RefreshPage ( )
6968 {
70- var url = new DynamicContentForm ( ) . Url ;
71- var browser = BrowserManager . Browser ;
72- browser . GoTo ( url ) ;
7369 var dynamicContentForm = new DynamicContentForm ( ) ;
70+ dynamicContentForm . Open ( ) ;
7471 var firstItem = dynamicContentForm . GetContentItem ( 1 ) . GetText ( ) ;
7572
73+ var browser = BrowserManager . Browser ;
7674 browser . Refresh ( ) ;
7775 browser . WaitForPageToLoad ( ) ;
76+
7877 var firstItemAfterRefresh = dynamicContentForm . GetContentItem ( 1 ) . GetText ( ) ;
7978 Assert . AreNotEqual ( firstItem , firstItemAfterRefresh ) ;
8079 }
@@ -90,71 +89,60 @@ public void Should_BePossibleTo_SetPageLoadTimeout()
9089 [ Test ]
9190 public void Should_BePossibleTo_TakeScreenshot ( )
9291 {
93- var url = new DynamicContentForm ( ) . Url ;
94- var browser = BrowserManager . Browser ;
95- browser . GoTo ( url ) ;
96- browser . WaitForPageToLoad ( ) ;
97- Assert . IsTrue ( browser . GetScreenshot ( ) . Length > 0 ) ;
92+ new DynamicContentForm ( ) . Open ( ) ;
93+ Assert . IsTrue ( BrowserManager . Browser . GetScreenshot ( ) . Length > 0 ) ;
9894 }
9995
10096 [ Test ]
10197 public void Should_BePossibleTo_ExecuteJavaScript ( )
10298 {
103- var url = new DynamicContentForm ( ) . Url ;
104- var browser = BrowserManager . Browser ;
105- browser . GoTo ( url ) ;
106- browser . WaitForPageToLoad ( ) ;
107- var currentUrl = browser . ExecuteScript < string > ( "return window.location.href" ) ;
108- Assert . AreEqual ( url , currentUrl ) ;
99+ var dynamicContentForm = new DynamicContentForm ( ) ;
100+ dynamicContentForm . Open ( ) ;
101+ var currentUrl = BrowserManager . Browser . ExecuteScript < string > ( "return window.location.href" ) ;
102+ Assert . AreEqual ( dynamicContentForm . Url , currentUrl ) ;
109103 }
110104
111- [ Ignore ( "Need to be fixed" ) ]
112105 [ Test ]
113106 public void Should_BePossibleTo_ExecuteAsyncJavaScript ( )
114107 {
115- var url = new DynamicContentForm ( ) . Url ;
116- var browser = BrowserManager . Browser ;
117- browser . GoTo ( url ) ;
118- browser . WaitForPageToLoad ( ) ;
119- var expectedDurationInSeconds = 1 ;
120- var operationDurationInSeconds = 1 ;
108+ const int expectedDurationInSeconds = 1 ;
109+ const int operationDurationInSeconds = 1 ;
110+
111+ new DynamicContentForm ( ) . Open ( ) ;
121112
122113 var stopwatch = new Stopwatch ( ) ;
123114 stopwatch . Start ( ) ;
124- browser . ExecuteAsyncScript ( GetAsyncTimeoutJavaScript ( expectedDurationInSeconds ) ) ;
115+ BrowserManager . Browser . ExecuteAsyncScript ( GetAsyncTimeoutJavaScript ( expectedDurationInSeconds ) ) ;
125116 stopwatch . Stop ( ) ;
126117 var durationSeconds = stopwatch . Elapsed . TotalSeconds ;
127118
128- Assert . True ( durationSeconds < ( expectedDurationInSeconds + operationDurationInSeconds ) &&
129- durationSeconds >= expectedDurationInSeconds ) ;
119+ Assert . Multiple ( ( ) =>
120+ {
121+ Assert . Less ( durationSeconds , ( expectedDurationInSeconds + operationDurationInSeconds ) , "Elapsed time should be less than (js + operation) duration" ) ;
122+ Assert . GreaterOrEqual ( durationSeconds , expectedDurationInSeconds , "Elapsed time should be greater or equal than js duration" ) ;
123+ } ) ;
130124 }
131125
132126 [ Test ]
133127 public void Should_BePossibleTo_ExecuteAsyncJavaScript_WithScriptTimeoutException ( )
134128 {
135- var url = new DynamicContentForm ( ) . Url ;
136- var browser = BrowserManager . Browser ;
137- browser . GoTo ( url ) ;
138- browser . WaitForPageToLoad ( ) ;
139-
129+ new DynamicContentForm ( ) . Open ( ) ;
140130 var expectedDurationInSeconds = Configuration . Instance . TimeoutConfiguration . Script . TotalSeconds + 1 ;
141- Assert . Throws < WebDriverTimeoutException > ( ( ) => browser . ExecuteAsyncScript ( GetAsyncTimeoutJavaScript ( expectedDurationInSeconds ) ) ) ;
131+ Assert . Throws < WebDriverTimeoutException > ( ( ) => BrowserManager . Browser . ExecuteAsyncScript ( GetAsyncTimeoutJavaScript ( expectedDurationInSeconds ) ) ) ;
142132 }
143133
144134 private string GetAsyncTimeoutJavaScript ( double expectedDurationInSeconds )
145135 {
146- return "window.setTimeout(arguments[arguments.length - 1], " + expectedDurationInSeconds * 1000 + " );";
136+ return $ "window.setTimeout(arguments[arguments.length - 1], { expectedDurationInSeconds * 1000 } );";
147137 }
148138
149139 [ Test ]
150140 public void Should_BePossibleTo_ExecuteJavaScriptFromFile ( )
151141 {
152- var url = new DynamicContentForm ( ) . Url ;
153- var browser = BrowserManager . Browser ;
154- browser . GoTo ( url ) ;
155- browser . WaitForPageToLoad ( ) ;
156- var currentUrl = browser . ExecuteScriptFromFile < string > ( "Resources.GetCurrentUrl.js" ) ;
157- Assert . AreEqual ( url , currentUrl ) ;
142+ var dynamicContentForm = new DynamicContentForm ( ) ;
143+ dynamicContentForm . Open ( ) ;
144+ var currentUrl = BrowserManager . Browser . ExecuteScriptFromFile < string > ( "Resources.GetCurrentUrl.js" ) ;
145+ Assert . AreEqual ( dynamicContentForm . Url , currentUrl ) ;
158146 }
159147
160148 [ Test ]
@@ -220,12 +208,11 @@ public void Should_BePossibleTo_GetBrowserName()
220208 Assert . AreEqual ( browserName , BrowserManager . Browser . BrowserName ) ;
221209 }
222210
223- [ Ignore ( "Need to fix on Azure" ) ]
224211 [ Test ]
225212 public void Should_BePossibleTo_SetImplicitWait ( )
226213 {
227214 var browser = BrowserManager . Browser ;
228- browser . GoTo ( new WelcomeForm ( ) . Url ) ;
215+ new WelcomeForm ( ) . Open ( ) ;
229216 var waitTime = TimeSpan . FromSeconds ( 5 ) ;
230217 browser . SetImplicitWaitTimeout ( waitTime ) ;
231218
@@ -241,8 +228,8 @@ public void Should_BePossibleTo_SetImplicitWait()
241228 }
242229 Assert . Multiple ( ( ) =>
243230 {
244- Assert . IsTrue ( elapsedTime < waitTime + TimeSpan . FromSeconds ( 2 ) ) ;
245- Assert . IsTrue ( elapsedTime >= waitTime ) ;
231+ Assert . Less ( elapsedTime , waitTime + TimeSpan . FromSeconds ( 2 ) , "Elapsed time should be less than implicit timeout + 2 sec(accuracy)" ) ;
232+ Assert . GreaterOrEqual ( elapsedTime , waitTime , "Elapsed time should be greater or equal than implicit timeout" ) ;
246233 } ) ;
247234 }
248235
0 commit comments