Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php behat find field错误:调用未定义的方法LoginAuthContext::find()_Php_Behat_Mink - Fatal编程技术网

Php behat find field错误:调用未定义的方法LoginAuthContext::find()

Php behat find field错误:调用未定义的方法LoginAuthContext::find(),php,behat,mink,Php,Behat,Mink,我正在编写behat步骤定义,以便在下面的“登录”页面上自动提交用户名和密码字段。通过使用xpath选择器,我得到了以下错误。请告知我做错了什么?谢谢 致命错误:在中调用未定义的方法LoginAuthContext::find() /第20行的behatlogin/features/bootstrap/LoginAuthContext.php 签到表 <form action="/auth" method="POST" class="ng-pristine ng-valid">

我正在编写behat步骤定义,以便在下面的“登录”页面上自动提交用户名和密码字段。通过使用xpath选择器,我得到了以下错误。请告知我做错了什么?谢谢

致命错误:在中调用未定义的方法LoginAuthContext::find() /第20行的behatlogin/features/bootstrap/LoginAuthContext.php

签到表

<form action="/auth" method="POST" class="ng-pristine ng-valid">
        <input type="text" name="uname" id="uname" class="form-control" placeholder="User name" required="" autofocus="">
        <input type="password" name="pass" id="pass" class="form-control" placeholder="Password" required="">
        <button class="btn btn-lg btn-primary btn-block shadow1" type="submit">Sign in</button>
</form>

出现此错误是因为没有扩展正确的类,并且在当前类中看不到
find()
方法

使用IDE编辑器可以帮助您防止此类问题,因为它应该为您提供该类中可用方法的提示


例如,如果您使用的是页面对象,那么您的
LoginAuthContext
需要扩展
page
,否则对于经典方法,我认为您需要扩展
Context

,这似乎是php错误,而不是javascript错误。添加相关标记以获得相关人员的帮助。添加上下文类和行为文件。您是否从正确的类扩展?我添加了
use-Behat\Behat\Context\Context
使用SensioLabs\Behat\PageObjectExtension\PageObject\Page但仍然给出错误
致命错误:未找到Trait'Behat\Behat\Context\Context
致命错误:Trait SensioLabs\Behat\PageObjectExtension\PageObject\Page not found
请检查页面对象的文档您有好的示例吗?我试过了,但还是不起作用
/**
 * @When /^I am logged in$/
 */
public function iAmLoggedIn()
{
    $this->find('xpath','uname')->setValue('testuname');
    $this->findField('xpath','pass')->setValue('testpass');
    $this->pressButton('Sign in');
}