robotcodedev / robotcode

RobotFramework support for Visual Studio Code
https://robotcode.io
Apache License 2.0
173 stars 14 forks source link

[BUG] Cant Load Photos to Simple Browser #146

Closed Alpha-Centauri-00 closed 1 year ago

Alpha-Centauri-00 commented 1 year ago

Describe the bug when using "Log" Keyword to load a photo in Log.html it works fine when i open the log in normal browser but not in Simple Browser.

To Reproduce create a new test case and use Log Keyword like this:


***Test Cases***
a simple test
    Log    <img src="PATH_TO_Image.jpg" width="150" height="100"/>    html=True

Expected behavior I'd like to see the photo in Siple Browser

Screenshots/ Videos image

Logs

Desktop (please complete the following information):

d-biehl commented 1 year ago

Hello,

this is not a bug. it works as expected. Due to security reasons in vscode it is not possible to load html files in simple browser from the local file system and you can run vscode in remote scenarios like ssh, wsl, docker or github codespaces or gitpod, where you don't have real acces to the filesystem. Thats why RobotCode starts internally a simple web server to show the log-files in simple browser. This web server sees only the project folder and ignores full paths to the filessystem.

As I see in you screenshots you use full paths to your images. If the files are in you project folder you can use it like this:

*** Test Cases ***
first
    Log    <img src="/images/demo.png" width="150" height="100"/>    html=True

Another approach, and in most cases it is the best approach, you can embed your image directly to the logfile. Browser-Library and SeleniumLibrary do this by default.

Unfortunately, since there is no standard way to do this, you will have to search the Internet for suggestions. As I remember correctly you have to convert the image to a base64 decoded string and then you can write something like

*** Test Cases ***
first
    ${data}   Decode file to Base64   ${PATH_TO_Image.jpg}
    Log    <img src="data:image/png;base64, ${data}">" width="150" height="100"/>    html=True

You have to implement the "Decode file to Base64" keyword, at the moment I have no code for this, but you can find examples in the internet.

Alpha-Centauri-00 commented 1 year ago

Danke für deine Antwort. @d-biehl