DevExpress / testcafe

A Node.js tool to automate end-to-end web testing.
https://testcafe.io
MIT License
9.82k stars 673 forks source link

Getting logger response body in encoded or encrypted form #4531

Closed nawazakhtar closed 4 years ago

nawazakhtar commented 4 years ago

I am getting the request object and when I am trying to print all things are correct except response body which is in the following form

response: { statusCode: 200, headers: [Object], body: '\u001f�\b\u0000\u0000\u0000\u0000\u0000\u0000\u0000�X[s\u001a;\u0012�+��y�c�f�\u001a?\u0005\u0003�I�@\u0000�99��\u00123\u0002��H\u0013ICL\��{�����]?$L��V��ҳ��,p.\u001d�\u001b�\u0016�\u000f]�5�j���u�\u001d���y��9s�뇻ɨ���\u001e���ʻ�w�|��z\u00177]��RlXHW��\u0002t���\u000f\u0016\u0001�F��@Y�pO\u0002!�\rBM�O����@vB��E\u0004@_�\r���w�V�\f��(��}#�w���a�(��\u0015�n��.\u0000�JOI��ݲX�L\u000b G,\bBj�@\bI\u000e��$8\u0000I%�\r{r.y\u0012� \b���i<62l@\u000e�Et�\u0013\u001c\u0011�N����V\u000b�H��2�����4X.���\u0017�yݞ�d��d�\u00015yZ�XHMeF"[\u0010��qGMg�+\u0006&\u00021^��9w��-#���o\u0007A �R�峣��T\u0003���6nA\b��1\f�5�3e6���2}@G�D�\u001a\u001f�JT��̀:�+u\u00198@\u001e\f�\u0017�qw��6���=�5\u0005�cK�I�\u0004a �ҁXYL�#��\u0013\u0011=�m��\u001b7T�D\u00184\u0016$��=��\u0018��\u0018�.���\u0007�����+Z{�5S#��PI�5�2��>\r��RT�\t�\b\u0019\u0011�\u0004G]\t�\t\t\'\u001c�\r\u001d��\u001fD\u0013����,Ȏ�\u0013\u0005�j\u001a\u0000��Q��k5�� �]eQ3�D֠�f���=\u0017�O�\u0004e�O1�\n��\u001f\u001d�\f ���g��>#a��T�\u00115���H�\u000f�\t\u000f�a_��N��\u001d��\u0011�\u0004��+@�\u0004�O��\u0003l=�K\bn�1��\u0004��yY.�X�bĞJ\u0012����\u0018�\u001dh�\u0003��6�\u0006�\u00100���\u0005}+ �����5��\nɅ�k�\u001e��|����\u0018�,��}�@�(�\u000eL]:��\u001d�P�^"�����T�h�YO�m�αb\u001d��\u001eR��C:\u0014�/������\u000e�Vu������r\u0004�\n�~a�9w�)��`��ߨ��\u001e�s{��\n"�!eh�~\u0000��k\u001ả�b�\f�~-$e[n�v���Zp\ri��j�2�9{\u001a��&<��\u0012�l�\t\u000f\u0012�V�\r\t\u0015E\u0018�\u0006�\n�\'xdz��$�\u001au\rM.O�\u001a�mw\u000b���A\u0005T�4jH\u0014��5�=�t��Fs\t�@$�B\u0019\u001eQ\u0012\u0016m�H\u001e����m�=�Ò�=+\[Ǭ$��p\u0000eF�\u0006yP�\u001d��=sr@�Υ��\nY�W\u0010��Ӷ�tlt�JT�\u001eM\u0003�\'2\u0016\nCb0\u001c>�?�\rV�?�\u0007w�[�\u000e��85�H�\u000f}5ϣ�0�\f\u0003��\r8�a�\u0006 [<�[\u0001E���ǀ,��2��L�\u000f�cש�"�fW�\u0014��~�\u0005�+�lxC�@+��\u0019܌9Uڂ��Fj��3s�T�%d\u0003\u0013��7?f��;\u0001)o}�}��\u000b\u000e�q(Ұ1V0Y}-\u0005��\u0005��,��\u0018r��!}?��\u001d�\t�q��_p�3�X��\u000eiU\u0004�v\u0018�\u0006�Bz8s\n�U\u0002�\n�k���� x�\u001cSir\u001b��-(�\u001f\u001an2ae˔�E\t2�������~�ٸ�\u0001���\u0010?+Ô�w\u001b�v�t���q��hWLXS������\u0006ˮ�p\bf\u0018�J]�\u0015$D\u0014QU��a�"���\u001a\u0012n\u000e8\u000e���!\u0004F;�\u001e�[@�\u001b�s\u0019L(�4\u0004N�����\u0016FZ�!\u0006�J��U���\u000f�e�L}��\n�$+��l���Em�?;�U\u0016�V&���\u000bʽ��\rj�\u0015�)R\t�\'\u0002���.��c��D\u0011��T�OL�Jr��<M�u\u0011�1Q\no,U�>�)Ss\nՋ�Q\u001e��[���h��\u0017ep\u0010��\u0006��\u0005�\u0006{P��n�\rc\'3��r�aT�>0i�E�\f��&23ŝ����p�r/�˂�R\t\u0014�e9�s�v�0\fjvv�����3\u0016�5\u0003~3�@��G\u0005\u001e\u0006�e��sHJ�S��7��\u0010o�Y���.���\n���H+m�G;�T��0v�x����\u0015�N\\\u001a\u0016�O���-\u001dk�\u0016� _M�xr�O�\'��@)\u0018\u0015��Yf�C�\\\u0012Xc���Mk���5\u0018�63�c\twʒ���\n��+�w\u001a��\u001d�\u0005�� /�Q\u001c\u00143\bF��s2��[���Ѡ�p�I\f����^S?�0)���u\u0012\u0006�</_̶�:d~x��a0\u0014QL�a�\u0013�@�\u0015C�\u0011(����\n,\nՒk��A)[�ס4]g�\u0011�\u000bnƤ>tAhU�Ȁ���D��A��B��W9,����c�"XW���\}<[t\u001fG����}~���\��pݯ�7�\b�!�צq��i�\u0003\t��0^���\u001bQ�w�w��}��s(-���H�\u0001i_����\u00127\f����\u0013��s{B�\u0018��|����i�b@�\u001f�k�\+\t�\u0006\r�vh.���N\u0006[��0�\u001b���aU5Â�1㥧Ù�ɞ�w#"��|�E�}Ӌ�m��v��n6���6���nNj|�����ڍ{B\u001b\u000f\u001c��4\u0006�\u001d7�y�\u0006pp\'���l�q���\u0006�\u0018�C�jp-�\u0004\u001fWJeK���\'��\u001es�f\u0007\u0005o��sbå��Q�p۟����[�\bƧ=\rp\f���-�C�/Yo@�m�\u000eh\u0006S\\\u0014�\u0016A�\u0013ٮ���V�a�0\u0005�\u0001Sž��U\u0012�\u000e�i�i�6/Vn�ٹ�t�d�&x�?��_z�/��?\u0000\u0000\u0000��\u0003\u0000�฼\u0016\u0000\u0000' } }

