我已经在python脚本中创建了Robot Framework自定义关键字,该关键字返回目录结构中文件的完整文件路径。 我可以单独运行python脚本,但可以得到预期的结果,但是,当我将脚本用作自定义关键字时,返回的列表为空。
感谢任何帮助 参见下面的代码: 机器人代码
Settings
Library FilePaths.py
Test Cases
GetsubmissionFiles
@{List}= get filepaths ////SomeServer//D//TestData//Automation//UK//
这是python代码:
import os
class FilePaths:
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
d = "\\\\SomeServer\\D\\TestData\\Automation\\UK\\"
def get_filepaths(d):
file_paths = []
for root, directories, files in os.walk(d):
for filename in files:
filepath = os.path.join(root, filename)
file_paths.append(filepath)
return file_paths
full_file_paths = get_filepaths(d)
print(full_file_paths)
问题是 Robot Framework导致一个空列表值,没有文件路径 返回值= []
答案 0 :(得分:0)
问题是您没有使用有效的文件路径。对于UNC路径,您只需要使用一个斜杠,而不要使用双斜杠:
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build-jt.js'
},
module: {
rules: [
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
},
{
test: /\.scss$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader'
],
},
{
test: /\.sass$/,
use: [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
],
},
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
// Since sass-loader (weirdly) has SCSS as its default parse mode, we map
// the "scss" and "sass" values for the lang attribute to the right configs here.
// other preprocessors should work out of the box, no loader config like this necessary.
'scss': [
'vue-style-loader',
'css-loader',
'sass-loader'
],
'sass': [
'vue-style-loader',
'css-loader',
'sass-loader?indentedSyntax'
]
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
在您的问题中,您声称它“我可以单独运行python脚本,并且可以得到预期的结果”,但是在python代码中,您使用的是反斜杠。由于在字符串中使用反斜杠,因此必须将它们加倍。如果使用正斜杠,则无需这样做。
换句话说,它在python中有效,但在robot中无效,因为您在python中使用了正确的路径,而在robot中使用了错误的路径。