laravel黄昏facebook网站驱动程序和cookie

时间:2018-08-10 21:00:31

标签: selenium-webdriver webdriver laravel-dusk

我正尝试使用Facebook chrome驱动程序登录网站 然后登录后访问网站的其他路径

登录成功,但是当我尝试查看其他页面时 它不识别我的登录名 这是我的代码:

$process = (new ChromeProcess)->toProcess();
    $process->start();
    $options = (new ChromeOptions)->addArguments(['--disable-gpu', '--headless','--enable-file-cookies','--disable-web-security','--allow-file-access-from-files']);
    $capabilities = DesiredCapabilities::chrome()->setCapability(ChromeOptions::CAPABILITY, $options);

    $driver = retry(5, function () use ($capabilities) {
        return RemoteWebDriver::create('http://localhost:9515', $capabilities);
    }, 50);
$browser = new Browser($driver);
        $browser::$baseUrl = 'https://example.com';
        $browser->visit('/login')
        ->type('username','1375344')
        ->type('password','23444')
        ->press('.login_btn');
        $browser->waitForText('welcome');
        $browser->visit('/statement/deposit/view');
        $browser->dump();

laravel黄昏和/或facebook驱动程序是否有cookiejar之类的东西?

1 个答案:

答案 0 :(得分:0)

尝试

$browser->loginAs(User::find(1));

此外,您可以查看

Dusk Authentication