title: selenium + java - how to download a pdf and save with a different name?
body: <p>As part of a work on an existing selenium test pack, I was asked to remove the instantiation of Firefox to download server-generated PDF documents - an authentication issue led to an agent config session error that prevented the documents from being downloaded.</p>
  <p>When the document is generated in the server, it can be accessed via a URL that contains a UUID. This URL was passed to a fresh instance of Firefox and the document could be downloaded.</p>
  <p>This selenium pack was thrown together <strong>NOT</strong> following the best practices of software development some 10 years ago. Though it worked, for the most part, its performance is quite poor.</p>
  <p>I can access the generated document on the server with the service URL plus the UUID as part of the path, as this is part of the document generation process. In the current workflow, there is a 'generate document' button that is clicked by the running pack.</p>
  <p>Once this document is generated, I need to download it to a specific folder and rename it to serve as proof the process has been completed to satisfaction.</p>
  <p>I searched a lot and found a few articles that gave me insights into parts of the issue, but could not put together a working solution.</p>
  <p>I can start chrome driver in headless mode but haven't figured out how to download the document. Since the browser window displays the document itself, there is no clickable download button on the page.</p>
  <p>Can anyone point me to a solution here?</p>
  <p>Thanks in advance,</p>