Selenium Get_screenshot_as_file Vs Get_screenshot_as_base64?
Solution 1:
With the get_screenshot_as_file, the screenshot get saves into a binary file, while with get_screenshot_as_base64 this will return you base64 encoded version of that screenshot.
So, why would anyone use the base64 version? The whole idea behind base64 is that it allows you to create ASCII representation of binary data, which will increase the data size but will also allow you to actually work with it. For example if you've tried to send over a stream of binary data to a socket, without encoding it then unless server was prepared to handle binary data, the result is hard to predict.
As a result of that the data transferred may be malformed, cut the transfer early and cause many other results that are almost impossible to predict. For example if you were to run a very simple socket server that just prints out everything as it receives to std::out, receiving a binary file would most likely corrupt your console terminal (you can try it on your very own Linux box).
Of course if the server is designed to receive and handle binary data then this will not be an issue, but most often the server-end will interpret user input as string which makes using base64 a wise choice.
Post a Comment for "Selenium Get_screenshot_as_file Vs Get_screenshot_as_base64?"