This repository was archived by the owner on Mar 4, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -373,7 +373,14 @@ public function takeScreenshot($save_as = null)
373373 $ screenshot = base64_decode (
374374 $ this ->execute (DriverCommand::SCREENSHOT )
375375 );
376+
376377 if ($ save_as ) {
378+ $ directoryPath = dirname ($ save_as );
379+
380+ if (!file_exists ($ directoryPath )) {
381+ mkdir ($ directoryPath , 0777 , true );
382+ }
383+
377384 file_put_contents ($ save_as , $ screenshot );
378385 }
379386
Original file line number Diff line number Diff line change @@ -257,7 +257,8 @@ public function testShouldSaveScreenshotToFile()
257257 $ this ->markTestSkipped ('Screenshots are not supported by HtmlUnit browser ' );
258258 }
259259
260- $ screenshotPath = sys_get_temp_dir () . '/selenium-screenshot.png ' ;
260+ // Intentionally save screenshot to subdirectory to tests it is being created
261+ $ screenshotPath = sys_get_temp_dir () . '/ ' . uniqid ('php-webdriver- ' ) . '/selenium-screenshot.png ' ;
261262
262263 $ this ->driver ->get ($ this ->getTestPageUrl ('index.html ' ));
263264
@@ -270,6 +271,7 @@ public function testShouldSaveScreenshotToFile()
270271 $ this ->assertGreaterThan (0 , imagesy ($ image ));
271272
272273 unlink ($ screenshotPath );
274+ rmdir (dirname ($ screenshotPath ));
273275 }
274276
275277 /**
You can’t perform that action at this time.
0 commit comments