dpb42021 2015-05-24 14:01
浏览 38

在PhantomJS中使用seeElement()时出错

I'm using Codeception to test my Yii2 application.

I switched from the default PhpBrowser into PhantomJS 2 as PhpBrowser can't handle native javascript popup such as 'confirm()' for acceptance testing.

so I change my acceptance.suite.yml configuration into this:

class_name: AcceptanceTester
modules:
    enabled:
        - WebDriver
        - tests\codeception\_support\FixtureHelper
    config:
        WebDriver:
            url: http://www.lppm.local
            browser: firefox
            window_size: 1366x768
            restart: true

and this is my test script:

<?php
use \tests\codeception\_pages\PeriodPage;

$I = new AcceptanceTester\AdminSteps($scenario);
$I->wantTo('Ensure that period access right is working fine');

$I->amGoingTo('Go to period main page');
PeriodPage::openBy($I);
$I->expectTo('See Action Buttons in grid view');
$I->seeElement('.glyphicon-trash');
$I->seeElement('.glyphicon-pencil');

$I->amGoingTo('Create a new period');
$I->click(PeriodPage::$create_button);
$I->seeInCurrentUrl('period/create');
$I->fillField('input[name="Period[name]"]', 'New Period');
$I->fillField('input[name="Period[start_date]"]', '2014-01-01');
$I->fillField('input[name="Period[end_date]"]', '2014-08-01');
$I->click('Create');

$I->expectTo('Redirected to the new period detail page');
$I->seeInCurrentUrl('period/view');
$period_url = $I->grabFromCurrentUrl();


$I->wantTo('Ensure period access right is working fine for normal user');
$normal_user = $I->haveFriend('Normal User');
$normal_user->does(function(\AcceptanceTester\GuestSteps $I) use ($period_url, $scenario){
    $I->login('user', 'user');
    $I->see('User, '.dropdown-toggle');
    $I->wantTo('Ensure that no action button is available in view page');
    $I->amOnPage($period_url);
    $I->dontSee('.btn');

    $I->wantTo('Ensure that no action button is available in index page');
    PeriodPage::openBy($I);
    $I->dontSee(PeriodPage::$create_button);
    $I->dontSeeElement('.glyphicon-trash');
    $I->dontSeeElement('.glyphicon-pencil');
});

but I get this error when I run the script with PhantomJS enabled:

There was 1 failure:

--------- 1) Failed to ensure that period access right is working fine in PeriodAccessRightCept (/var/www/lppm/tests/codeception/acceptance/PeriodAccessRightCept.php) Couldn't see element ".glyphicon-trash": Failed asserting that an array is not empty.

this script is working fine when I use PhpBrowser

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 Centos / PETGEM
    • ¥15 划分vlan后不通了
    • ¥20 用雷电模拟器安装百达屋apk一直闪退