Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 3.x 从robot框架调用python编码文件时获取FileNotFoundError_Python 3.x_Robotframework - Fatal编程技术网

Python 3.x 从robot框架调用python编码文件时获取FileNotFoundError

Python 3.x 从robot框架调用python编码文件时获取FileNotFoundError,python-3.x,robotframework,Python 3.x,Robotframework,我正在尝试编写一个自动化代码,用于根据我传递给环境的值来选择不同的环境值以执行我的测试用例 以下是我尝试的代码: # env.robot *** Settings *** Variables setup.py stage01 *** Test Cases *** Print values log to console ${data} 我得到的答复是: [ ERROR ] Error in file 'D:\env.robot': Processing variabl

我正在尝试编写一个自动化代码,用于根据我传递给环境的值来选择不同的环境值以执行我的测试用例

以下是我尝试的代码:

# env.robot

*** Settings ***
Variables      setup.py   stage01

*** Test Cases ***
Print values
    log to console  ${data}
我得到的答复是:

[ ERROR ] Error in file 'D:\env.robot': Processing variable file 'D:\setup2.py' with arguments [ stage01 ] 
failed: FileNotFoundError: [Errno 2] No such file or directory: 'values.xlsx'
values.xlsx与.py和.robot文件位于同一目录中

我想根据env变量的值从values.xlsx文件中获取数据,并在robot测试用例中使用这些值


请建议我需要修改的内容或其他方法。

您所说的“同一目录”是什么意思?Python在当前工作目录中查找,该目录可能与脚本所在的目录不同。我的意思是,所有三个文件(.xlsx、.py和.robot)都位于同一文件夹中,而不是Python查找相对文件的位置。Python将在当前工作目录中查找。
[ ERROR ] Error in file 'D:\env.robot': Processing variable file 'D:\setup2.py' with arguments [ stage01 ] 
failed: FileNotFoundError: [Errno 2] No such file or directory: 'values.xlsx'