没有这样的元素:无法找到模态元素

时间:2019-05-26 19:14:23

标签: php laravel automated-tests laravel-dusk

我必须测试此模式框,并且我必须 输入项目名称

<div class="modal fade bs-create-project-modal show" tabindex="-1" role="dialog" aria-labelledby="create-project" style="display: block; padding-right: 14px;">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title mt-0">Create project</h5>                                              
                            <input class="form-control" type="text" name="title" placeholder="Enter project name">
                        </div>
                <button type="submit" class="btn btn-primary waves-effect waves-light">Create project</button>

我尝试过

->type('div.modal .fade .bs-create-project-modal input[name^=title]', 'any') 但收到“没有这样的元素:无法找到元素”

1 个答案:

答案 0 :(得分:0)

您可能需要使用waitFor()来检查模态是否存在。

$dusk->waitFor('input[name^="title"]')
    ->type('input[name^="title"]', 'any')
    ->press('Submit');
相关问题