I'm writing test cases in Robot Framework using AppiumLibrary.
I'm importing AppiumLibrary with the following code to get a screenshot whenever something goes wrong:
AppiumLibrary.__init__(self, run_on_failure="Capture Page Screenshot")
Is there a way to NOT take a screenshot for a specific keyword? This keyword will for example create 15 screenshots (if it's not able to find Donald):
Wait Until Keyword Succeeds 30 seconds 2 seconds Element Text Should Be Username Donald
There is nothing built-in to do what you want. There are many solutions, however.
One solution would be to turn off capturing the keyword (using register keyword to run on failure) immediately before calling wait until keyword succeeds
. You could then call wait until keyword succeeds
, and then turn capturing back on afterwards.
Or, you can register your own custom keyword instead of Capture page screenshot
. Your own keyword can use whatever logic it wants to determine whether to capture screenshots or not. For example, it could look for a global variable that tells it whether to capture or not.
You could also write your own keyword to use in place of wait until keyword succeeds
which also uses one of the other two solutions.
For example, create a keyword named wait until element contains text
which turns off the capturing, runs wait until keyword succeeds
, and then turns it back on. Then, in your test you still just have a single statement:
wait until element contains text Username Donald