Download pdf from new tab no href

hello everyone , I’m new to UiPath , what I’m trying to do is to dwonload pdf files .

, i have a table with list of links, every link leads to a details page of a consignment note so i looped through it

, in the consignment details page there is a ‘print’ button

, when the button
clicked it will open a new tab with the pdf file

, my issue is i tried the activity Get Attribute to get the href
but i couldn’t fined it , it seems like every time i click the button a new link is generated
is there any way i can get the link of the new page or to open it every time the button ‘print’ got clicked?

Step 1: Handle the New Tab

After clicking the print button, the PDF might be generated and displayed in a new tab. Here’s how you can handle it:

  1. Switch to New Tab: Use the “Attach Browser” or “Use Browser” activity with a dynamic selector to switch to the new tab where the PDF is displayed. Identifying the new tab might require you to use wildcard (*) characters in the selector or use the browser’s window title if it’s known.
  2. Wait for PDF to Load: Use the “Find Element” activity to wait for the PDF to be fully loaded in the browser. You might need to look for a specific element indicative of the PDF load completion.

Step 2: Download the PDF

The method to download the PDF can vary depending on how the PDF is displayed in the browser:

  • Direct Download: If the browser displays a download option for the PDF, you can use the “Click” activity to click the download button.
  • Keyboard Shortcuts: If the browser or PDF viewer supports keyboard shortcuts for downloading, you can use the “Send Hotkey” activity to send the appropriate keystroke combination (e.g., Ctrl + S) to save the PDF file.
  • Print to PDF: If direct download options are not available, you might need to simulate printing the PDF and selecting “Save as PDF” as the printer, using a series of “Click” and “Type Into” activities to navigate the print dialog.

Let’s break down the steps to resolve this issue:

  1. Monitor Events or Infinite Loop:
  • If your process is attended (you’re monitoring it), consider using Monitor Events. Otherwise, you can run an infinite loop with a specific exit condition for exceptional scenarios.
  • In the loop, open the webpage and check for the presence of the “DDMMYY” file name element. If it exists and matches your condition, proceed to download it.
  1. Identify the Download Button:
  • First, ensure that you’ve reached the page with the “print” button.
  • If there’s a download button that opens the “Save As” window, simply click on it. You can then handle the “Save As” window to save the file locally.
  1. Dynamic File Name:
  • Since the file name changes daily (based on the current date), you’ll need to extract the date dynamically.
  • Use activities like Data Scraping or Screen Scraping to extract the date from the webpage. Store it in a variable.
  1. Type Into Activity:
  • Once you have the date, use the Type Into activity to input the date into the “Save As” window.
  • Make sure to handle any variations in the window (such as different field names or controls).
  1. Download the File:
  • After setting the file name, proceed to download it.
  • If there’s a specific download link, you can use the Click activity to trigger the download.
  • If the download process involves additional steps (such as selecting a folder), handle those as well.
  1. Repeat the Process:
  • Finally, repeat the entire process to monitor the page for new files.
  • Adjust the loop or monitoring mechanism to check for the updated file link regularly.

Remember to adapt these steps to your specific scenario, considering whether your bot runs attended or unattended, and whether it’s a browser-based application. If you encounter any further issues, feel free to ask! :robot::+1: