The solution I found uses the chromeOptions.args capability to set a profile. I created a profile template with the correct setting. I used this profile as a template.
In the profile template directory there is a single file named Default/Preferences
with the contents:
{
"profile": {
"block_third_party_cookies": false
}
}
The perl test file looks something like:
use Selenium::Remote::Driver;
use File::Temp 'tempdir';
my $template_dir = '/path/to/template/dir/';
my $dirname = tempdir(
'chrome_user_data_XXXXXX',
DIR => '/tmp',
CLEANUP => 1,
);
system(qq|cp -a $template_dir/* $dirname|) == 0
or die("Could not copy $template_dir/* to $dirname");
my $driver = Selenium::Remote::Driver->new(
browser_name => 'chrome',
extra_capabilities => {
args => ["user-data-dir=$dirname"],
},
);