Mohit Mohit - 5 months ago 32
Perl Question

Changing default download directory in Chrome Webdriver

Can anyone let me know how can I change the default download location for Chrome using Selenium-Perl. I am using Chrome Webdriver and the Perl module

. I got code for Java but not in Perl for this task.


I do not have the test setup but passing below as desired_capabilities or extra_capabilities to the constructor should work fine.

'download.default_directory', 'C:\New_Folder'

Snippet (untested):

my $driver = Selenium::Remote::Driver->new(
    'browser_name' =>'chrome',
    'extra_capabilities' => {
        'chromeOptions' => {
            'prefs' => {
                'download.default_directory' => 'C:\New_Folder'

Edit: Difference between Selenium::Chrome and Selenium::Remote::Driver

Selenium::Chrome allows you to use the ChromeDriver without needing the JRE or a selenium server running. If the ChromeDriver binary is not found, it falls back to the default Selenium::Remote::Driver.