I am using the duncan3dc module in laravel, Successfully importing text from the default example But I do not know how to take a screenshot,
I just installed this module using Composer.
$ composer requires duncan3dc/dusk.
Does it mean that everything needed for this module is automatically installed?
Or do I need something else to take a screenshot?
Below is my controller code
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use duncan3dc\Laravel\Dusk;
class TestController extends Controller
{
public function test()
{
$dusk = new Dusk;
$dusk->visit("http://example.com");
$dusk->screenshot("ddd");
echo $dusk->element("h1")->getText() . "\n";
}
}
When I run the above code, I get this error:
file_put_contents (/tmp/ddd.png): failed to open stream: No such file or directory
I think there is no folder, so I get the error, where should I create the folder in the project folder?
According to the changelog from version
0.8.0you can pass fully qualified path toscreenshotmethod. So doing this will work (you should see the fileddd.pngcreated near the php file):You can also pass absolute path:
or