【问题标题】:Download a file in Selenium Grid through Robot Framework Test通过 Robot Framework Test 在 Selenium Grid 中下载文件
【发布时间】:2018-02-19 18:53:29
【问题描述】:
${options}= Call Method ${chrome_options} to_capabilities
Create Webdriver Remote command_executor=${REMOTE_URL} desired_capabilities=${options}
Go To ${url}
获取测试的节点 IP 和 SCP 文件的可能解决方案之一。
有没有办法我可以在 Robot Framework 中获取节点详细信息。
【问题讨论】:
标签:
robotframework
selenium-grid
【解决方案1】:
我为此使用了一个有趣的解决方法。在我的套件设置中:
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}
在我的测试拆解中,我需要清空 mi 下载目录:
Run Keyword And Ignore Error Empty Directory ${global_downloadDir}
然后我设置了两个关键字:
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}
所以现在,使用等待文件下载完成关键字应该返回您的文件名:
Click Button id=downloadFile
${filename} = Wait Until File Download is Finished
${content} = Get File ${fileName}