0
${options}=     Call Method     ${chrome_options}    to_capabilities 
Create Webdriver    Remote   command_executor=${REMOTE_URL}   desired_capabilities=${options}
Go To    ${url}

One of the possible solutions to get the Node IP of the Test and SCP the file. Is there a way i can get the Node details in Robot Framework.

A. Kootstra
  • 6,827
  • 3
  • 20
  • 43
tsk
  • 1
  • 1
  • 1

2 Answers2

3

I use an interesting workaround for this. In my suite setup:

Set Global Variable    ${global_downloadDir}    ${CURDIR}\\Downloads\\${suiteName}
${prefs} =    Create Dictionary    download.default_directory=${global_downloadDir}
Call Method    ${chromeOptions}    add_experimental_option    prefs    ${prefs}
Create Webdriver    Chrome    chrome_options=${chromeOptions}

In my test teardown I need to empty mi download directory:

Run Keyword And Ignore Error    Empty Directory    ${global_downloadDir}

Then I have set of two keywords:

Download Should Be Done
    [Arguments]    ${directory}=${global_downloadDir}
    [Documentation]    Verifies that the directory has only one folder and it is not a temp file and returns path to the file
    ${files} =    List Files In Directory    ${directory}
    Length Should Be    ${files}    1
    Should Not Match Regexp    ${files[0]}    (?i).*\\.tmp
    Should Not Match Regexp    ${files[0]}    (?i).*\\.crdownload
    ${file}    Join Path    ${directory}    ${files[0]}
    Log    File was successfully downloaded to ${file}
    [Return]    ${file}

Wait Until File Download is Finished
    [Arguments]    ${directory}=${global_downloadDir}    ${timeout}=${global_timeout}    ${retry}=2s
    ${fileName} =    Wait Until Keyword Succeeds    ${timeout}    ${retry}    Download should be done    ${directory}
    [Return]    ${fileName}

So now, using the Wait Until File Download is Finished keyword should return your filename:

Click Button    id=downloadFile
${filename} =    Wait Until File Download is Finished
${content} =    Get File    ${fileName}
Lubos Jerabek
  • 813
  • 4
  • 18
0

If the file is what you're after, then I'd map a shared drive/folder to the executing node and then have Chrome store the file there. This will work well if the file has a unique file name that won't conflict with other tests storing files in the same location.

An alternative approach is uses the hostname or the IP as a unique node identifier. Getting the hostname is described in this StackOverflow answer for the question: How to display/log which node ran Selenium test session?. The principle behind this code is best explained in this StackOverflow answer.

In case you're also running a headless Chrome on your grid and want to download files to a specific directory, then this StackOverflow answer will provide you with the necessary Python and Robot code to achieve it as this isn't supported natively.

A. Kootstra
  • 6,827
  • 3
  • 20
  • 43