RobotFramework, how to check text on page

前端 未结 1 1686
失恋的感觉
失恋的感觉 2020-12-11 06:52

if there appears text on a page after hitting a button.

the only thing it is in is a class, like so:

相关标签:
1条回答
  • 2020-12-11 07:24

    There are various options choose which suites you most

    Using Keywords

    1. If you want exact text match then use

      Element Text Should Be    //label[@class='err']    2 van de 3 velden  Eiwit, Koolhydraten, Vet  zijn leeg.
      
    2. If you want substring in text

      Element Should Contain    //label[@class='err']    velden
      
    3. It waits until the locator with text appears on page , I think another option to suffice to serve you verify text

      Wait Until Element Contains    locator        text
      
    4. This will verify text on entire page so it may be present multiple times on page or only single time

      Wait Until Page Contains        text_you_want_to_verify_on_page 
      

    Using Locators

    to match complete text

    //label[text()="2 van de 3 velden  Eiwit, Koolhydraten, Vet  zijn leeg."]
    

    to match partial text

    //label[contains(text(),'velden')]
    

    and pass it to one of keyword which verifies element on page. for more option you can explore here

    0 讨论(0)
提交回复
热议问题