ivanmiranda

ivanmiranda

Member Since 3 Months Ago

Experience Points 220
Experience Level 1

4,780 experience to go until the next level!

In case you were wondering, you earn Laracasts experience when you:

  • Complete a lesson — 100pts
  • Create a forum thread — 50pts
  • Reply to a thread — 10pts
  • Leave a reply that is liked — 50pts
  • Receive a "Best Reply" award — 500pts
Lessons Completed 0
Lessons
Completed
Best Reply Awards 0
Best Reply
Awards
  • start-engines Created with Sketch.

    Start Your Engines

    Earned once you have completed your first Laracasts lesson.

  • first-thousand Created with Sketch.

    First Thousand

    Earned once you have earned your first 1000 experience points.

  • 1-year Created with Sketch.

    One Year Member

    Earned when you have been with Laracasts for 1 year.

  • 2-years Created with Sketch.

    Two Year Member

    Earned when you have been with Laracasts for 2 years.

  • 3-years Created with Sketch.

    Three Year Member

    Earned when you have been with Laracasts for 3 years.

  • 4-years Created with Sketch.

    Four Year Member

    Earned when you have been with Laracasts for 4 years.

  • 5-years Created with Sketch.

    Five Year Member

    Earned when you have been with Laracasts for 5 years.

  • school-session Created with Sketch.

    School In Session

    Earned when at least one Laracasts series has been fully completed.

  • welcome-newcomer Created with Sketch.

    Welcome To The Community

    Earned after your first post on the Laracasts forum.

  • full-time-student Created with Sketch.

    Full Time Learner

    Earned once 100 Laracasts lessons have been completed.

  • pay-it-forward Created with Sketch.

    Pay It Forward

    Earned once you receive your first "Best Reply" award on the Laracasts forum.

  • subscriber-token Created with Sketch.

    Subscriber

    Earned if you are a paying Laracasts subscriber.

  • lifer-token Created with Sketch.

    Lifer

    Earned if you have a lifetime subscription to Laracasts.

  • lara-evanghelist Created with Sketch.

    Laracasts Evangelist

    Earned if you share a link to Laracasts on social media. Please email [email protected] with your username and post URL to be awarded this badge.

  • chatty-cathy Created with Sketch.

    Chatty Cathy

    Earned once you have achieved 500 forum replies.

  • lara-veteran Created with Sketch.

    Laracasts Veteran

    Earned once your experience points passes 100,000.

  • 10k-strong Created with Sketch.

    Ten Thousand Strong

    Earned once your experience points hits 10,000.

  • lara-master Created with Sketch.

    Laracasts Master

    Earned once 1000 Laracasts lessons have been completed.

  • laracasts-tutor Created with Sketch.

    Laracasts Tutor

    Earned once your "Best Reply" award count is 100 or more.

  • laracasts-sensei Created with Sketch.

    Laracasts Sensei

    Earned once your experience points passes 1 million.

  • top-50 Created with Sketch.

    Top 50

    Earned once your experience points ranks in the top 50 of all Laracasts users.

01 May
3 months ago

ivanmiranda left a reply on Laravel Dusk Tests Failing

It is supposed to upload an item on ebay to sell it. I was just with the beginning. The code is this:

<?php

namespace Tests\Browser;

use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;

class ExampleTest extends DuskTestCase
{
    /**
     * A basic browser test example.
     *
     * @return void
     */
    public function testBasicExample()
    {
        $this->browse(function (Browser $browser) {

            $browser->visit('https://www.ebay.es/')
                    ->assertSeeLink('Identifícate')
                    ->clickLink('Identifícate')
                    ->type('userid', 'mail')
                    ->type('pass', 'pass')
                    ->click('#sgnBt');
        });
    }
}

ivanmiranda started a new conversation Laravel Dusk Tests Failing

Hello,

I'm developing an app and I was interested in Laravel Dusk's tests functionality to automatize some tasks, but running the tests I've realised that they work poorly 1 of 10 average, more or less. The usual exception that dumps into the screen is this:


