如何在 eclipse 中使用带有 python 的机器人框架以及如何使用 python 解释器在 eclipse 中运行机器人框架测试?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24957694/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:48:40  来源:igfitidea点击:

How to use robot framework with python in eclipse and How to run the Robot framework tests in eclipse using python interpreters?

pythoneclipseselenium-webdriverrobotframework

提问by user3295846

I have installed robot framework plugin into my eclipse. I have added python plugins and interpreter in the path, python files are executing successfully. I have added built-in library index file in the project, created robot text file and i want to execute the test but i right click on the test and try to run as, it is not giving the run configurations. I tried F9 for execution but it is not working. I think there is the separate set up required for running the robot tests in eclipse. my project we don't have access to Maven and client doesn't want Maven. Please let me know how to execute the robot tests in eclipse.

我已经在我的 eclipse 中安装了机器人框架插件。我在路径中添加了python插件和解释器,python文件正在成功执行。我在项目中添加了内置库索引文件,创建了机器人文本文件,我想执行测试,但我右键单击测试并尝试运行,它没有提供运行配置。我试过 F9 执行但它不起作用。我认为在 eclipse 中运行机器人测试需要单独的设置。我的项目我们无权访问 Maven 并且客户不想要 Maven。请让我知道如何在 Eclipse 中执行机器人测试。

Thanks

谢谢

回答by Pablo

You can use RED (Robotframework Editor), an extension for Eclipse available in the Eclipse Marketplace. Once you installed, simply go to "Run -> Run configurations..." and configure a run profile under "Robot". Eclipse will execute the following command on your test:

您可以使用 RED(Robotframework Editor),这是 Eclipse Marketplace 中提供的 Eclipse 扩展。安装后,只需转到“运行 -> 运行配置...”并在“机器人”下配置运行配置文件。Eclipse 将在您的测试中执行以下命令:

/usr/bin/python -m robot.run

You can check the logs in the "Message Log" view, and test results in the "Execution View".

您可以在“消息日志”视图中查看日志,并在“执行视图”中查看测试结果。

回答by Michael Tingey

Here's how I setup my Eclispe to run Pybot for Windows 7. You have to setup "External Tools", I don't have a high enough reputation to post images so see the steps below. Once you've setup an external tools configuration you'll use "Run-->External Tools-->Pybot".

这是我如何设置我的 Eclispe 以运行适用于 Windows 7 的 Pybot。您必须设置“外部工具”,我没有足够高的声誉来发布图像,因此请参阅以下步骤。设置外部工具配置后,您将使用“运行--> 外部工具--> Pybot”。

HTH,

哈,

From the Eclipse tool bar:

从 Eclipse 工具栏:

  1. Run-->External Tools-->External Tools Configurations...
  2. From the "External Tools configurations" pop-up select "Program", then press the New button
  3. Fill in the following setting on the definition screen:
    • Name: Pybot (or a name of your choosing)
    • Location: C:\Python27\Scripts\pybot.bat (path to your pybot.bat file)
    • Working Directory: C:\workspace_42 (your Eclipse workspace)
    • Arguments: "${selected_resource_loc}"
  1. 运行-->外部工具-->外部工具配置...
  2. 从“外部工具配置”弹出窗口中选择“程序”,然后按“新建”按钮
  3. 在定义屏幕上填写以下设置:
    • 名称:Pybot(或您选择的名称)
    • 位置:C:\Python27\Scripts\pybot.bat(pybot.bat 文件的路径)
    • 工作目录:C:\workspace_42(您的 Eclipse 工作区)
    • 参数:“${selected_resource_loc}”

回答by LeonH

If you want to execute Python's flavour of Robot Framework you must use either command line or the Robot IDE (RIDE). To run your tests from the command line you must:
1. Open the terminal
2. Navigate to the appropriate directory
3. Use the pybotcommand and then specify the folder/file containing your tests

如果要执行 Python 风格的 Robot Framework,则必须使用命令行或Robot IDE (RIDE)。要从命令行运行测试,您必须:
1. 打开终端
2. 导航到适当的目录
3. 使用pybot命令,然后指定包含测试的文件夹/文件

eg.

例如。

pybot mytestfolder
pybot myfirsttest.txt