Alternative solution for Run Keyword And Ignore Error to avoid status="FAIL" in output.xml

1,582 views
Skip to first unread message

L.S. Yew

unread,
Mar 27, 2014, 10:42:10 PM3/27/14
to robotframe...@googlegroups.com
Currently I have the following code that checks whether a user exists. It it does not exist, the user will be created as follows:
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

${status}       ${value}=       Run Keyword And Ignore Error    Page Should Contain Element     //a[text()='User Does Not Exist']
Run Keyword If  '${status}' == 'FAIL'   Create User       ${user_id}     ${first_name}    ${last_name}

---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Whenever "Run Keyword And Ignore Error" is executed and if the page does not contain 'User Does Not Exist', 'status="FAIL"' will be generated in output.xml

The problem is I have another application that checks for 'status="FAIL"' in output.xml which marks as failure in the test automation. In the case above, 'status="FAIL"' found in output.xml is not an actual failure.

Assuming I have no control over the application that analyses output.xml, is there any alternative way that I can prevent 'status="FAIL"' being generated in output.xml and check for the existence of the text, 'User Does Not Exist'? Is there an alternative way that I can avoid using "Run Keyword And Ignore Error" to reach the same goal?


Bryan Oakley

unread,
Mar 28, 2014, 6:59:33 AM3/28/14
to robotframework-users
Have you tried calling "Get Text" or "Get Value" on the xpath of the element that displays the message, rather than "Page should contain element"? When you call "Page should contain...", that is an assertion. You're saying the page should contain the element, and to fail if it doesn't. If you are simply checking for a condition rather than requiring the condition, don't use "Page should contain...". Instead, use some other keyword that will tell you whether it's on the page or not. 


--
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 http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

L.S. Yew

unread,
Mar 31, 2014, 10:52:43 PM3/31/14
to robotframe...@googlegroups.com
Thanks for your response, Bryan.

I cannot think of a way to use Get Text or Get Value because there is nothing unique about the locator. The following are some samples of the locators (they are all located in a table):

<a href="/admin/user/view/90/">john</a>
<a href="/admin/user/view/91/">david</a>
<a href="/admin/user/view/92/">jane</a>

90, 91 & 92 looks like an id but there is no way for me to know the value. I only know the user name such as "john", "david" or "jane" because that's the name I intend to search.

Kevin O.

unread,
Apr 1, 2014, 10:13:24 AM4/1/14
to robotframe...@googlegroups.com
Have you looked at Get Matching Xpath Count? You are already using XPath...

Wait Until Page Contains Element    xpath=//a[starts-with(@href, '/admin/user/view/')]    # sync, assumes at least one user exists
${user exists}=    Get Matching Xpath Count     xpath=//a[text()='User Does Not Exist']
Run Keyword Unless    ${user exists}    Create User       ${user_id}     ${first_name}    ${last_name}    # using int as boolean here

I would still raise an objection to the post-processor. It seems like it would also have a problem with Wait Until Keywod Succeeds unless you are removing the initial failures with command-line options.

Kevin

Azam Alias

unread,
Jun 5, 2014, 11:04:14 PM6/5/14
to robotframe...@googlegroups.com
I am having a similar issue with this keyword.

Currently I am using Selenium2Library, and by default it will grab a screenshot every time a keyword fails.

I am using Run Keyword And Ignore Error to close an advertisement overlay from a web page, and it is randomly displayed as it is externally referenced, out of our team's control.

So far it works okay, except that there are unnecessary screenshots if the overlay is not displayed, and it is cluttering our output folder.

Can anyone give the better way to approach this?

Thanks and regards,

Janne Härkönen

unread,
Jun 6, 2014, 1:01:57 AM6/6/14
to azam...@gmail.com, robotframework-users
Hi Azam,

On Fri, Jun 6, 2014 at 6:04 AM, Azam Alias <azam...@gmail.com> wrote:
I am having a similar issue with this keyword.

Currently I am using Selenium2Library, and by default it will grab a screenshot every time a keyword fails.

I am using Run Keyword And Ignore Error to close an advertisement overlay from a web page, and it is randomly displayed as it is externally referenced, out of our team's control.

So far it works okay, except that there are unnecessary screenshots if the overlay is not displayed, and it is cluttering our output folder.

Can anyone give the better way to approach this?


It seems that Selenium2Library supports dynamically changing the keyword to run on failure[1], so this sequence should work: 

Register Keyword To Run On Failure   Nothing
Run Keyword and Ignore Error    Page Should Contain Element ....
... Some other actions ....
Register Keyword To Run On Failure   <Whatever it was earlier>

Wrapping that as a user keyword should work pretty well.



hth,
--J
Reply all
Reply to author
Forward
0 new messages