Warning: TTY mode is not supported on Windows platform.
PHPUnit 7.5.7 by Sebastian Bergmann and contributors.


DevTools listening on ws://127.0.0.1:61761/devtools/browser/dc039dbb-c23a-4866-b
8cc-8c0a9be5e32e
E                                                                   1 / 1 (100%)

Time: 1.7 minutes, Memory: 16.00 MB

There was 1 error:

1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http
GET to /session/e2eeb262cfbb9b5ebbd2aaff134b9ab7/screenshot

Operation timed out after 30000 milliseconds with 0 bytes received

C:\xampp\htdocs\k24\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php
:292
C:\xampp\htdocs\k24\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:547
C:\xampp\htdocs\k24\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:345
C:\xampp\htdocs\k24\vendor\laravel\dusk\src\Browser.php:274
C:\xampp\htdocs\k24\vendor\laravel\dusk\src\Concerns\ProvidesBrowser.php:139
C:\xampp\htdocs\k24\vendor\laravel\framework\src\Illuminate\Support\Collection.p
hp:419
C:\xampp\htdocs\k24\vendor\laravel\dusk\src\Concerns\ProvidesBrowser.php:140
C:\xampp\htdocs\k24\vendor\laravel\dusk\src\Concerns\ProvidesBrowser.php:69
C:\xampp\htdocs\k24\tests\Browser\ExampleTest.php:44

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.


I've tried with pause() method and making several assertions in order to give the server more time to respond, but with no luck. I'm thinking about making an approach with jQuery. Anyone that has been dealing with Dusk would know about this? Or jQuery? Thanks.

ivanmiranda left a reply on Laravel Dusk Example Test Failing - Can't Load URL

Thanks for the info @diegoaurino. I didn't know these details about Apache configuration. Finally, the 404 not found was being thrown because there was some security measure that didn't allow the test to go ahead. Fixing that it's working now.

Thanks again!

29 Apr
3 months ago

ivanmiranda left a reply on Artisan::call('dusk') Not Working. Undefined Index: Argv Thrown

In case someone is interested: you have several ways to fix this.

Firstly, you have here a similar discussion that finally ends up using Symfony processes: https://laracasts.com/discuss/channels/testing/invoking-the-artisan-dusk-command-outside-the-cli?page=1#reply=507904

You can also do, as I did, this little hack:

        $pathToArtisan = 'C:\xampp\htdocs\k24';
        
        echo exec("cd $pathToArtisan && php artisan dusk");

ivanmiranda left a reply on Invoking The Artisan Dusk Command Outside The CLI

I've been following this discussion cause I was interested in doing something similar. I've tried this and also seems to work:

        $pathToArtisan = 'C:\xampp\htdocs\k24';
        
        echo exec("cd $pathToArtisan && php artisan dusk");

In case it helps.

ivanmiranda started a new conversation Artisan::call('dusk') Not Working. Undefined Index: Argv Thrown

Hello everyone,

