Search code examples
robotframeworkplaywright

How to inspect if a element changed there text


We need to inspect when the text on a element change, because it is one way to see if the process ended, so we made something like this:

*** Settings ***
Library          Browser
*** Test Case ***
...
Then inspect if the element text is Finished
*** Keywords ***
Then inspect if the element text is Finished
sleep                                                      10
${text} =                                                  Get Text                                                      //*[@id="situacaoUltimaMovimentacaoVariacaoCambial"]
Should Be Equal                                            ${text}                                                      Finished

But I don't think using sleep for this is a good idea, you guys know some solution for doing this in a better way?


Solution

  • Thanks to @senaid I found a good solution.

    Because Playwright will always wait until try to do some commands, I used Click on the element with the text that will be find after the process finished. So the code will be:

    *** Settings ***
    Library          Browser
    *** Test Case ***
    ...
    Then inspect if the element text is Finished
    *** Keywords ***
    Then inspect if the element text is Finished
    Click                                                          //*[@id='situacaoUltimaMovimentacaoVariacaoCambial' and contains(text(),'Finished')]