Selenium IDE中的代码导出
小号elenium IDE is not sitting still. Since its relaunch last year, 小号elenium IDE developers have been busy responding to user enhancement requests. One highly-requested has just been released – the ability to export code from Selenium IDE for use in 小号elenium WebDriver. Code export from Selenium IDE today works with Java JUnit. The development team is looking for community members like you to add to the capabilities of Selenium IDE.
该代码正在托管中,可在Github上使用。 您可以查看示例并开发自己的导出功能。
但是,首先,这是新功能。
Getting Started
You can export either a test or suite of tests to WebDriver code by right-clicking on a
测试或套件,选择出口,选择目标语言,然后单击出口。
这会将包含导出的目标语言代码的文件保存到浏览器的下载目录中。
Origin Tracing Code Comments
导出时,有一个可选的开关可启用源跟踪代码注释。
这会将内联代码注释放置在导出的文件中,并详细说明生成它的Selenium IDE中的测试步骤。
Supported Exports
当前,Selenium IDE导出到Java。 特别是Java for JUnit。
Selenium IDE团队打算在每种语言的至少一个测试框架中支持Selenium的所有官方支持的编程语言绑定(例如Java,JavaScript,C#,Python和Ruby)。
Contributions are welcome to help add new languages and test frameworks for a given language. See How To Contribute for details on how.
Java JUnit
Java JUnit的导出代码可与Java 8,JUnit 4.12和最新版本的Selenium 3一起使用。
您应该能够将导出的Java文件放入带有列出这些依赖项的pom.xml文件的标准Maven目录结构中并运行它。
Contributing to Code Export for Selenium IDE
代码导出以模块化方式构建,以帮助实现贡献。
每种语言和测试框架都有自己的包含要导出代码的包。 每个代码段都映射到Selenium IDE中的命令,并且每个程序包都依赖于底层的“核心”程序包,该程序包负责所有繁重的工作。
以下是在现有语言中为新语言或新测试框架创建程序包的步骤。
1. Create a new package
首先,复制一个现有的语言包(例如,packages / code-export-java-junit),并将其重命名(例如,package.json文件中的文件夹和详细信息)为您想要贡献的目标语言和框架。 (例如package / code-export-ruby-rspec等)。
Next, add the new package as a dependency to the package.json in code-export.
最后,从项目的根开始运行纱线。
2. Update the locators and commands
代码导出的核心功能是生成特定于语言的字符串。 其中最突出的是命令和定位器策略(例如,“ by”查找的语法)。
对于给定的语言,每种语言都有一个文件,以及随附的测试文件。
您可以在github中看到一个示例:packages / code-export-java-junit。
When declaring new commands you can either specify its output as a string, or as an object which specifies indentation levels).
内置在代码导出中的是一个前缀控件,用于控制输出代码的缩进。 如果命令的输出是冗长的并且您想明确显示,则此结构很有用。 或者,如果命令更改了紧随其后的命令的缩进级别。
3. Create the hooks
挂钩构成了要导出的代码的大部分结构(例如,套件,测试以及其中包含的所有内容,例如设置,拆卸等)。 它们还使插件能够将代码导出到测试或套件的不同部分。
有9个不同的钩子:
- afterAll(所有测试完成后)afterEach(在完成每个测试之后–在afterAll之后)beforeAll(在运行所有测试之前)beforeEach(在运行每个测试之前–在beforeAll之后)命令(为插件添加的新命令发出代码)依赖性(添加其他语言依赖性)inEachBegin(在每个测试的开头)inEachEnd(在每个测试中,在测试结束时)变量(声明将在整个套件中使用的新变量)
See an example of hooks being implemented in packages/code-export-java-junit here: Hooks
4. Update the language specific attributes
在每种语言中,您需要指定一些底层细节。 诸如缩进多少空间,如何声明方法,测试,套件等之类的事情。
Find an example of this being implemented in packages/code-export-java-junit here: Language specific options
5. Add it to the mix
完成所有其他操作后,将其连接起来以在UI中使用。
This is possible in packages/code-export/src/index.js.
您将需要:
- 导入新的代码导出包使用有关您的代码导出语言的详细信息更新可用语言更新导出程序以引用您的代码导出名称并导入
6. Test and tune
最佳的代码导出端到端测试将应用一系列测试,并验证它们是否按预期运行。
从开发版本中,访问种子测试,并验证所有标准库命令均适用于您的新语言。
测试,修复并再次测试,直到您对最终结果充满信心。
7. Submit a PR
You’ve done the hard part. Now simply submit a PR. Please do so against the v3branch.
For More Information on Selenium IDE:
The original version of this article appears in the Selenium IDE documentation site.
Selenium IDE pages
- Selenium IDE documentation
- Selenium IDE tutorial
- Selenium IDE on Google Chrome Store
- Selenium IDE on Firefox Store
- Selenium IDE GitHub page
- Selenium IDE (SIDE Runner) npm page
- Selenium IDE on Stackoverflow
- Selenium IDE on Quora
- Selenium IDE on Reddit
- Selenium IDE on Hackernews
Applitools for Selenium IDE pages
- Applitools for Selenium IDE product page
- Applitools for Selenium IDE documentation
- Applitools for Selenium IDE on Google Chrome Store
- Applitools for Selenium IDE on Firefox Store
Selenium IDE videos
- Selenium IDE tutorial video playlist
- Dave Haeffner presenting Selenium IDE at Selenium Camp
- Dave Haeffner presenting the new Selenium IDE launch webinar
- Tomer Steinfeld on how he built the new Selenium IDE
- Joe Colantonio presentation on Selenum IDE, part one and part two
- Simon Stewart: Selenium IDE – the next generation
- Other Selenium IDE videos
from: https://dev.to//michaelvisualai/code-export-in-selenium-ide-121d