实施selenium facebook';cakephp2中的php Web驱动程序
我试图在CakePHP2的测试中实现facebook的PHP WebDriver() 上下文 我使用的是Ubuntu 16.04、CakePHP2和selenium服务器3.0.0。我可以毫无问题地运行服务器。我还安装了PHPUnit和WebDriver。 我的composer.json如下所示:实施selenium facebook';cakephp2中的php Web驱动程序,selenium,cakephp,testing,Selenium,Cakephp,Testing,我试图在CakePHP2的测试中实现facebook的PHP WebDriver() 上下文 我使用的是Ubuntu 16.04、CakePHP2和selenium服务器3.0.0。我可以毫无问题地运行服务器。我还安装了PHPUnit和WebDriver。 我的composer.json如下所示: { "name": "cakephp/cakephp", "description": "The CakePHP framework", "type": "library",
{
"name": "cakephp/cakephp",
"description": "The CakePHP framework",
"type": "library",
"keywords": ["framework"],
"homepage": "http://cakephp.org",
"license": "MIT",
"authors": [
{
"name": "CakePHP Community",
"homepage": "https://github.com/cakephp/cakephp/graphs/contributors"
}
],
"support": {
"issues": "https://github.com/cakephp/cakephp/issues",
"forum": "http://stackoverflow.com/tags/cakephp",
"irc": "irc://irc.freenode.org/cakephp",
"source": "https://github.com/cakephp/cakephp"
},
"require": {
"php": ">=5.3.0",
"ext-mcrypt": "*",
"facebook/webdriver": "^1.3"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"phpunit/phpunit-selenium": ">=1.2",
"cakephp/debug_kit" : "^2.2.0",
"cakephp/cakephp-codesniffer": "^1.0.0"
},
"bin": [
"lib/Cake/Console/cake"
]
}
<?php
App::uses('UsersController', 'Controller');
use \Facebook\WebDriver\Remote\DesiredCapabilities;
use \Facebook\WebDriver\Remote\RemoteWebDriver;
use \Facebook\WebDriver\WebDriverBy;
/**
* UsersController Test Case
*/
class UsersControllerTest extends PHPUnit_Framework_TestCase {
/**
* @var RemoteWebDriver
*/
protected $webDriver;
/**
* Fixtures
*
* @var array
*/
public $fixtures = array(
'app.user',
// 'app.sale',
// 'app.product',
// 'app.category',
// 'app.products_sale',
// 'app.tag',
// 'app.products_tag',
// 'app.user_address'
);
/**
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
$host = 'http://localhost:4444/wd/hub';
$this->webDriver = RemoteWebDriver::create($host, DesiredCapabilities::chrome());
$this->User = ClassRegistry::init('User');
}
/**
* tearDown method
*
* @return void
*/
public function tearDown() {
unset($this->User);
$this->webDriver->quit();
parent::tearDown();
}
/**
* testIndex method
*
* @return void
*/
public function testIndex() {
$this->markTestIncomplete('testIndex not implemented.');
}
/**
* testView method
*
* @return void
*/
public function testView() {
$this->markTestIncomplete('testView not implemented.');
}
/**
* testAdd method
*
* @return void
*/
public function testAdd() {
$data = array(
'User' => array(
'email' => 'testing@localhost.com',
'password' => 'sample',
'firstname' => 'Kate',
'lastname' => 'Sample',
),
);
$this->testAction('/users/add', array('data' => $data, 'method' => 'post'));
$count = $this->User->find('count', array(
'conditions' => $data['User'],
'contain' => array(),
));
$this->assertEquals(1, $count);
}
/**
* testEdit method
*
* @return void
*/
public function testEdit() {
$this->markTestIncomplete('testEdit not implemented.');
}
/**
* testDelete method
*
* @return void
*/
public function testDelete() {
$this->markTestIncomplete('testDelete not implemented.');
}
}
我执行测试的类如下所示:
{
"name": "cakephp/cakephp",
"description": "The CakePHP framework",
"type": "library",
"keywords": ["framework"],
"homepage": "http://cakephp.org",
"license": "MIT",
"authors": [
{
"name": "CakePHP Community",
"homepage": "https://github.com/cakephp/cakephp/graphs/contributors"
}
],
"support": {
"issues": "https://github.com/cakephp/cakephp/issues",
"forum": "http://stackoverflow.com/tags/cakephp",
"irc": "irc://irc.freenode.org/cakephp",
"source": "https://github.com/cakephp/cakephp"
},
"require": {
"php": ">=5.3.0",
"ext-mcrypt": "*",
"facebook/webdriver": "^1.3"
},
"require-dev": {
"phpunit/phpunit": "3.7.*",
"phpunit/phpunit-selenium": ">=1.2",
"cakephp/debug_kit" : "^2.2.0",
"cakephp/cakephp-codesniffer": "^1.0.0"
},
"bin": [
"lib/Cake/Console/cake"
]
}
<?php
App::uses('UsersController', 'Controller');
use \Facebook\WebDriver\Remote\DesiredCapabilities;
use \Facebook\WebDriver\Remote\RemoteWebDriver;
use \Facebook\WebDriver\WebDriverBy;
/**
* UsersController Test Case
*/
class UsersControllerTest extends PHPUnit_Framework_TestCase {
/**
* @var RemoteWebDriver
*/
protected $webDriver;
/**
* Fixtures
*
* @var array
*/
public $fixtures = array(
'app.user',
// 'app.sale',
// 'app.product',
// 'app.category',
// 'app.products_sale',
// 'app.tag',
// 'app.products_tag',
// 'app.user_address'
);
/**
* setUp method
*
* @return void
*/
public function setUp() {
parent::setUp();
$host = 'http://localhost:4444/wd/hub';
$this->webDriver = RemoteWebDriver::create($host, DesiredCapabilities::chrome());
$this->User = ClassRegistry::init('User');
}
/**
* tearDown method
*
* @return void
*/
public function tearDown() {
unset($this->User);
$this->webDriver->quit();
parent::tearDown();
}
/**
* testIndex method
*
* @return void
*/
public function testIndex() {
$this->markTestIncomplete('testIndex not implemented.');
}
/**
* testView method
*
* @return void
*/
public function testView() {
$this->markTestIncomplete('testView not implemented.');
}
/**
* testAdd method
*
* @return void
*/
public function testAdd() {
$data = array(
'User' => array(
'email' => 'testing@localhost.com',
'password' => 'sample',
'firstname' => 'Kate',
'lastname' => 'Sample',
),
);
$this->testAction('/users/add', array('data' => $data, 'method' => 'post'));
$count = $this->User->find('count', array(
'conditions' => $data['User'],
'contain' => array(),
));
$this->assertEquals(1, $count);
}
/**
* testEdit method
*
* @return void
*/
public function testEdit() {
$this->markTestIncomplete('testEdit not implemented.');
}
/**
* testDelete method
*
* @return void
*/
public function testDelete() {
$this->markTestIncomplete('testDelete not implemented.');
}
}
有人能帮忙吗??
谢谢大家! ==PHP7。升级CakePHP内核,或降级PHP安装。CakePHP 2.8.Hi中引入了PHP7兼容性!这似乎就是问题所在!但现在我有另一个问题:PHP致命错误:在/home/francisco/Escritorio/cakephp/exercises/Ch14/14_03_finish/app/Test/Case/Controller/userscocontrollertest.PHP中找不到类“Facebook\WebDriver\Remote\RemoteWebDriver”class@FranRoaPrieto你能解决这个问题吗?嗨,日本佬。我不记得怎么做了,对不起。我不再使用cakePHP了