@@ -145,6 +145,7 @@ public function testShouldCloseWindow()
145145
146146 /**
147147 * @covers ::executeScript
148+ * @group exclude-saucelabs
148149 */
149150 public function testShouldExecuteScriptAndDoNotBlockExecution ()
150151 {
@@ -153,17 +154,18 @@ public function testShouldExecuteScriptAndDoNotBlockExecution()
153154 $ element = $ this ->driver ->findElement (WebDriverBy::id ('id_test ' ));
154155 $ this ->assertSame ('Test by ID ' , $ element ->getText ());
155156
157+ $ start = microtime (true );
156158 $ this ->driver ->executeScript ('
157159 setTimeout(
158- function(){document.getElementById("id_test").innerHTML = "Text changed by script"},
159- 500
160+ function(){document.getElementById("id_test").innerHTML = "Text changed by script"; },
161+ 250
160162 ) ' );
163+ $ end = microtime (true );
161164
162- // Make sure the script don't block the test execution
163- $ this ->assertSame ('Test by ID ' , $ element ->getText ());
165+ $ this ->assertLessThan (250 , $ end - $ start , 'executeScript() should not block execution ' );
164166
165- // If we wait, the script should be executed
166- usleep (1000000 ); // wait 1000 ms
167+ // If we wait, the script should be executed and its value changed
168+ usleep (300000 ); // wait 300 ms
167169 $ this ->assertSame ('Text changed by script ' , $ element ->getText ());
168170 }
169171
@@ -180,6 +182,7 @@ public function testShouldExecuteAsyncScriptAndWaitUntilItIsFinished()
180182 $ element = $ this ->driver ->findElement (WebDriverBy::id ('id_test ' ));
181183 $ this ->assertSame ('Test by ID ' , $ element ->getText ());
182184
185+ $ start = microtime (true );
183186 $ this ->driver ->executeAsyncScript (
184187 'var callback = arguments[arguments.length - 1];
185188 setTimeout(
@@ -190,6 +193,13 @@ function(){
190193 250
191194 ); '
192195 );
196+ $ end = microtime (true );
197+
198+ $ this ->assertGreaterThan (
199+ 0.250 ,
200+ $ end - $ start ,
201+ 'executeAsyncScript() should block execution until callback() is called '
202+ );
193203
194204 // The result must be immediately available, as the executeAsyncScript should block the execution until the
195205 // callback is called.
@@ -204,7 +214,7 @@ public function testShouldTakeScreenshot()
204214 if (!extension_loaded ('gd ' )) {
205215 $ this ->markTestSkipped ('GD extension must be enabled ' );
206216 }
207- if ($ this ->desiredCapabilities ->getBrowserName () == WebDriverBrowserType::HTMLUNIT ) {
217+ if ($ this ->desiredCapabilities ->getBrowserName () === WebDriverBrowserType::HTMLUNIT ) {
208218 $ this ->markTestSkipped ('Screenshots are not supported by HtmlUnit browser ' );
209219 }
210220
@@ -227,7 +237,7 @@ public function testShouldSaveScreenshotToFile()
227237 if (!extension_loaded ('gd ' )) {
228238 $ this ->markTestSkipped ('GD extension must be enabled ' );
229239 }
230- if ($ this ->desiredCapabilities ->getBrowserName () == WebDriverBrowserType::HTMLUNIT ) {
240+ if ($ this ->desiredCapabilities ->getBrowserName () === WebDriverBrowserType::HTMLUNIT ) {
231241 $ this ->markTestSkipped ('Screenshots are not supported by HtmlUnit browser ' );
232242 }
233243
0 commit comments