lundi 28 mars 2022

Unknown command in chromedriver

I'm working on a PHP project and using dusk to conduct tests (OS: Ubuntu 20). When I run the chromedriver on Linux and navigate to any URL, I am getting an unexpected error. For example, the next error happens when I navigate to localhost:9515/logo.png:

{ "value":
    { "error":"unknown command",
      "message":"unknown command: unknown command: logo.png",
      "stacktrace":"#0 0x5561bf5e33e3 \u003Cunknown>\n#1 0x5561bf348468 \u003Cunknown>\n#2 0x5561bf3991de \u003Cunknown>\n#3 0x5561bf398f57 \u003Cunknown>\n#4 0x5561bf31f634 \u003Cunknown>\n#5 0x5561bf32044a \u003Cunknown>\n#6 0x5561bf60ff56 \u003Cunknown>\n#7 0x5561bf6272ad \u003Cunknown>\n#8 0x5561bf611dae \u003Cunknown>\n#9 0x5561bf627c34 \u003Cunknown>\n#10 0x5561bf605be2 \u003Cunknown>\n#11 0x5561bf31f206 \u003Cunknown>\n#12 0x7f5f2c10d0b3 \u003Cunknown>\n"}}

The problem is that dusk also navigates to webpages and instead of getting the HTML contents, it's getting the same error.

I'm completely stumped at two things. First, why does there seem to be a recursion of unknown commands (it's as if the unknown command itself is the unknown command)? Second, why is the unknown command pointing at the URL, or the file?

Things I have tried:

  • I have already re-installed chromedriver
  • I have confirmed that the version of the chromedriver is the same as the Chrome and Chromium versions (99)
  • I have tried launching the chromedriver myself and using Laravel dusk, but the outcome remains the same

I would appreciate any help.


EDIT: This is my DuskTestCase.php file, which I haven't really changed:

<?php

namespace Tests;

use Laravel\Dusk\TestCase as BaseTestCase;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;

abstract class DuskTestCase extends BaseTestCase
{
    use CreatesApplication;

    /**
     * Prepare for Dusk test execution.
     *
     * @beforeClass
     * @return void
     */
    public static function prepare()
    {
        static::startChromeDriver();
    }

    /**
     * Create the RemoteWebDriver instance.
     *
     * @return \Facebook\WebDriver\Remote\RemoteWebDriver
     */
    protected function driver()
    {
        $options = (new ChromeOptions)->addArguments([
            '--disable-gpu',
            '--headless'
        ]);

        return RemoteWebDriver::create(
            'http://127.0.0.1:9515', DesiredCapabilities::chrome()->setCapability(
                ChromeOptions::CAPABILITY, $options
            )
        );
    }
}

And this is the test:

<?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('/') // also experimented with localhost and 127.0.0.1 (with ports), but no change
                    // ->pause(2000)
                    ->assertSee('Sign In');
        });
    }
}

In the environment file, I have set APP_URL=http://127.0.0.1:9515.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/qb4WlD5
via IFTTT

Aucun commentaire:

Enregistrer un commentaire