有没有办法在eggPlant中从excel、文本文件等外部数据表中读取数据?
当对不同的输入参数集运行相同的脚本时,这将证明这对我很有用,而不是对值进行硬编码。
-Siva
发布于 2018-07-26 22:46:23
由于这是浏览量最大的茄子问题,我将给它一个更有力的答案。
是的!使用数据文件中的数据是一种奇妙的方法,可以在不进行硬编码的情况下将测试参数化!
保存数据
为此,您必须将数据以.csv或.txt格式保存在套件的Resources目录中。这使您可以在Eggplant中打开它并进行交互。
导入数据
在脚本中,您可以仅使用文件名引用这些数据文件,例如,
put ResourcePath("myData.txt") into FilePath将整个文件myData.txt从资源目录保存到一个变量FilePath中。
访问数据
然后,您可以像访问任何其他文件一样访问该文件的每一行。
put line 1 of file FilePath into Name
put line 2 of file FilePath into DOB如果将数据另存为.csv,则可以指定特定数据的行和列。
put item 2 in line 1 of file FilePath into Last_NameRead more about reading files in the Eggplant Documentation!
For more complicated resource files, read this page in the Eggplant Documentation!
发布于 2013-01-10 18:59:07
1. Enter the data in the excel sheet and save it as a CSV file.
2. Piece of code:
repeat with theData= each line of file "D:\TestData.csv"
log item 1 of theData
end repeathttps://stackoverflow.com/questions/14212319
复制相似问题