我有一个包含测试用例的文件。像这样:
*** Settings ***
Documentation AREALVALID_LOGINbug4.ROBOT FILE
...
... ese tests are data-driven by their nature. They use a single
... keyword, specified with Test Template setting, that is called
... with different arguments to cover different scenarios.
...
... This suite also demonstrates using setups and teardowns in
... different levels.
Suite Setup Open Browser To Login Page
Suite Teardown Close Browser
Test Setup Go To Login Page
Test Template Login With Invalid Credentials Should Fail
Resource validresourcebug4.robot
*** Test Cases *** USER NAME PASSWORD
testbug4a 16 ${VALID USER} 14
testbug4a 17 ${VALID USER} 17
*** Keywords ***
Login With Invalid Credentials Should Fail
[Arguments] ${username} ${password}
Input Voedselnaam ${username}
Input Password ${password}
Submit Credentials
Check Messages
Set Browser Implicit Wait 1
# Wait Until Element Is Visible test
Login Should Have Failed
Login Should Have Failed
Location Should Be ${LOGIN URL}
Title Should Be Voedsel toevoegen
Set Browser Implicit Wait 5
我有一个资源文件,看起来像这样:
*** Settings ***
Documentation A resource file with reusable keywords and variables.
...
... The system specific keywords created here form our own
... domain specific language. They utilize keywords provided
... by the imported SeleniumLibrary.
Library SeleniumLibrary
*** Variables ***
#localhost:7272
${SERVER} testenvansoftware.nl/test/invoegenvoedselbug4.php
${BROWSER} Firefox
${DELAY} 0
${VALID USER} 90
${VALID PASSWORD} 60
${EIWIT} 70
${VET} 15
${LOGIN URL} http://${SERVER}
${WELCOME URL} http://${SERVER}/welcome.html
${ERROR URL} http://${SERVER}/error.html
*** Keywords ***
Open Browser To Login Page
Open Browser ${LOGIN URL} ${BROWSER}
Maximize Browser Window
Set Browser Implicit Wait 5
Set Selenium Speed ${DELAY}
Login Page Should Be Open
Login Page Should Be Open
Title Should Be Voedsel toevoegen
Go To Login Page
Go To ${LOGIN URL}
Login Page Should Be Open
Input Voedselnaam
[Arguments] ${username}
Input Text voedselnaam ${username}
Input Password
[Arguments] ${password}
Input Text Eenheid ${password}
Input Text Kcal ${password}
Input Text Eiwit ${password}
Input Text Koolh ${password}
Input Text Vet ${password}
Submit Credentials
Click Element getdata
Set Browser Implicit Wait 2
Check Messages
Element Should Be Visible //label[@class='err'] You
Element Text Should Be //label[@class='err'] You found bug#3: The system crashes by testing this way. Great Job!
Element Should Contain //label[@class='err'] You
Welcome Page Should Be Open
Location Should Be ${LOGIN URL}
Title Should Be Voedsel toevoegen
Set Browser Implicit Wait 5
现在,如果password的值为14,则该消息不同于密码为17的消息。
那么最好的解决方案是什么?最好的设置方法是什么?
我应该构建2个.robot测试文件吗? 要么 我应该建立2个资源文件吗? 要么... 是否可能在第一种情况下检查消息A而在第二种情况下检查消息B?请一些建议。...
答案 0 :(得分:0)
真的很难理解它们到底是什么问题,但是如果您要测试不同的输入会产生不同的错误,则建议将预期的错误字符串作为测试的一部分。
示例:
*** Test Cases *** USER NAME PASSWORD EXPECTED ERROR
testbug4a 16 ${VALID USER} 14 You found bug #1 blah blah
testbug4a 17 ${VALID USER} 17 You found bug #2 yada yada