小编ole*_*tar的帖子

在Chrome和IE中启动phpunit-selenium2测试

我使用本教程http://net.tutsplus.com/tutorials/php/how-to-use-selenium-2-with-phpunit/创建了测试.一切正常,但我只能在Firefox上启动此测试.我在互联网上阅读了很多关于此的文章,但我找不到任何解决方案.我有Sebastian Bergmann的Windows XP,PHP 5.4.7,PHPUnit 3.7.13.在运行测试之前,我启动了selenium-server-standalone-2.28.0.jar.有我的考试

<?php
class Example extends PHPUnit_Extensions_Selenium2TestCase
{   protected function setUp()
    {   
    $this->setBrowser("firefox");
        $this->setBrowserUrl('http://test.com/');
    }

    public function testogin()
    {
        $this->url('http://test.com/');
        $this->timeouts()->implicitWait(10000);
        $username = $this->byId('user_login');
        $username->value('test.ru');
        $password = $this->byId('user_pass');
        $password->value('test');
        $this->byId('login_btn')->click();
    }
}
?>
Run Code Online (Sandbox Code Playgroud)

请帮我在其他浏览器上运行此测试.如果您需要更多信息,请问我.谢谢

phpunit selenium-webdriver

11
推荐指数
2
解决办法
5888
查看次数

如何在Sinon中过滤请求

我在Jasmine中为Backbone应用程序编写单元测试.当然,我在测试中使用了Sinon.但现在我有问题.我正在为登录屏幕编写测试,我需要模拟服务器响应 - 因为服务器工作非常糟糕.现在我的代码看起来:

describe('Login', function(){
     it('Should simulate server response', function(){
        server = sinon.fakeServer.create();
        server.respondWith("GET", "http:\\example.com", [200, {"Content-Type": "application/json"}, '{"Body:""asd"}'])
     })
     $('body').find('button#login').trigger('click');
     server.respond();
     server.restore()
     console.log(server.requests);
})
Run Code Online (Sandbox Code Playgroud)

这段代码运行正常,但是我在控制台中看到假冒所有请求,但在登录期间我也有其他请求,我不需要使用假服务器.这是下一个屏幕的要求.也许存在对特殊请求进行过滤或使用虚假响应的方法.请帮帮我.谢谢.

javascript jasmine sinon

9
推荐指数
1
解决办法
2105
查看次数

标签 统计

jasmine ×1

javascript ×1

phpunit ×1

selenium-webdriver ×1

sinon ×1