简体   繁体   中英

Running robot framework scripts from batch file: Import Library Error

I have been successfully writing robot framework test scripts (Using Eclipse IDE, RED Robot Editor) and now want to start scheduling them using windows batch files. However, when I try and run the script from a windows command prompt, I'm getting an error (see below). As I mentioned, the scripts worked fine. I would right click on the script file in Eclipse, then Run As -> Robot Test

Here's my error:

Importing test library 'Library' failed: ImportError: No module named Library

At script start up, here's what happens:

__init__.robot

*** Settings ***
Resource    ../Generic_Configurations/Import_File.robot

Import_File.robot

*** Settings ***
Library    Selenium2Library
Library    Library

A couple preliminary questions:

  • Is running my scripts from a command line dependent upon the eclipse environment (RED plugin)? If so, how do I tell the system to pull in those settings?
  • Do I need to set any environmental variables so that the Library.py will be recognized?

Any comments/suggestions appreciated!

Are my scripts dependent upon the eclipse environment (RED plugin)?

Probably not. Robot itself is not dependent on an editing environment. However, it's possible that you are relying on some defaults or command line arguments supplied by your editing environment.

Do I need to set any environmental variables so that the Library.py will be recognized?

Possibly. The rules for how robot finds libraries is well documented. See Configuring where to search libraries and other extensions in the robot framework user guide.

通过在批处理文件顶部使用以下命令,可以解决此问题:

set PYTHONPATH=Libraries

If you get this error, try to add the python Libraries path in environment variable. that should sol

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM