0

我已经设法将ExcelRobot库导入到 Ride 中,因为名称没有变红,所以一切看起来都很正常。 在此处输入图像描述

当我转到测试用例并调用关键字Open Excel时,它显示关键字可用。 在此处输入图像描述

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

有什么问题?

4

2 回答 2

3

我不确定您要使用的库。但是我在我的测试套件中使用了“ExcelLibrary”并且它工作得很好。

  1. 步骤01:点安装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

希望这可以帮助。

干杯。

于 2020-07-07T05:44:37.880 回答
2

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

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

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

请参阅 Tools->RIDE 记录提及所robot找到内容的行,以及 TestRunner 消息。

于 2020-07-07T22:50:56.357 回答