I am developing a Laravel app and I trying to introduce some automations using Laravel Dusk. The thing is that I've followed all the instructions pointed on Laravel Docs and this is still failing. I've registered DuskServiceProvider on AppServiceProvider class (by the way, I couldn't find this on the official docs) and I even put the DuskCommand class on kernel's commands protected property, but with no luck.

I'm calling Artisan::call('dusk') from one of my controllers but the tests are not executed. I've retrieved the Artisan::call method response and it prints out 1. The error that I'm facing is 'Undefined index: argv' on the DuskCommand class.

I've also read that this is achievable with Symfony, but I wonder why Artisan::call is not working here. According to official docs:

Sometimes you may wish to execute an Artisan command outside of the CLI. For example, you may wish to fire an Artisan command from a route or controller. You may use the call method on the Artisan facade to accomplish this. The call method accepts either the command's name or class as the first argument, and an array of command parameters as the second argument

My Kernel class:

<?php

namespace App\Console;

use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use Laravel\Dusk\Console\DuskCommand;
use Laravel\Dusk\Console\DuskFailsCommand;

class Kernel extends ConsoleKernel
{
    /**
     * The Artisan commands provided by your application.
     *
     * @var array
     */
    protected $commands = [
        DuskCommand::class, DuskFailscommand::class
    ];

    /**
     * Define the application's command schedule.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    protected function schedule(Schedule $schedule)
    {
        // $schedule->command('inspire')
        //          ->hourly();
    }

    /**
     * Register the commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        $this->load(__DIR__.'/Commands');

        require base_path('routes/console.php');
    }
}

The DuskServiceProvider class

<?php

namespace Laravel\Dusk;

use Exception;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;

class DuskServiceProvider extends ServiceProvider
{
    /**
     * Bootstrap any package services.
     *
     * @return void
     */
    public function boot()
    {
        Route::get('/_dusk/login/{userId}/{guard?}', [
            'middleware' => 'web',
            'uses' => 'Laravel\Dusk\Http\Controllers\[email protected]',
        ]);

        Route::get('/_dusk/logout/{guard?}', [
            'middleware' => 'web',
            'uses' => 'Laravel\Dusk\Http\Controllers\[email protected]',
        ]);

        Route::get('/_dusk/user/{guard?}', [
            'middleware' => 'web',
            'uses' => 'Laravel\Dusk\Http\Controllers\[email protected]',
        ]);
    }

    /**
     * Register any package services.
     *
     * @return void
     * @throws Exception
     */
    public function register()
    {
        if ($this->app->environment('production')) {
            throw new Exception('It is unsafe to run Dusk in production.');
        }

            $this->commands([
                Console\InstallCommand::class,
                Console\DuskCommand::class,
                Console\DuskFailsCommand::class,
                Console\MakeCommand::class,
                Console\PageCommand::class,
                Console\ComponentCommand::class,
            ]);
        
    }
}

And the AppServiceProvider:

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema; 
use Laravel\Dusk\DuskServiceProvider;
use Laravel\Dusk\Console\DuskCommand;
use Laravel\Dusk\Console\MakeCommand;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->register(DuskServiceProvider::class);
        $this->commands(DuskCommand::class);
        $this->commands(MakeCommand::class);
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191);
    }
}

Thanks!!

ivanmiranda left a reply on Laravel Dusk Example Test Failing - Can't Load URL

@DIEGOAURINO - Hello @diegoaurino Not sure how to accomplish what you say about DocumentRoot. Do you mean that the server has to point to the public folder of my app? And in that case, how can I do that? Thanks again.

28 Apr
3 months ago

ivanmiranda left a reply on Laravel Dusk Example Test Failing - Can't Load URL

@diegoaurino Hello again,

I think I've explained myself a bit wrong. With http://localhost/etc, I just meaned that server runs only on http://localhost (main root) and etc represents the rest of routes, like for example http://localhost/public/shows/display. So APP_URL is fine as far as I know. My OS is Windows 10 Professional and the app is perfectly working for the purpose it has. Problems are just happening with Dusk. However, I managed this to work with https:// routes at least. But problems are still thrown on app local routes. I show an example:


<?php

namespace Tests\Browser;

use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;

class ExampleTest extends DuskTestCase
{
    /**
     * A basic browser test example.
     *
     * @return void
     */
    public function testBasicExample()
    {
        $this->browse(function (Browser $browser) {

            $browser->visit('/k24/public')
                    ->assertSee('Login');
            // $browser->visit('https://www.google.com/intl/es/gmail/about/#')
            //         ->assertSee('Iniciar sesión')
            //         ->clickLink('Iniciar sesión')
        });
    }
}

Here response by Artisan CLI is:


Warning: TTY mode is not supported on Windows platform.
PHPUnit 7.5.7 by Sebastian Bergmann and contributors.


DevTools listening on ws://127.0.0.1:52915/devtools/browser/53c53e40-b810-4f33-a772-1604f807e902
E                                                                   1 / 1 (100%)

Time: 33.86 seconds, Memory: 14.00 MB

