Mohit Mohit - 1 year ago 127
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.

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download