Reputation: 608
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 Selenium::Remote::Driver
. I got code for Java but not in Perl for this task.
Upvotes: 3
Views: 1195
Reputation: 390
I had troubles understanding the difference mentioned between Selenium::Chrome
and Selenium::Remote::Driver
. Here's what I got to work:
my $driver = Selenium::Chrome->new(
extra_capabilities => {
'goog:chromeOptions' => {
prefs => {
'download.default_directory' => '/tmp'
},
args => [ 'window-size=1950,500' ]
}
}
);
Upvotes: 0
Reputation: 21666
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.
Upvotes: 2