A
A
AlpoDenis2018-04-14 00:27:37
PHP
AlpoDenis, 2018-04-14 00:27:37

Can ChromeOption be set to save the file?

$options = (new ChromeOptions)
          ->addArguments(['
                    '--headless', 
                   '--no-sandbox',
                    '--disable-gpu', 
                    '--disable-popup-blocking', 
                    '--window-size=1366,768'
            ])->setExperimentalOption('prefs', [
               'download.directory_upgrade' => true,
                'download.prompt_for_download' => false,
                'download.default_directory' =>  public_path().'/ugj',
                'browser.set_download_behavior' => [ 'behavior' => 'allow'],
               'safebrowsing.enabled'=>true,
            ]);

            $this->browser = new Browser(
                RemoteWebDriver::create(
                    'http://localhost:4444/wd/hub',
                    DesiredCapabilities::chrome()
                        ->setCapability(ChromeOptions::CAPABILITY, $options)
                        ->setCapability(WebDriverCapabilityType::BROWSER_NAME, 'chrome')
                )
            );

An example of selenium in the background comes to a specific url.
clicks on the save file button.
and the file should be saved, but no..
if you remove Arguments = '--headless'
, the user will see chrome and the file will be saved to the right place..
is it possible to combine this somehow? The settings I tried above didn't help...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dimonchik, 2018-04-14
@dimonchik2013

this is a known bug, so in 2017
download curl or make a request for a file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question