在我的验收测试中,我想模拟后退按钮点击和结果转换.
我有以下,但我有一种感觉是错的.
- test("back to search page",function(){
- visit('/')
- .then(function(){
- return fillIn('.search input','hi');
- })
- .then(function(){
- return click('.search button');
- })
- .then(function(){
- // I want to go back here
- return visit('/');
- })
- .then(function(){
- var keyword = find('.search input').val();
- equal(keyword,'');
- ok(!exists('.search .results'));
- });
- })
在测试中模拟返回按钮的正确方法是什么?
解决方法
window.history.back()或window.history.go(-1)