使用Robot Framework从网页接收HTML源代码
我想用Robot Framework获取网页的HTML源代码。但是我不想用Selenium2Library,因为它会打开一个网页浏览器,耗时很长。
你能推荐我一些Robot Framework的库吗?我可以用Python写自己的库,像用urllib2之类的,但我觉得应该有更合适的解决方案。
1 个回答
3
你可以使用requests库,这个库是基于Python的requests库,用来从网上获取资源。
*** Settings ***
| Library | RequestsLibrary
| Suite Setup | Create Session | example | http://www.example.com
*** Test Cases ***
| Example using the requests library
| | ${response}= | Get | example | /
| | log | ${response.content}