Also the options used are : logResponseHeaders: true, logResponseBody: true, logRequestHeaders: true, logRequestBody: true, stringifyRequestBody: true, stringifyResponseBody: true

Environment details:

Farfurix commented 4 years ago

@nawazakhtar

Hello,

This information is not enough to reproduce this issue. We have a lot of updates since v1.0.1. First, I suggest you install the latest v1.7.0 TestCafe version (if it is possible in your case, you can also try to update Node.js to 12.13.1 LTS) and check whether the issue still persists.

Could you please provide us with a sample project or a public URL? We will examine it and check for a suitable solution.

nawazakhtar commented 4 years ago

I tried running the following test with latest testcafe version:

import { RequestLogger, Selector } from "testcafe";

const url = 'https://devexpress.github.io/testcafe/documentation/test-api/intercepting-http-requests/';

const logger = RequestLogger({ url }, { logResponseHeaders: true, logResponseBody: true, logRequestHeaders: true, logRequestBody: true, stringifyRequestBody: true, stringifyResponseBody: true });

fixture Test Cafe test .page(url) .requestHooks(logger);

test('test cafe sample',async t => { const logHttpRequestLink = Selector('a').withText('Log HTTP Requests').nth(1); await t.click(logHttpRequestLink); console.log('logger ======>>>>>>>'); console.log('length is ======>>>>>'+logger.requests.length); console.log(logger.requests.map(r => r.request.url)); console.log(logger.requests); });

I got the following output:

Running tests in:

@Farfurix Please try running above test and see what you get in response

aleks-pro commented 4 years ago

Hello @nawazakhtar ,

Thank you for the example. I have managed to reproduce the issue. The cause of it is that the response body is packed into the gzip format. We already have a suggestion regarding this problem. Follow it to be informed about our progress: https://github.com/DevExpress/testcafe/issues/3243

PS: As TestCafe is an open-source tool, you always have a chance to create a pull request in the TestCafe GitHub repository to fix a bug or add a new functionality.

lock[bot] commented 4 years ago

This thread has been automatically locked since it is closed and there has not been any recent activity. Please open a new issue for related bugs or feature requests. We recommend you ask TestCafe API, usage and configuration inquiries on StackOverflow.