6
我越来越伤心,Selenium和Laravel 5.2
我使用Laravel 5.2,并且正在开发我的单元测试。
在Laravel 5.1,你可以使用大集成的lib用硒,但它似乎并没有在Laravel 5.2
所以基本上工作,有15.2和硒之间的任何一种整合的,或者很好地使用它是不可能的?
在这种情况下,我应该明确地留在L5.1作为测试我的应用程序:(
我越来越伤心,Selenium和Laravel 5.2
我使用Laravel 5.2,并且正在开发我的单元测试。
在Laravel 5.1,你可以使用大集成的lib用硒,但它似乎并没有在Laravel 5.2
所以基本上工作,有15.2和硒之间的任何一种整合的,或者很好地使用它是不可能的?
在这种情况下,我应该明确地留在L5.1作为测试我的应用程序:(
的基本组成部分,您需要使用作曲家
composer require --dev phpunit/phpunit-selenium
创建Selenium测试安装PHPUnit_selenium包里面laravel /测试案例类/
<?php
class SeleniumTestCase extends PHPUnit_Extensions_Selenium2TestCase
{
/**
* The base URL to use while testing the application.
*
* @var string
*/
protected function setUp()
{
$this->setBrowser('firefox');
$this->setBrowserUrl('http://localhost:8000/');
}
protected function visit($path)
{
$this->url($path);
return $this;
}
protected function see($text, $tag = 'body')
{
print_r(request()->session()->all());
//method call by tag name;
$this->assertContains($text,$this->byTag($tag)->text());
return $this;
}
protected function pressByName($text){
$this->byName($text)->click();
return $this;
}
protected function pressByTag(){
$this->byTag('button')->click();
return $this;
}
protected function type($value, $name)
{
$this->byName($name)->value($value);
return $this;
}
protected function hold($seconds){
sleep($seconds);
return $this;
}
}
,并创建新的测试用例访问主页的网址
从终端java -jar /usr/local/bin/selenium-server-standalone-2.35.0.jar
参考文献10
<?php
class ExampleTest extends SeleniumTestCase
{
/**
* A basic functional test example.
*
* @return void
*/
public function testTitle()
{
$this->visit('/')
->see('Site title','title');
}
}
和运行指令的PHPUnit测试:
https://laracasts.com/discuss/channels/testing/has-anyone-tried-laravel-integrated-package-in-laravel-52 – haakym