Cookies 我能';t使用codeception和Selenium登录
我有一个小问题,我正在尝试使用Codeception来运行我的第一个测试阶段。为了做到这一点,我使用了硒2和预吸 我尝试实现的第一步是登录PrestaShop的后台 但它似乎不想连接到PrestaShop后台。我被重定向到登录页面 有人知道这是从哪里来的吗? 看起来cookies或会话有问题,但我不知道如何解决 编辑:以下是我的代码: Selenium.suite.yml:Cookies 我能';t使用codeception和Selenium登录,cookies,prestashop,codeception,Cookies,Prestashop,Codeception,我有一个小问题,我正在尝试使用Codeception来运行我的第一个测试阶段。为了做到这一点,我使用了硒2和预吸 我尝试实现的第一步是登录PrestaShop的后台 但它似乎不想连接到PrestaShop后台。我被重定向到登录页面 有人知道这是从哪里来的吗? 看起来cookies或会话有问题,但我不知道如何解决 编辑:以下是我的代码: Selenium.suite.yml: class_name: SeleniumGuy modules: enabled: - Sele
class_name: SeleniumGuy
modules:
enabled:
- SeleniumHelper
- Selenium2
config:
Selenium2:
url: 'http://localhost/Sites/PrestaShop1.5.4/'
browser: 'firefox'
capabilities:
unexpectedAlertBehaviour: 'accept'
codeception.yml
paths:
tests: tests
log: tests/_log
data: tests/_data
helpers: tests/_helpers
settings:
bootstrap: _bootstrap.php
suite_class: \PHPUnit_Framework_TestSuite
colors: false
memory_limit: 1024M
log: true
modules:
config:
Db:
dsn: ''
user: 'root'
password: 'root'
dump: tests/_data/dump.sql
在tests/Selenium文件夹中,我有
prestashopglobaltest.php
<?php
use \SeleniumGuy;
class PrestaShopModuleListCest
{
// tests
public function install_the_module(SeleniumGuy $I) {
PrestaShopGlobalHelper::loginBackoffice($I);
PrestaShopGlobalHelper::goToPage($I, 'modules');
}
}
在tests/helpers/Selenium中,我有
PrestaShopGlobalHelper
<?php
use \SeleniumGuy;
class PrestaShopGlobalHelper
{
static $mainTabID = array(
'modules' => 'maintab15'
);
static $menuLink = array(
'modules' => '#maintab15 .submenu li:first'
);
// tests
static public function loginBackOffice(SeleniumGuy $I) {
$I->wantTo('Login in Backoffice');
$I->amOnPage('/bb');
PrestaShopGlobalHelper::login($I);
}
static public function login(SeleniumGuy $I, $login = '****', $pass = '****')
{
$I->fillField('#email',$login);
$I->fillField('#passwd',$pass);
$I->click('Connexion');
}
static public function goToPage(SeleniumGuy $I, $page)
{
$I->moveMouseOver('#'.self::$mainTabID[$page]);
$I->click(self::$menuLink[$page]);
}
}
我发现了问题所在:
我在Selenium2.yml中添加了一个显式等待时间。
下一步是在Selenium2模块中添加隐式等待,但这是不可配置的,我没有时间尝试扩展该类:
我发现了问题所在:
我在Selenium2.yml中添加了一个显式等待时间。
下一步是在Selenium2模块中添加隐式等待,但这是不可配置的,我没有时间尝试扩展该类:
<?php
use \SeleniumGuy;
class PrestaShopGlobalHelper
{
static $mainTabID = array(
'modules' => 'maintab15'
);
static $menuLink = array(
'modules' => '#maintab15 .submenu li:first'
);
// tests
static public function loginBackOffice(SeleniumGuy $I) {
$I->wantTo('Login in Backoffice');
$I->amOnPage('/bb');
PrestaShopGlobalHelper::login($I);
}
static public function login(SeleniumGuy $I, $login = '****', $pass = '****')
{
$I->fillField('#email',$login);
$I->fillField('#passwd',$pass);
$I->click('Connexion');
}
static public function goToPage(SeleniumGuy $I, $page)
{
$I->moveMouseOver('#'.self::$mainTabID[$page]);
$I->click(self::$menuLink[$page]);
}
}