2017-07-09 4 views
0

私は、Webメニューを確認するテストを書いているが、必要なすべてのアイテムを持っているので、私はこのようないくつかの項目で「メニューを確認してください」と呼ばれるキーワードを作成しました:Robot Framework:メニューの項目をテストするためのより良い方法はありますか?

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 

私は、これがキーワードの実装を知っているとテスト自体の一部ではありませんが、私にとってはちょっと面倒です。

これを行うより良い方法はありますか?

答えて

1

Wait Until Element Is Visibleは、ページが完全に読み込まれているかどうかを確認するためのものです。次に、Page Should Contain ElementElement Text Should Beのその後の組み合わせで要素を検証します。

個人的にはPage Should Contain ElementElement Text Should Beに含まれていると思います。失敗して同様のメッセージが表示されます。

、請求、カスタムキーワードを選ぶ、その後、デュオを維持しますが、コードの余分な行を廃止する場合:

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}