This is my robot class file content

*** Settings ***
Library    ./robotautogui.py

*** Test Cases ***
move it
    move_mouse_to    600    200

and my custom python library file

import pyautogui

class robotautogui:
    def move_mouse_to(self, x, y, duration=0.0):

        pyautogui.moveTo(x, y, duration)

but running this give error:

move it [ WARN:[email protected]] global loadsave.cpp:244 findDecoder imread_('600'): can't open/read file: check file path/integrity move it | FAIL |

OSError: Failed to read 600 because file is missing, has improper permissions, or is an unsupported or invalid format

OSError: Failed to read 600 because file is missing, has improper permissions, or is an unsupported or invalid format

why is it calling imread (I believe it is image read function). The function is working in python when called directly. But it just don't work in robot framework.

I am trying to convert some python code to robot framework for some automation purposes. Just started and some codes where perfect for starters. But this I just don't know how to tackle.

1

There are 1 best solutions below

4
Pekka On BEST ANSWER

The error message you get from pyautogui is incorrect. Pyautogui requires integer or float values for x and y. Robot Framework variables are strings unless specified.

Workaround is to convert them to integer:

import pyautogui

class robotautogui:
    def move_mouse_to(self, x, y, duration=0.0):
        x = int(x)
        y = int(y)
        duration = float(duration)
        pyautogui.moveTo(x, y, duration)