有没有办法在Eggplant的另一台机器上检索文本文件值?

时间:2016-01-11 10:22:12

标签: testing automated-tests eggplant

我很难从其他机器上读取文本文件。我已经尝试映射文件,如 \ 10.212.9.20 \ Eggplant \ Test \ propertyfile.txt 。但它不起作用。这是我的代码:

set the itemDelimiter to "="
    repeat with theParams = each line of file "\\10.212.9.20\Eggplant\Test\propertyfile.txt"
    insert item 2 of theParams after myList
end repeat

put item 6 of myList into ServerURL
put item 10 of myList into Username
put item 9 of myList into Password

感谢您的帮助。

2 个答案:

答案 0 :(得分:0)

如果您正在尝试在正在测试的系统上打开文件,可以让eggPlant在文本编辑器中打开文件,然后使用ctrl + a ctrl + c将其文本复制到剪贴板中。然后,您可以解析此文本,就像它是文件一样。

-- Assuming you have located the file and opened it in a text editor.
click(SomeLocationWithinTheTextEditor)
typeText ControlKey, "a" -- select all
typeText ControlKey, "c" -- copy to clipboard

set myTextFile = remoteClipboard(5) -- Wait up to 5 seconds to return the clipboard content

set the item delimiter to "="
repeat for each line of myTextFile
    insert item 2 of it after myList
end repeat

put item 6 of myList into ServerURL
put item 9 of myList into Password
put item 10 of myList into Username

答案 1 :(得分:0)

  

" \ 10.212.9.20 \茄子\测试\ propertyfile.txt"

你在Windows上运行eggPlant吗? Windows上的eggPlant Functional只能解析字母映射驱动器,因此如果您将共享驱动器映射到带有字母的eggPlant机器(即D:\,E :),那么您将能够与另一台机器上保存的文件进行交互:

重复使用Params =每行文件" D:\ Eggplant \ Test \ propertyfile.txt"