Log page url on test failure

42 views
Skip to first unread message

Aliasger Kiranawala

unread,
Aug 20, 2021, 1:55:00 PM8/20/21
to robotframework-users
Team,

I want to know if there is a way to log the failed page url along with screen shot? Currently i have to trace back to know from which URL I reached by following steps till the failure happened. 

Any help is appreciated!

praveen yarraguntla

unread,
Aug 20, 2021, 9:43:54 PM8/20/21
to alia...@locus.sh, robotframework-users
Hi aliasger,

I did a similar step in one of my projects.  Capturing a screenshot at failure step can be taken care by framework.

Steps I followed.
------------------------
1)  In the variables section  @{URLList}= Create List
2) In the test case set global variable ${URLList}
3) Identify Bad Url
    ${url}=   Get Location
log ${url}
Append To List ${URLList} ${url}
log ${URLList}
set global variable ${URLList}

With this you can get all the failure urls. If you want screenshot here, take the failure url and verify in the report

--
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 view this discussion on the web visit https://groups.google.com/d/msgid/robotframework-users/7e848101-2783-4d35-a06e-b3d41db963b6n%40googlegroups.com.

Aliasger Kiranawala

unread,
Aug 22, 2021, 2:50:18 AM8/22/21
to robotframework-users
But I dont want to capture all the page urls. I just need those when the failure occurs. 

Dave Amies

unread,
Aug 22, 2021, 9:55:16 PM8/22/21
to robotframework-users
One thing I learned was that you can override the default keyword that is run on failure with Register Keyword To Run On Failure so you could create a keyword that does a Get Location and Capture Page Screenshot and make this new keyword your on failure keyword.

Not sue if that's what your after, so I hope that helps,

Dave.

Aliasger Kiranawala

unread,
Aug 23, 2021, 1:14:34 AM8/23/21
to robotframework-users
Thanks Dave.

Yes I was looking for the similar approach. One question is will the same work when any built in keyword fails?

Dave Amies

unread,
Aug 23, 2021, 8:03:34 PM8/23/21
to robotframework-users
I believe that one is specific to Selenium Library, I used it because I wanted to disable screen shots for a section of my test to reduce the number of screenshots i'll never look at (it was a retry loop)

When I checked the documentation for Builtin I found (I've not used these, but the may be what you want):
So they may help you,

Dave.
Reply all
Reply to author
Forward
0 new messages