How to check url request response as 200 successfully

Best practices, code snippets for common functionality, examples, and guidelines.
csolanki
Posts: 77
Joined: Thu Mar 22, 2018 8:51 am

How to check url request response as 200 successfully

Post by csolanki » Mon Nov 26, 2018 11:32 am

Hey,

I have read posts regarding api testing and request module ,which we can use in checking response successfully. But I wanted to know, irrespective of the URL, can I just check response is coming as 200 or not ? any UI is under process for the same ?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 4041
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to check url request response as 200 successfully

Post by odklizec » Tue Nov 27, 2018 4:12 pm

Hi,

If you mean you want to get the response code from Ranorex action like OpenBrowser, then no, there is no such feature. If you want to get the response code from web request, then you need to write some code for this. Check for example this post:
https://stackoverflow.com/questions/133 ... est-and-ht
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

User avatar
Vega
Posts: 110
Joined: Mon Jul 11, 2016 2:15 pm

Re: How to check url request response as 200 successfully

Post by Vega » Wed Nov 28, 2018 10:44 pm

Additionally if you want to get the response from an in browser request, you can use something like Chrome dev tools:
form1.png
form1.png (59.13 KiB) Viewed 25 times
Just remember if you want to automate and Chrome form objects, you need to launch Chrome with the below flag (just add it to the arguments part of the open browser action):

Code: Select all

--force-renderer-accessibility
But as odklizec mentioned depending on your requirements you may be better off using a coded approach. Just know that coded network requests do not line up with what is in the browser as coded requests make requests outside of the browser...unless you have some type of middleware to pipe the requests from the browser to your API/code/whatever.

Hope this helps