Automation 机器人框架:有没有更好的方法来测试菜单中的项目?
我正在编写一个测试来验证web菜单是否包含所有必需的项,因此我创建了一个名为“verify menu”的关键字,其中包含以下几个项:Automation 机器人框架:有没有更好的方法来测试菜单中的项目?,automation,robotframework,Automation,Robotframework,我正在编写一个测试来验证web菜单是否包含所有必需的项,因此我创建了一个名为“verify menu”的关键字,其中包含以下几个项: Verify Menu Wait Until Element Is Visible ${menu} Page Should Contain Element ${home menu item} Element Text Should Be ${home menu item} Home Page Should
Verify Menu
Wait Until Element Is Visible ${menu}
Page Should Contain Element ${home menu item}
Element Text Should Be ${home menu item} Home
Page Should Contain Element ${products menu item}
Element Text Should Be ${products menu item} Products
Page Should Contain Element ${brands menu item}
Element Text Should Be ${brands menu item} Brands
Page Should Contain Element ${find us menu item}
Element Text Should Be ${find us menu item} Find us
Page Should Contain Element ${our history menu item}
Element Text Should Be ${our history menu item} Our History
Page Should Contain Element ${contact us menu item}
Element Text Should Be ${contact us menu item} Contact Us
我知道这是一个关键字实现,而不是测试本身的一部分,然而,它看起来有点混乱
有更好的方法吗?在我看来,
等待元素出现,以确定页面已完全加载。然后页面的后续组合应包含元素
,并且元素文本应为
,以验证元素
我个人认为页面应该包含元素
,而元素文本也应该包含元素。它将失败并提供类似的消息
也就是说,如果您想保留duo,但不需要额外的代码行,那么选择自定义关键字:
Verify Menu
Wait Until Element Is Visible ${menu}
Validate Element ${home menu item} Home
Validate Element ${products menu item} Products
Validate Element ${brands menu item} Brands
Validate Element ${find us menu item} Find us
Validate Element ${our history menu item} Our History
Validate Element ${contact us menu item} Contact Us
*** Keywords ***
Validate Element
[Arguments] ${identifier} ${value}
Page Should Contain Element ${identifier}
Element Text Should Be ${identifier} ${value}