博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Bot Style Tests
阅读量:6805 次
发布时间:2019-06-26

本文共 1187 字,大约阅读时间需要 3 分钟。

  hot3.png

Although PageObjects are a useful way of reducing duplication in your tests, it's not always a pattern that teams feel comfortable following. An alternative approach is to follow a more "command-like" style of testing.

 Example:

A "bot" is an action-oriented abstraction over the raw Selenium APIs. This means that if you find that commands aren't doing the Right Thing for your app, it's easy to change them. As an example: public class ActionBot {private final WebDriver driver;public ActionBot(WebDriver driver) {this.driver = driver;}public void click(By locator) {driver.findElement(locator).click();}public void submit(By locator) {driver.findElement(locator).submit();}/** * Type something into an input field. WebDriver doesn't normally clear these* before typing, so this method does that first. It also sends a return key* to move the focus out of the element.*/public void type(By locator, String text) { WebElement element = driver.findElement(locator);element.clear();element.sendKeys(text + "\n");}}

Once these abstractions have been built and duplication in your tests identified, it's possible to layer PageObjects on top of bots.

转载于:https://my.oschina.net/hcp/blog/55860

你可能感兴趣的文章
Java原始的压缩和解压
查看>>
ORACLE系统表和视图说明
查看>>
你在为谁工作
查看>>
5、MySQL多表查询
查看>>
GZIPInputstream解决乱码问题
查看>>
阿里云不能启动docker
查看>>
安装LVS
查看>>
C++入门篇05
查看>>
amoeba搭建及读写分离测试
查看>>
linux系统结构
查看>>
谷歌从Android市场中剔除恶意短信***
查看>>
RH124 第三单元 在图形环境中获取帮助
查看>>
Android第二十三期 - 256k的ListView下拉刷新和滚动加载数据
查看>>
技术团队的打造
查看>>
Juniper NetScreen常见问题汇总
查看>>
arcgis portal使用问题及解决方法
查看>>
nagios 主机组定义
查看>>
用yum来安装或卸载CentOS图形界面包
查看>>
我的友情链接
查看>>
linux
查看>>