Home > OS >  Import Python Library in RobotFramework Unicode Issue
Import Python Library in RobotFramework Unicode Issue

Time:03-23

I´m completely new in robotframework and i´m trying to import a python custom library that creates a folder

Python Library

import os

def CrearFolder():
os.mkdir("C:\Users\manuel.lopez\PycharmProjects\Curso_RobotFramework\DEMO_CARPETA")

RobotFramework Script

*** Settings ***
Documentation   Create a folder from Python
Library    SeleniumLibrary
Library    C:\\Scripts_Python\\Keywords_Python.py

*** Variables ***
${url}=     https://demoqa.com/text-box
${navegador}=   chrome

*** Test Cases ***
Test uno
       [Documentation]
       [Tags]    Test_uno
       #Tiempo para todas nuestras funciones

       Crear Carpeta Desde Python

       close browser

 *** Keywords ***
 Crear Carpeta desde Python
      Crear_Folder

The problem is that when i execute the script i get always the next error, i´ve tried with different slash, scape characters, moving the Python Library outside and changing the path and adding the path to PYTHONPATH but nothing changes, any suggestion?

[ ERROR ] Error in file 'C:\Users\manuel.lopez\PycharmProjects\Curso_RobotFramework\Test_Case_Nivel3\Keywords_python1.robot' on line 4: Importing library 'C:\Scripts_Python\Keywords_Pytho n.py' failed: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape (Keywords_Python.py, line 6) Traceback (most recent call last):

CodePudding user response:

You can find the ans here: https://stackoverflow.com/a/1347854/17663093

You need to add your path in double quotes too.

  • Related