Dav*_*ave 3 testing f# ui-automation canopy-web-testing
有没有人有功能语言编写UI自动化的例子或经验?我正在学习F#以更好地理解功能概念,我很难弄清楚如何用函数式语言构建自动UI测试 - 似乎很容易使用我在Java中使用的相同页面/屏幕对象模式或C#,但由于缺乏经验,我很好奇,如果我错过了不同的方法.
lef*_*oat 11
使用功能语言的最大胜利来自于根本不必使用课程,但能够在他们是正确的答案时.此外,由于类型推断和语法,F#允许一个漂亮干净的'dsl'外观测试套件.常见操作(例如:登录)很容易抽象为函数并在测试中调用.任何非常特定于页面的功能都可以添加到该页面的模块及其定义功能(css选择器等).
以下是使用遮篷编写的测试示例
test(fun _ ->
//description of the test
describe "registering a user"
//go to root
url "/"
//ensure that you are on the login page
on "/Account/LogOn"
//click the registration link
click "form a[href='/Account/Register']"
//verify that you were redirected
on "/Account/Register"
//set the value of the input to email address specified
"#Email" << "username@example.com"
//set the value of the input to "Password"
"#Password" << "Password"
//set the value of the input to "PasswordConfirmation"
"#PasswordConfirmation" << "Password"
//click the register button
click "input[value='register']"
//verify that you were redirected
on "/"
//log off after test
url "/account/logoff"
)
我在F#中编写了一个Web自动化框架/库(也是Ruby中的一个),到目前为止,虽然我不认为它的样式是功能性的,但它没有任何类.几乎所有东西都是功能.您的测试套件是运行的函数列表.
使用<500 LoC时,只有3个模块,与页面交互的主要功能集,简单的测试运行器和一些配置变量.在这一点上,这种范式对我来说非常有效.我没有使用类来进行页面定义,因为对我来说,页面定义就像我使用的css选择器一样.具有一堆值的模块很好地满足了这个需求.
试一试,我认为你会发现它是实现目标的绝佳方式.
对不起第一次发布所以它不会让我显示更多的链接.查看github,您可以在/canopy/canopy/canopy.fs中查看源代码
| 归档时间: |
|
| 查看次数: |
1359 次 |
| 最近记录: |