python - RobotFramework Having keywords and Test template
问题描述
I am using Robotframework and trying to write a Test case which need's Template as well as some keywords.. Below is something which i am currently working on .. Template cannot be inside Settings because there are different Test-cases and each of them have different use cases.
When trying to run TC_003_Edit_Custom_Destination
it is throwing me error which is
Keyword 'Create Destination Invalid Scenarios' expected 4 arguments, got 1.
TC_003_Edit_Custom_Destination
[Documentation] Edit Custom Destination, inside settings tab
[Tags] Testing Edit Custom Destination Functionality
TC_001_Streaming_test_setup other
Cancel create Destination
Click on edit title for new destination created ${destination_title_name}
[Template] Create Destination Invalid Scenarios
${empty} ${empty} ${empty} Please enter an RTMP address
${empty} ${rtmps_address} ${empty} Please enter an stream key
${empty} rtm://google.com 123ABC Invalid Destination
${empty} ${rtmps_address} 123ABC Please give this destination a name
${destination_title_name} ${rtmps_address} 123ABC ${empty}
Does anyone know how can i add keywords and also test-template together inside TestCase ? I don't want to pack
TC_001_Streaming_test_setup other Cancel create Destination
inside [Setup]
____ Update ____
*** Test Cases ***
Test Case with Template
[Template] Template_1
${template_args_1} ${template_args_2}
Some_keywords_1
Some_keywords_2
Some_keywords_3
解决方案
如果我理解正确,您希望在同一个套件中使用带有模板的测试用例和没有模板的测试用例。
这可以通过在测试级别设置模板来实现,如下面的示例,您有 3 个测试用例,2 个使用不同的模板,1 个没有任何模板。
*** Test Cases ***
Test Case with Template
[Template] I Will use this template
This is the first execution variable
This is the second execution
Test using another Template
[Template] Use this template instead
This uses a different template
Test Without Template
Log This test case doesn't use template!
*** Keywords ***
I Will use this template
[Arguments] ${templateVar1}
Log My variable value is ${templateVar1}
Use this template instead
[Arguments] ${anotherVar}
Log This is the other template value: ${anotherVar}
推荐阅读
- sql - 在数据子集上编写具有多个不同条件的查询
- java - jsoup 连接 HTTP 错误 406
- sql-server - 如何在每个发票编号的多个项目中使用 GROUP by?
- amazon-web-services - 对 DynamoDB 中的 GSI 进行批量查询?
- python - 在 python 中使用 selenium 抓取 HTML 代码的一部分(不是文本)
- python - 如何使用 wsgi 在 URL 路径中包含变量?(不是查询字符串)
- html - 用不同的填充在html中嵌套表格
- r - UpdateSelectInput 不更新 R Shiny 模块中的值
- linux - 从字符串 grep 日期
- r - 创建日期数据框