Contributions
Re: Performing post request with content-type multipart/form-data (for binary file)
Wow, it works with curl, even on CrossBrowserTesting, brilliant! So at least with our TestComplete ProBundle license (i. e. including desktop module).:manvery-happy: For now, thank you both for your expert advice!! I had already encountered curl during my research on multipart/form-data content type, but I didn't think it was possible that this could work so easily on CBT and therefore discarded it too quickly. Really great! Thanks + best regards!1KViews1like0CommentsRe: Performing post request with content-type multipart/form-data (for binary file)
Hi Alex, > Then, considering that TC 12.4 and up supports external project files (https://support.smartbear.com/testcomplete/docs/general-info/version-history/features-added-to-ver-12-4.html#smarter-crossbrowsertesting-integration), I would stick to Helen's suggestion: add curl files to some subfolder of your test project so that they are deployed to CBT and use it (curl) to send the screenshot. That almost sounds too good to be true. In this respect, I would understand the Release Notes to mean that it is possible to use your stored test data in this way, for example. Don't you think SMARTBEAR would have made it even clearer if Windows applications could suddenly be run on cloud machines? Which keyword operation or scripting method would I use to verify this approach? Is there a way to do this that works without the TestComplete Desktop module, i. e. only with the Web module? Edit 1:As I just saw, Helen recommended in her post above to call curl with the WshShell.run method. Should this work without a Desktop module? Edit 2: And once againin order to double-check: Is there noway to extract these original, unaltered, i. e. not encoded, non-human readable control characters that make up my screenshot graphics file,so that I can concatenate the data myself in the required multipart/form-data format? The rest of the Javascript needed for this task I have finished long ago, and of course it works - only this darned binary data is missing. Thanks + best regards1KViews0likes2CommentsRe: Performing post request with content-type multipart/form-data (for binary file)
Hi Alex, I apologize for not having explicitly stated that yet. The answer is: Yes, I would like to send a screenshot directly from the respectiveCrossBrowserTesting machine in certain situations, for example (but not only) in case of an error during testing. And I don't want to have to wait until the log data has finally landed on the local computer after completing all assigned test runs on all the CBT machines concerned (which can take several hours). Thanks + best regards3.4KViews0likes4CommentsRe: Performing post request with content-type multipart/form-data (for binary file)
3rd attempt (why was my answer to Alex' last post deleted twice?): Hi, > Depending on the scripting language of your test project, you may look for some third-party library/component that will provide such functionality and use it. However, there may be problems with deploying required components to the CrossBrowserTesting environment. That's exactly my problem. :) Fiddler will then also be excluded as an option. That's why, in the meantime, I have taken a closer look at the syntax required for the multipart/form-data content type in order to assemble the string for myself, that has to be transmitted. But therefore I also need an approach to read the byte code of the binary graphic file and append it to my output variable. I assumed that the second code example at https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqbinaryfile/index.html could help me with this: function ReadByteFromFile() { var Path = "C:\\MyFiles\\Desktop.jpg"; // Opens the specified file for reading var myFile = aqFile.OpenBinaryFile(Path, aqFile.faRead); Log.Message("File by bytes:"); // Reads bytes from the file and posts them to the test log while(! myFile.IsEndOfFile()) { s = myFile.ReadByte(); Log.Message(s); } // Closes the file myFile.Close(); } Unfortunately, however, this does not result in the byte code but in a purely numerical chain (I suspect ASCII code?). But how can I access the unaltered byte code, which I need? I do not find any further details on this in the TestComplete documentation. Many thanks and best regards3.4KViews0likes6CommentsRe: Performing post request with content-type multipart/form-data (for binary file)
Hi Helen, thanks for your reply.Our messages have crossed. As I wrote above, only those approaches that I can use for TestComplete tests on CrossBrowserTesting are useful to me. That's why I have already started to create the required multipart/form-data format myself (of course including the required headers and boundaries etc.). Outside of TestComplete, I have already succeeded in doing so. I now only need the correctmethod to integrate the binary image data into my post message. Thank you and best regards3.4KViews0likes0CommentsRe: Performing post request with content-type multipart/form-data (for binary file)
Hi, > Depending on the scripting language of your test project, you may look for some third-party library/component that will provide such functionality and use it. However, there may be problems with deploying required components to the CrossBrowserTesting environment. That's exactly my problem. Fiddler will then also be excluded as an option. That's why,in the meantime, I have taken a closer look at the syntax required for the multipart/form-data content type in order to assemble the string for myself, that has to be transmitted. But therefore I also need an approach to read the byte code of the binary graphic file and append it to my output variable. I assumed that the second code example athttps://support.smartbear.com/testcomplete/docs/reference/program-objects/aqbinaryfile/index.htmlcould help me with this: function ReadByteFromFile() { var Path = "C:\\MyFiles\\Desktop.jpg"; // Opens the specified file for reading var myFile = aqFile.OpenBinaryFile(Path, aqFile.faRead); Log.Message("File by bytes:"); // Reads bytes from the file and posts them to the test log while(! myFile.IsEndOfFile()) { s = myFile.ReadByte(); Log.Message(s); } // Closes the file myFile.Close(); } Unfortunately, however, this does not result in the byte code but in a purely numerical chain (I suspect ASCII code?). But how can I access the unaltered byte code, which I need? I do not find any further details on this in the TestComplete documentation. Many thanks and best regards3.4KViews0likes0CommentsRe: Performing post request with content-type multipart/form-data (for binary file)
Hi AlexKaras, regarding a) and b) you may be right in principle. But either way, since the FormData object is not supported by TestComplete, the method formData.append() cannot work either. Because even if I try to initiate the FormData object empty ... var requestBody = new FormData(); ... I get the same error. I did not quite understand what you mean by c). Maybe I should have mentioned that I need the routine for some web tests that have to run on CrossBrowserTesting devices. I wanted to avoid opening another browser tab for such actions in parallel to the tested web application. And of course, I can't access desktop applications on these devices at all - if that's necessary for such additional tools. Otherwise could you please outline the use of Fiddler in this context a little closer? Thank you and best regards3.5KViews0likes9CommentsPerforming post request with content-type multipart/form-data (for binary file)
Hi, in a script test, I would like to use the send method to send a binary file, namely a desktop screenshot, formatted in the content type "multipart/form-data". According to the JavaScript code example for theCreatePostRequest MethodI wrote down the following: function httpPostRequest() { var address = "https://example.com/receiver"; // Define the request body FormData-Object var requestBody = new FormData(Sys.Desktop.Picture()); // Create the aqHttpRequest object var aqHttpRequest = aqHttp.CreatePostRequest(address, "", ""); // Specify the Content-Type header value aqHttpRequest.SetHeader("Content-Type", "multipart/form-data"); // Send the request, create the aqHttpResponse object var aqHttpResponse = aqHttpRequest.Send(requestBody); // Check the response: Log.Message(aqHttpResponse.StatusCode); // A status code Log.Message(aqHttpResponse.Text); // A body } But the JavaScript object FormData, which is to be generated in this code, is apparently not supported by TestComplete. The error "ReferenceError: FormData is not defined" appears. Or what am I doing wrong? Is there any other way? Or do I have to build my own function to format the binary code according to the standard (see here)? Thanksin advance for any hint and best regards3.9KViews1like13Comments