2013-10-15 64 views
1

我有一個小問題,我試圖使用Codeception來運行我的第一個測試階段。要做到這一點,我使用了Selenium2和PrestaShop。我無法使用codeception和Selenium登錄

我試圖實現的第一步是登錄PrestaShop的後臺。

但它似乎不想連接到PrestaShop後臺。我被重定向到登錄頁面!

有誰知道這可以從哪裏來? 似乎有什麼與餅乾或會話,但我不知道如何解決這個問題!

編輯:這裏是我的代碼:

Selenium.suite.yml:

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 

在文件夾測試/硒我有 PrestaShopGlobalCest.php

<?php 
use \SeleniumGuy; 

class PrestaShopModuleListCest 
{ 
    // tests 
    public function install_the_module(SeleniumGuy $I) { 
     PrestaShopGlobalHelper::loginBackoffice($I); 
     PrestaShopGlobalHelper::goToPage($I, 'modules'); 
    } 
} 

_bootstrap.php

<?php 
    Codeception\Util\Autoload::registerSuffix('Helper', __DIR__.'/../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]); 
    } 

} 

回答