【问题标题】:Is there a way to retrieve text file values on the other machine in Eggplant?有没有办法在茄子的另一台机器上检索文本文件值?
【发布时间】:2016-03-05 07:35:56
【问题描述】:

我很难从另一台机器上读取文本文件。我已经尝试像 \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

感谢您的帮助。

【问题讨论】:

    标签: testing automated-tests eggplant


    【解决方案1】:

    如果您试图在您正在测试的系统上打开一个文件,您可以让 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
    

    【讨论】:

      【解决方案2】:

      "\10.212.9.20\Eggplant\Test\propertyfile.txt"

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

      用 theParams = 文件“D:\Eggplant\Test\propertyfile.txt”的每一行重复

      【讨论】:

      • 谢谢!但是我在键和值之间有一个分隔符“=”。例如用户名=鲍勃
      • 我需要根据它们各自的键在我的茄子变量上传递参数值。
      猜你喜欢
      • 2014-04-10
      • 1970-01-01
      • 2019-10-10
      • 2010-09-21
      • 2021-06-27
      • 2020-08-31
      • 2011-08-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多