Forum Discussion
Hi,
> since the FormData object is not supported by TestComplete
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.
> could you please outline the use of Fiddler in this context a little closer?
The suggestion is based on the assumption that you don't need to send some specific file in your test but it is acceptable if the same file is sent every time.
If this assumption is correct, then you may use Fiddler or any other request-capturing tool to capture the request that sends some small (for performance considerations) file. The captured request will provide you with the already properly encoded body part. So you may store it in some file or as a constant string in test code and use in the test.
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 regards
- AlexKaras8 years agoCommunity Hero
Hi,
Once again in order to double-check:
Do you *really* need to send *different* files from your test? Won't sending of the same file work?
- TestKeks8 years agoOccasional Contributor
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 respective CrossBrowserTesting 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 regards
- AlexKaras8 years agoCommunity Hero
Hi,
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.
https://support.smartbear.com/testcomplete/docs/reference/program-objects/picture/savetofile.html describes how to save the screenshot to the file.