实践中需要下载文件到目标目录。Selenium关键词中对此没有很好的支持。
经过学习前人经验,得出方法,可以通过wget直接获取文件。此前,需要拿到被测系统的cookie信息。
最终方案如下,
1)Linux系统
Download Congiuration File
[Arguments] ${cookiename}
${cookievalue} Get Cookie Value ${cookiename}
${rc} Execute Command wget --cookies=on --header "Cookie: ${cookiename}=${cookievalue}" -O /xxx/yyy/zzz.conf http://${${test_env}.server}/api/v1/zzz/ return_stdout=False return_rc=True
Should Be Equal As Integers 0 ${rc}
2)Windows 系统
Robot Framework.OperatingSystem.Run_And_Return_Rc + PowerShell
尚未实践。
参考:
https://blog.youkuaiyun.com/hchaoh/article/details/69390483
https://blog.codecentric.de/en/2010/07/file-downloads-with-selenium-mission-impossible/