Php 如何让Codeception在laravel 5.1中打开Firefox?或者如何在laravel 5上使用SPA进行验收测试?
我正在尝试创建验收测试来与reactJS一起工作。我首先让Codeception运行良好,然后添加react。这时我注意到codeception没有启用JS。我试过添加phantomJS:同样的问题。因为我无法调试phantomJS,所以我决定尝试selenium,这样我就可以看到它在firefox中运行。我已经为此工作了几天,Codeception拒绝像正常的selenium测试一样打开firefox 你要问的事情: -是的,每次更改后我都会运行Php 如何让Codeception在laravel 5.1中打开Firefox?或者如何在laravel 5上使用SPA进行验收测试?,php,selenium-webdriver,laravel-5,reactjs,codeception,Php,Selenium Webdriver,Laravel 5,Reactjs,Codeception,我正在尝试创建验收测试来与reactJS一起工作。我首先让Codeception运行良好,然后添加react。这时我注意到codeception没有启用JS。我试过添加phantomJS:同样的问题。因为我无法调试phantomJS,所以我决定尝试selenium,这样我就可以看到它在firefox中运行。我已经为此工作了几天,Codeception拒绝像正常的selenium测试一样打开firefox 你要问的事情: -是的,每次更改后我都会运行codecept build。 -是的,我已经运
codecept build
。
-是的,我已经运行了java-jar-selenium-server-standalone-2.48.0.jar
。尽管这不重要。无论我是否让它运行,测试都没有区别。
-是的,我试过$I->waitForElement(“#随便什么”)
。大约20秒后它就死了。
-不,我有可以使用laravel
以下是我的配置:
acceptance.suite.yml
class_name: AcceptanceTester
modules:
enabled:
- WebDriver:
url: 'http://eagle.app/'
browser: firefox #This does nothing. I literally changed it to `fart` and it didn't error. just same failed tests due to no JS
window_size: 1024x768
capabilities:
webStorageEnabled: true
javascriptEnabled: true
firefox_binary: /Applications/Firefox.app
- \Helper\Acceptance
/测试/验收/AuthCest.php
<?php
//use \AcceptanceTester;
class AuthCest
{
public function _before(AcceptanceTester $I)
{
}
public function _after(AcceptanceTester $I)
{
}
// tests
public function register(AcceptanceTester $I)
{
// This should open firefox/selenium
$I->executeInSelenium(function (Facebook\WebDriver\Remote\RemoteWebDriver $webdriver) {
$handles=$webdriver->getWindowHandles();
$last_window = end($handles);
$webdriver->switchTo()->window($last_window);
});
// This is my original test. I realize its not in executeInSelenium()
// but I'm just showing you what works in non-SPA laravel apps (which doesn't work for me)
$I->switchToWindow();
$I->am('an anonymous user');
$I->wantTo('Register');
$I->amOnPage('/');
$I->wait(1);
$I->see('Laravel 5'); #this is where it dies with react
$I->click('REGISTER');
$I->fillField(['name' => 'name'], 'testuser');
$I->fillField(['name' => 'email'], 'test@user.com');
$I->fillField(['name' => 'password'], 'testuserpass');
$I->fillField(['name' => 'password_confirmation'], 'testuserpass');
$I->click('Register', '#content form');
$I->see('LOG OUT');
$I->click('LOG OUT');
$I->see('REGISTER');
$I->click('LOG IN');
$I->fillField(['name' => 'email'], 'test@user.com');
$I->fillField(['name' => 'password'], 'testuserpass');
$I->click('Login', '#content form');
$I->see('LOG OUT');
}
}
您实际上不需要手动打开firefox,Codeception+Selenium会在您运行时自动打开。/Codeception run acceptance
另外,确保“firefox\u binary”指向正确的路径。您实际上不需要手动打开firefox,Codeception+Selenium会在您运行时自动打开。/Codeception run acceptance 另外,确保“firefox\u二进制文件”指向正确的路径
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
settings:
bootstrap: _bootstrap.php
colors: true
memory_limit: 1024M
extensions:
enabled:
- Codeception\Extension\RunFailed
- Codeception\Extension\Recorder