Wait Until Keyword Succeeds and only one screenshot?

1,509 views
Skip to first unread message

sami.sa...@q-factory.fi

unread,
Mar 20, 2018, 8:20:07 AM3/20/18
to robotframework-users
Hello,

Could it be possible to add argument e.g. "one_screenshot" to Wait Until Keyword Succeeds keyword as an option? It would save disk/data space, if failure is still on in last attempt, then screenshot would be taken. 

Br
Sami

sami.sa...@q-factory.fi

unread,
Mar 20, 2018, 8:41:12 AM3/20/18
to robotframework-users
Is this the way to handle this? Adding to robot commandline:

--removekeywords wuks

--removekeywords all|passed|for|wuks|name:<pattern>|tag:<pattern> *
                          Remove keyword data from all generated outputs.
                          Keywords containing warnings are not removed except
                          in `all` mode.
                          all:     remove data from all keywords
                          passed:  remove data only from keywords in passed
                                   test cases and suites
                          for:     remove passed iterations from for loops
                          wuks:    remove all but the last failing keyword
                                   inside `BuiltIn.Wait Until Keyword Succeeds`
Br
Sami

Tatu Aalto

unread,
Mar 20, 2018, 9:10:48 AM3/20/18
to sami.sa...@q-factory.fi, robotframework-users
Ugh

The best option is not to use WUKS at all. But I know that relying only on the library keywords, like SeleniumLibrary, that is not always possible. If you have long running tests that use lot's of WUKS, I can understand why disk space may come a problem, but generally speaking hardware is cheap and should not be a big problem. The --removekeywords option only cleans the log.html and provides cure for the symptom and not for the decease. Although it makes the log.html scrolling more easier.

But it would be great know in which library and keyword(s) you use with the WUKS? Perhaps there is an enhancement that could be implemented for the library, so that you don't need to use WUKS at all.

-Tatu
Send from my mobile


--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Pekka Klärck

unread,
Mar 20, 2018, 10:12:45 AM3/20/18
to Sami Savolainen, robotframework-users
No. Wait Until Keyword Succeeds (WUKS) knows nothing about screenshots
so it cannot control how they are taken. Like Tatu I'd try to avoid
using WUKS in general. If that's not possible, I'd try disabling
taking screenshots or would use `--removekeywords WUKS` that you
already found.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Sami Savolainen

unread,
Mar 20, 2018, 10:26:27 AM3/20/18
to Pekka Klärck, robotframework-users
Thanks Tatu and Peke for your replies. Mostly I am using Wait Until Keyword Succeeds with Selenium keyword Wait xxx...
For loop with Run Keyword And Return Status + selected keyword(s) could be one way and after loop if it still fails, screenshot is taken.

-Sami 

Tatu Aalto

unread,
Mar 20, 2018, 11:54:41 AM3/20/18
to Sami Savolainen, robotframe...@googlegroups.com
Ugh

Is there a reason why you could not replace the whole user keyword with this: http://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Wait%20Until%20Page%20Contains%20Element

Added user group back to discussion.


-Tatu
Send from my mobile

On Tue, 20 Mar 2018, 17:43 Sami Savolainen, <sami.sa...@q-factory.fi> wrote:
Moi,

Something like this for example:

Wait Until Page Contains Element With One Screenshot
[Arguments] ${retry} ${retry_times} ${element} ${msg}=None
: FOR ${i} IN RANGE ${retry_times}
\ ${success}= Run Keyword And Return Status Page Should Contain Element ${element}
\ Exit For Loop If ${success}
\ Sleep ${retry_times}
Run Keyword If '${success}'=='False' Run Keywords Capture Page Screenshot
... AND Fail msg=${msg}
How could I replace static keyword Page Should Contain Element as argument(s) in my keyword e.g. that I could replace Wait Until Element Is Visible with its arguments? I could make better general dynamic keyword of it.

-Sami

2018-03-20 16:48 GMT+02:00 Tatu Aalto <aalto...@gmail.com>:
Ugh

Would it possible to see an actual keyword where you use this type of logic? 

-Tatu

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.




--
Parhain terveisin
Sami Savolainen
Testauskonsultti
Q-Factory Oy

Dmitriy

unread,
Mar 20, 2018, 12:29:35 PM3/20/18
to Sami Savolainen, robotframework-users
Hi,


For me it sounds like you try mask existing problem.I am totally against using WUKS keywords
because this indicates that wether your keyword are problematic or functionality does not work
as expected. However this guarantees that tests do not do 100% what they expect to do. Simple
example is clicking button you wrap it in WUKS and you have to click button 1+ times. 
Test works perfectly however imagine that user has to click same button more then once 
to perform action. I believe all of you had this kind of scenario and how annoying was that? 
Such a simple thing and it has divesting impact on product reliability and end-user happiness.

Thanks,
Dmitriy

Sami Savolainen

unread,
Mar 20, 2018, 12:31:32 PM3/20/18
to Tatu Aalto, robotframe...@googlegroups.com
Moikka, 

Wait Until... keywords I could use but mostly these Click Element is nice to try several times when SUT is not so good testability point of view. One time clicks are vulnerable sometimes. 

-Sami 

sami.sa...@q-factory.fi

unread,
Mar 20, 2018, 12:47:00 PM3/20/18
to robotframework-users
Hi Dimitriy,

For sure I am not masking anything :-) Sometimes systems are not build based on user friendly point of view and system owners are ok with that. But: they want, that information of SUT is correct and our job is to verify that. So testing is not always so black and white. And sometimes extra ”tricks” are needed to do that. If we test UI with mass of users, story is totally different.

-Sami




Anne kootstra

unread,
Mar 20, 2018, 4:00:23 PM3/20/18
to robotframework-users
I'm enclined to agree with Dimitri. Extensive usage of WUKS is a sure sign you as an automation engineer are not in control of the system-under-test. This could be due to lacking indicators for recognizing that you're application is ready for the next Test Action. In any case it pays to invest in a good waiting strategy to know when your application is in rest. This eliminates the need for most of the WUKS scenarios. 

An alternate approach to using WUKS, but preventing screenshots to be created, is to  create a custom keyword and use a keyword like Get Element Count and then a Run Keyword If ..  to assess the action. This will not trigger when the count is 0 and thus a screenshot is prevented. 

In the event that you need to use WUKS and want to avoid the unnecessary creation of images the only way is to use the SeleniumLibrary keyword: Register Keyword To Run On Failure. This will allow for temporarily disabling of the screenshot functionality till the WUKS has ended. 

Again, this is an approach that should be used sparsely and even then with regret. 



Op dinsdag 20 maart 2018 17:47:00 UTC+1 schreef sami.sa...@q-factory.fi:

Sami Savolainen

unread,
Mar 20, 2018, 4:18:43 PM3/20/18
to koot...@gmail.com, robotframework-users
Hi,

Now we go to side track. Original question was, how to get one screenshot instead of several screenshots in same function (wait until keyword succeeds). I am not anxious to use wuks, i have not used it ever earlier. That's why I was asking here, could it be solution. So thanks, now I know, it's not the way. 

So could you stay in original topic? I am very aware, what is our SUT and expectations in QA point of view.

Best regards 
Sami 

--
You received this message because you are subscribed to a topic in the Google Groups "robotframework-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/robotframework-users/LQFS-B_CTBM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to robotframework-u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages