Keyword not working RPA.Browser.Selenium

Hi,

I am using RPA.Browser.Selenium library for web-automation, I had a task to download a file from a webpage and close the browser after download gets completed.

Now I wanted to download that file in a particular directory, so I used

Set Download Directory

but the problem is Set Download Directory is not resetting the default chrome download path to the specified path and everytime files are getting downloaded to the default Chrome download path i.e. C:\Users<user>\Downloads

Open page and Download latest package
    ${user}     OperatingSystem.Get Environment Variable    username
    ${package}    AXIS_PATH_pacakge
    Open Available Browser    <my_url>    maximized=True
    Set Download Directory    C:\\Users\\${user}\\NewFolder
    Click Link    //body//tr[last()-1]//td[2]//a   
    Click Link    //body//tr[last()-1]//td[2]//a   
    ${loc}    Get Location
    Go To    ${loc}SOLARIS_baseline.html 
    Click Link    xpath=//a[text()='${package}']
    Wait Until Created    C:\\Users\\${user}\\NewFolder\\${package}*.tpi

I am using VSCode with Robocorp extension

1 Like

I think you have to set the download directory before opening the browser.

2 Likes

Oh, that worked.
Thanks @erik.palen :blush:

2 Likes

I also want to add that this might not work for Firefox (tested on Linux).

I had to do this for Firefox:

  1. Add the geckodriver to Linux PATH;
  2. Initialize browser usingff_profile_dir:
Open Browser
    ...    ${url}
    ...    browser=firefox
    ...    options=add_argument("--start-maximized")
    ...    ff_profile_dir=set_preference("browser.download.folderList", 2);set_preference("browser.download.dir", r"${DOWNLOAD_DIR}");set_preference("browser.helperApps.neverAsk.saveToDisk", "application/zip")
1 Like