【问题标题】:ExcelRobot - Robot Framework Ride - Import IssueExcelRobot - 机器人框架骑行 - 导入问题
【发布时间】:2020-10-27 03:51:01
【问题描述】:

我已经成功地将ExcelRobot 库导入到 Ride 中,一切看起来都很正常,因为名称没有变成红色。

当我转到测试用例并调用关键字Open Excel 时,它显示该关键字可用。

但是,当我运行测试用例时,我收到了错误Importing test library 'ExcelRobot' failed: ImportError: No module named ExcelRobot

有什么问题?

【问题讨论】:

    标签: python-2.7 robotframework robotframework-ide


    【解决方案1】:

    我不确定您要使用的库。但是我在我的测试套件中使用了“ExcelLibrary”并且它运行良好。

    1. 步骤 01:pip install robotframework-excellibrary
    2. 步骤 02:检查 Python 路径中的库(例如 C:\Python27\Lib\site-packages\ExcelLibrary)
    3. 步骤 03:在测试中导入库

    示例代码:

    *** Settings ***
    Library           ExcelLibrary
    Library           String
    
    *** Variables ***
    ${ExcelLocation}    ExcelTestNumbers.xls
    ${ExcelOutputLocation}    ExcelTestNumbersOutput.xls
    ${ExcelSheetName}    Sheet1
    
    *** Test Cases ***
    NumberRotation
        NumberRotation
    
    *** Keywords ***
    NumberRotation
        ExcelLibrary.Open Excel    ${ExcelLocation}
        ${ExcelRowCount}    ExcelLibrary.Get Row Count    ${ExcelSheetName}
        Log to console    Excel_Row_Count_${ExcelRowCount}
        : FOR    ${LoopCycle}    IN RANGE    ${ExcelRowCount}
        \    Log to console    Loop_Rotation_${LoopCycle}
        \    ${CurrentProcessingNumber}=    ExcelLibrary.Read Cell Data By Coordinates    ${ExcelSheetName}    0    ${LoopCycle}
        \    Log to console    CurrentProcessingNumber_${CurrentProcessingNumber}
        \    ExcelLibrary.Put String to Cell    ${ExcelSheetName}    1    ${LoopCycle}    ExcelSave${LoopCycle}
        \    Save Excel    ${ExcelOutputLocation}
        \    Log to console    Saved
        \    ...    ELSE    NumberInvalid
    

    ExcelLibrary 关键字:http://navinet.github.io/robotframework-excellibrary/ExcelLibrary-KeywordDocumentation.html

    希望这会有所帮助。

    干杯。

    【讨论】:

    • 我也在我的测试中使用了这个库。我也认为导入最好使用 ExcelLibrary。我试图找到 ExcelRobot 的关键字文档,但找不到。
    • 感谢您对@Nipuna 和@Muditha 的支持,我一直在努力使ExcelLibrary 工作,但我总是在Ride(红色)上遇到导入问题,我安装的版本是0.0 .2.在我的 python 2.7 上,我还检查了文件夹 Lib\site-packages 并且该文件夹在那里,我不知道是否有任何与我有冲突的库,也许为了正常工作的一些先决条件没有得到尊重。
    • 由于我无法使用ExcelLibrary,我尝试了robotexcel librayry,关于文档,我使用了链接https://zero-88.github.io/robotframework-excel/docs/ExcelRobot.html。知道任何图书馆有什么问题吗?谢谢
    • 我使用的是 Robot Framework 3.2.1(win32 上的 Python 2.7.11),RIDE 1.7.4.2 在 Python 2.7.11 上运行。实际上 Robotframework 最难的部分是设置环境。无论如何,我的设置 ExcelLibrary 应该可以工作。
    【解决方案2】:

    RIDE 包含作为内部库的robotframework 3.1.2,因此它可以处理关键字文档,甚至可以在未安装robotframework 的系统中作为编辑器工作。此策略还允许在 Python 2.7 中安装 RIDE 1.7.4.2,但在 Python 3 上安装运行 robot

    您报告的错误将落在这种情况下,即正确检测到库导入,但不是在执行时。

    RIDE 的 TestRunner(运行选项卡)准备执行参数到 robot 并调用它,就像从命令窗口、shell 或终端一样。 PATH 环境变量找到的第一个robot 就是运行的那个。

    查看工具->RIDE 记录提及发现 robot 的行,以及 TestRunner 消息。

    【讨论】:

      猜你喜欢
      • 2020-10-24
      • 2020-10-17
      • 2015-04-11
      • 2013-01-26
      • 1970-01-01
      • 2013-06-21
      • 2017-08-06
      • 2020-10-22
      • 1970-01-01
      相关资源
      最近更新 更多