There was 1 error:

1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session/ec5106b07b670aff07ce240966ef166f/url with params: {"url":"http:\/\/localhost\/\/k24\/public"}

Operation timed out after 30000 milliseconds with 0 bytes received

C:\xampp\htdocs\k24\vendor\facebook\webdriver\lib\Remote\HttpCommandExecutor.php:292
C:\xampp\htdocs\k24\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:547
C:\xampp\htdocs\k24\vendor\facebook\webdriver\lib\Remote\RemoteExecuteMethod.php:40
C:\xampp\htdocs\k24\vendor\facebook\webdriver\lib\WebDriverNavigation.php:85
C:\xampp\htdocs\k24\vendor\laravel\dusk\src\Browser.php:138
C:\xampp\htdocs\k24\tests\Browser\ExampleTest.php:20
C:\xampp\htdocs\k24\vendor\laravel\dusk\src\Concerns\ProvidesBrowser.php:67
C:\xampp\htdocs\k24\tests\Browser\ExampleTest.php:26

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.


And on screenshots login is perfectly shown, so I'm unable to find out why local routes are not responding as they should.

Respect to your question, @bobbybouwmann, thanks in advance for answering. I had your same thought about why Facebook is appearing here, but it seems that ChromeDriver used by Laravel Dusk is related some how with Facebook. You can check that here, on vendor folder, for example:


namespace Facebook\WebDriver\Chrome;

use Facebook\WebDriver\Exception\WebDriverException;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\DriverCommand;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\Service\DriverCommandExecutor;
use Facebook\WebDriver\Remote\WebDriverCommand;

class ChromeDriver extends RemoteWebDriver

And my setup on .env file looks like this:


APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:0mia4GPUbDTzkIXMrGT2aqxP6EocNiMWlmcspoMhQ4E=
APP_DEBUG=true
APP_URL=http://localhost/

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=kontollarte_beta
DB_USERNAME=root
DB_PASSWORD=''

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=dcebf6fe5611e6
MAIL_PASSWORD=688eabce7e7d21
MAIL_ENCRYPTION=null

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

I know passwords on mysql config should be different from default, but this is just testing environment. Thanks for helping guys.

27 Apr
3 months ago

ivanmiranda left a reply on Laravel Dusk Example Test Failing - Can't Load URL

Hey @diegoaurino, thanks for the response, in advance.

Yes, APP_URL is set to http://localhost and i'm using a local web server. I've acheived to get it work with https routes on $browser->visit() method, but it's still throwing errors with the app routes. I've checked the error screenshots and a 404 not found is thrown for practically all routes.

ivanmiranda started a new conversation Laravel Dusk Example Test Failing - Can't Load URL

Hello everyone,

Here is my problem: i'm trying to develop a piece of code with Laravel Dusk that allows me to automatize a few tasks on Chrome browser. However, despite of applying correctly all the documentation steps, ExampleTest.php file is throwing this error:

 "No se puede cargar la URL: El dominio de esta URL no está incluido en los dominios de la aplicación. Para poder cargar esta URL, añade todos los dominios y subdominios de tu a
plicación al campo de dominios de la aplicación en la configuración de tu aplicación."

It seems, according with what forums says on the internet, that Facebook security rules have become tighter and more restrictive, using only oauth URL's. One of the solutions it is supposed to be include all the domains of your app in Facebook app configuration panel, but my question is: i'm running this locally, which means my url's at the moment are http://localhost/etc.

This is really bothering me. Anybody could help, please? Thanks in advance.

Leave some pics of the code:

<?php

namespace Tests\Browser;

use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;

class ExampleTest extends DuskTestCase
{
    /**
     * A basic browser test example.
     *
     * @return void
     */
    public function testBasicExample()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/')
                    ->assertSee('Laravel');
        });
    }
}

And in AppServiceProvider i've also included:

<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Schema; 
use Laravel\Dusk\DuskServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        $this->app->register(DuskServiceProvider::class);
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
        Schema::defaultStringLength(191);
    }
}