Yii2 Codeception“;请参阅链接“;行为似乎不正确

Yii2 Codeception“;请参阅链接“;行为似乎不正确,yii2,codeception,Yii2,Codeception,我正在使用Codeception版本2.0.16在Yii2中运行一些验收测试。我的单元测试和功能测试工作得很好,但是验收测试似乎显示了一个奇怪的结果。我定义了以下验收测试: I->wantTo('test link discovery'); $I->seeElement(Locator::href('/index-test.php/user/create')); $I->seeLink('Create User'); 现在“href”和链接文本指的是同一个链接。但是,当我运行

我正在使用Codeception版本2.0.16在Yii2中运行一些验收测试。我的单元测试和功能测试工作得很好,但是验收测试似乎显示了一个奇怪的结果。我定义了以下验收测试:

I->wantTo('test link discovery');
$I->seeElement(Locator::href('/index-test.php/user/create'));
$I->seeLink('Create User');
现在“href”和链接文本指的是同一个链接。但是,当我运行此命令时,会出现以下错误:

1) Failed to test link discovery in UserCept (/var/www/localhost/<mysite>/tests/codeception/acceptance/UserCept.php)
Couldn't see link "Create User": Element located either by name, CSS or XPath 'a' was not found on page.  
Scenario Steps:
12. I see link "Create User"
11. I see element "//a[@href=normalize-space('/index-test.php/user/create')]"
1)无法测试UserCept(/var/www/localhost//tests/codeception/acceptance/UserCept.php)中的链接发现
无法看到“创建用户”链接:页面上未找到按名称、CSS或XPath“a”定位的元素。
场景步骤:
12我看到“创建用户”链接
11我看到元素“//a[@href=normalizespace('/index test.php/user/create')”
如您所见,定位器函数查找链接,但“seeLink”请求失败。这是相当令人惊讶的;以下是返回的实际页面:(部分来自“\u输出”结果页面“UserCept.fail”)


切换导航
  • 用户
使用者

显示2项中的1-2项。 # 

(键代码为
) 显然,我可以使用定位器语法来运行测试,但如果有人能解释定位器功能工作正常,但“seeLink”失败的原因,我会非常感激?谢谢。

请在报告问题。请在报告问题
<body>

<div class="wrap">
    <nav role="navigation" class="navbar navbar-fixed-top" id="w1"><div class="container"><div class="navbar-header"><button data-target="#w1-collapse" data-toggle="collapse" class="navbar-toggle" type="button"><span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span></button><a href="/index-test.php" class="navbar-brand">NGO Review</a></div><div class="collapse navbar-collapse" id="w1-collapse"><ul class="navbar-nav navbar-right nav" id="w2"><li><a href="/index-test.php/site/index">Home</a></li>
<li><a href="/index-test.php/site/about">About</a></li>
<li><a href="/index-test.php/site/contact">Contact</a></li>
<li><a href="/index-test.php/site/login">Login</a></li></ul></div></div></nav>
    <div class="container">
        <ul class="breadcrumb"><li><a href="/index-test.php">Home</a></li>
<li class="active">Users</li>
</ul>        <div class="user-index">

    <h1>Users</h1>

    <p>
        <a href="/index-test.php/user/create" class="btn btn-success">Create User</a>    </p>
    <div class="grid-view" id="w0"><div class="summary">Showing <b>1-2</b> of <b>2</b> items.</div>
<table class="table table-striped table-bordered"><thead>
<tr><th>#</th><th><a data-sort="username" href="/index-test.php/user/index?sort=username">E-Mail Address</a></th><th><a data-sort="first_name" href="/index-test.php/user/index?sort=first_name">First Name</a></th><th><a data-sort="last_name" href="/index-test.php/user/index?sort=last_name">Last Name</a></th><th><a data-sort="last_login_time" href="/index-test.php/user/index?sort=last_login_time">Last Login Time</a></th><th class="action-column"> </th></tr>
</thead>