ExcelRobot - Robot Framework Ride - 导入问题

ExcelRobot - Robot Framework Ride - Import Issue

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

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

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

有什么问题吗?

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

  1. 第一步:pip安装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

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

希望对您有所帮助。

干杯。

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

中安装 运行 robot

您报告的错误属于这种情况,正确检测到库导入,但在执行时未检测到。

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

查看工具->RIDE 记录提及发现robot 内容的行,以及测试运行ner 消息。