上次走到了具体测试执行的地方,感觉缺乏一个全局观,有点走不下去。
还是再回头看看整个设计思路,所有的模块文档都可以从这里访问到:
使用文档:
http://robotframework.org/robotframework/
接口文档:
http://robot-framework.readthedocs.io/en/3.0.2/autodoc/robot.html
在看这些keywords之前先记录一下对为什么要用keywords这种方式而不是传统的编程方式的思考:
1. 有大师曰过,所有的编程抽象,本质上都是DSL,也就是最后会变成一种领域专用语言,任何我们调用的库都是。所以keywords本质上也是一种DSL。
2. 作为测试领域的DSL,好的keywords设计可以极大的降低测试的编写门槛和开发效率
3. 内置的Keywords应该提供一种测试逻辑完备性,包括各种判断和循环
4. kewords使用上由于是基于英文设计的,应该更符合英语使用者的思维,如果有相应的中文版本那就可以更方便中文使用者,当然可以自己开发中文版
Robotframework自带的默认keywords和库如下,如果要熟练使用,最好都能仔细看看,尤其是builtin的。
BuiltIn
Contains generic often needed keywords. Imported automatically and thus always available.
Collections
Contains keywords for handling lists and dictionaries.
DateTime
Supports creating and verifying date and time values as well as calculations between them.
Dialogs
Supports pausing the test execution and getting input from users.
OperatingSystem
Enables performing various operating system related tasks.
Process
Supports executing processes in the system.
Remote
Part of the remote library interface. Does not have any keywords of its own.
Screenshot
Provides keywords to capture and store screenshots of the desktop.
String
Library for manipulating strings and verifying their contents.
Telnet
Supports connecting to Telnet servers and executing commands on the opened connections.
XML
Library for verifying and modifying XML documents.
Builtin的keywords可以和应该能够解决我们平时常用的测试逻辑,如果不行还能够保持原生python语言的灵活性。用这个思路,看看大概有哪些。
首先提示了,大部分关键字都提供了对错误信息的支持,而且可以是HTLML格式的,目的应该是可以让错误信息更醒目。然后说有些keywords是可以支持python的语句,会用eval执行。内置的keywords如下:
Call Method · Catenate · Comment · Continue For Loop · Continue For Loop If · Convert To Binary · Convert To Boolean · Convert To Bytes · Convert To Hex · Convert To Integer · Convert To Number · Convert To Octal · Convert To String · Create Dictionary · Create List · Evaluate · Exit For Loop· Exit For Loop If · Fail · Fatal Error · Get Count · Get Length · Get Library Instance · Get Time · Get Variable Value · Get Variables · Import Library · Import Resource · Import Variables · Keyword Should Exist · Length Should Be · Log · Log Many · Log To Console · Log Variables · No Operation· Pass Execution · Pass Execution If · Regexp Escape · Reload Library · Remove Tags · Repeat Keyword · Replace Variables · Return From Keyword ·