I've managed to locate the correct element on the web page and I can click it. I see the download prompt come up, asking me whether I should open the pdf, open it in Firefox, or save it.
My code looks like this:
my $profile = Selenium::Firefox::Profile->new;
$profile->set_preference(
"browser.download.dir" => "/Users/john/Downloads",
"browser.download.folderList" => "1",
"browser.helperapps.neverAsk.SaveToDisk" => "application/pdf"
);
my $driver = Selenium::Firefox->new(
'binary' => "/usr/local/bin/geckodriver",
'firefox_profile' => $profile
);
[...]
$driver->find_child_element($driver->find_element_by_id('secHead_1'), "./a[\@class='phoDirFont']")->click();
My understanding is that if I've set up the correct preferences, then this file would save without the prompt. That's not happening though. I've dug down into it with dev tools, and it does seem to be serving up the pdf file with "application/pdf" as the mime-type. Firefox certainly recognizes it as one (offering to open it in Firefox, not just with the registered app).
If there is another method (perhaps by sending keystrokes to the prompts), that would be acceptable too. Though I've been using Firefox (trying to get away from Google products in my personal life), if Chrome would make a difference I could switch to that instead.
Looking at my about:config (with the Selenium-opened window), the preferences settings seem to have taken. However, it still prompts for the file.