screenshot is not embedded into the log file of RobotFramework

Asked by masuo on 2016-05-29

I am tring runScript to use Robotframework.
screenshot is stored in the default directory.
But screenshot is not embedded into the log file of RobotFramework log.html
Please provide suggestions.

OS:Windows7
Version:SikuliXIDE1.1.1(2016-05-27_01:01nightly)
RobotFramework Library/Keyword:Screenshot/Take Screenshot

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
2016-06-02
Last query:
2016-06-02
Last reply:
2016-06-01
RaiMan (raimund-hocke) said : #1

please give more information on waht you are trying to do.
Why shold a screenshot be embedded into the ronot log file?

masuo (masuo-ohara) said : #2

According to the following user guide , Take Screenshot takes a screenshot in JPEG format and embeds it into the log file.
http://robotframework.org/robotframework/latest/libraries/Screenshot.html#Take%20Screenshot

I want to know why the result is different from the description .
It is the first time I use Robot Framework, also It is the first time I saw the reports and logs.

[my code:]
runScript("""
robot
*** Variables ***
*** Settings ***
Library ./inline/MyLibrary
Library Dialogs
Library Screenshot
#Test Setup
#Test teardown
*** Test Cases ***
加算テスト:1 + 2
    電卓(calc)を表示する
    calculate addition 1 2
    スクリーンショットを撮る # <----- I use here
    電卓(calc)を閉じる
    テスト結果の判定を入力する
結果判定:
    [Documentation] ここの記述がコメントに出力されるはず
    状態をOKに設定する
    テスト結果を判定する
*** Keywords ***
電卓(calc)を表示する
    open calc
電卓(calc)を閉じる
    close calc

スクリーンショットを撮る
    Take Screenshot # <----- I use here

テスト結果の判定を入力する
    Execute Manual Step 合格なら[PASS]不合格なら[FAIL]をクリックしてください
状態をOKに設定する
    Set Suite Variable ${status} OK
状態をNGに設定する
    Set Suite Variable ${status} NG
テスト結果を判定する
    Should Be Equal ${status} OK
""")

class MyLibrary(object):
    def open_calc(self):
        self.calc = App.open("calc")
        wait("1464443509291.png",10)
    def close_calc(self):
        self.calc.close()
    def calculate_addition(self, a, b):
        type(a)
        sleep(2)
        click(Pattern("1464443542037.png").targetOffset(0,47))
        type(b)
        sleep(2)
        click("1464443598287.png")

RaiMan (raimund-hocke) said : #3

I am surely also not the Robot expert (frankly: never used it before ;-).

The mentioned feature simply does not work (tested on OSX 10.11).
So it is a Robot problem.

masuo (masuo-ohara) said : #5

The result was determined by the following code in librarylogger.py
(AppData\Roaming\Sikulix\Lib\robot\output\librarylogger.py)

if threading.currentThread().getName() in LOGGING_THREADS:
    LOGGER.log_message(Message(msg, level, html))

[in my case]
threading.currentThread().getName():'Thread-10'
LOGGING_THREADS:'MainThread', 'RobotFrameworkTimeoutThread'

When I change code as calling LOGGER.log_message() directly, it works.

Best RaiMan (raimund-hocke) said : #6

... then apparently the library Screenshot somehow missed to register the thread in LOGGING_THREADS

... but that really seems to be a Robot problem.

Why don't you produce your shots with SikuliX features?

masuo (masuo-ohara) said : #7

There is screen capture feature in SikuliX.
But feature of reporting is not in SikuliX, I recognize.
So, I am interested in the feature of reporting in Robot Framework.
Both test case and evidence is listed in the report file.

masuo (masuo-ohara) said : #8

I think this is a Robot problem, so close this question.

masuo (masuo-ohara) said : #9

Thanks RaiMan, that solved my question.

masuo (masuo-ohara) said : #10

Now I am using RobotFramework by adding following codes before robot.run instead of changing librarylogger.py .

from threading import currentThread
currentThread().name = 'MainThread'

RaiMan (raimund-hocke) said : #11

Woooouuw, that's genious.

I will put it into the internal prolog.

RaiMan (raimund-hocke) said : #12

again thanks: added, tested, works ;-)