问题标签 [codeception]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
2437 浏览

laravel - Codeception seeInDatabase() 对我不起作用

我真的被这个验收测试困住了。

我的代码是这个

一切都过去了,直到出现“seeInDatabase”的那一行。日志给了我这个错误“警报:没有找到匹配的记录失败断言'0'大于0。”。

我检查了数据库设置

对我来说似乎很好。我用 seeInDatabase() 仔细检查了一行,我知道它在那里,是的,它工作得很好。(不是 PDO 问题或类似的问题)

所以我在表单的“POST”之后强制在我的控制器中创建只是为了确保

同样,我无法验证这一新行。知道如何解决这个问题吗?

//// 更新 /////

当我用普通 PDO 代码替换 Eloquent Insert 时,一切正常。如何解决这个问题?(完整信息在这里

0 投票
1 回答
3351 浏览

codeception - Codeception Webdriver:获取链接的 href 值

我正在尝试使用 Codeception(使用 webdriver/selenium 进行验收测试)来测试我的应用程序,并希望能够在执行操作后获取链接的值。

基本上我想注销系统,然后单击链接,所以我需要将 url 存储在一个变量中,以便在注销操作后使用。

这是一种像这样的 CMS 操作:

  1. 以管理员身份登录
  2. 创建内容
  3. 创建的内容和显示给用户的链接

我希望那时能够

  1. 获取链接的href值
  2. 登出
  3. 转到 URL 并检查某些页面内容。
0 投票
1 回答
2449 浏览

php - codeception does not see dump.sql

I'm using Yii2 with Codeception. The problem is that Codeception seems to not see the database dump. For simplicity, I consider only LoginCept acceptance tests:

So, when I run

everything runs without errors:

But as soon as I add the following line

the test starts to fail:

Below I put the detailed info from config files.

codeception.yml file has the following content:

The print out of \Yii::$app->db gives:

With the credentials above, I can log in manually to my database (in phpmyadmin).

The database dump is located in F:\site\tests\_data\dump.sql. I've created it from my working database called site and made some modification inside it:

Codeception build command everytime I run it, gives:

0 投票
2 回答
1666 浏览

php - 如何更改 codeception phpbrowser/mink 超时

我正在尝试使用 codeception 创建测试,以检查页面在高负载的情况下是否正常工作。

不幸的是,如果页面负载非常高并且测试开始,我会收到这样的错误:

是否有可能将 Mink 超时设置为更高的值?

0 投票
1 回答
443 浏览

php - CodeCeption seeInDatabase 在查询未返回任何结果时显示通过

在 Project\tests\acceptance\TestCept.php 里面我有类似的东西:

我跑:

我得到:

当我运行以下查询时:

我得到零结果。

我在看什么?当此查询不存在任何记录时,为什么 CodeCeption 返回 PASS?

谢谢

0 投票
1 回答
253 浏览

exception - Laravel 测试和纯文本异常消息

我正在尝试使用带有 Laravel 的 Codeception 来获取可读的错误消息。我找到了如何覆盖 App::error 函数来给我基于文本或 json 的响应。但是,我想以某种方式设置错误,以便在不从测试调用时仅显示 html 错误页面。

我意识到我正在运行的功能测试使用 PhpBrowser 类,所以可能无法检查......

非常感谢任何提示。

下面的代码:

0 投票
1 回答
1459 浏览

php - CodeCeption - 你可以在验收测试中使用 if 语句吗?

这是我的验收测试的代码片段:

代码接收中的 if/else 语句是否可能?我目前有设置值=N,所以 hello world 隐藏在网页上,但 CodeCeption 跳过了 if/else,直接转到“$I->see('hello world');” 并且失败了,因为它没有看到 hello world。* 我看到“hello world”失败

0 投票
0 回答
1051 浏览

testing - 使用 Laravel 4 和 PhpBrowser 重定向代码接收测试失败

与此相关:为什么 Codeception 的 PhpBrowser 不遵循“重新加载”标题?

我正在使用 Laravel 4.1

我无法通过重定向到另一个页面的测试,例如:

测试失败并显示“重定向到 http:// ....”而不是重定向到的页面。

重定向由 Redirect::route($name) 执行

似乎是 PhpBrowser 的问题?

任何解决方法?找不到任何带有解决方案的最新信息。

0 投票
1 回答
692 浏览

php - Codeception - REST - Return xth key from array

I am trying to obtain a key from an array that Codeception is pulling back through it's REST module, more specifically, the 'grabDataFromJsonResponse' method. I would like to pull the first key from that array, as the grabDataFromJsonResponse function lets me select in far enough to only return the data I need. However, Codeception seems to convert it to an object, and thus, I get the wrong key. Below is a codesample, as well as a sample (top of) an array object that Codeception is returning:

The function checkAgainstKey simply does an AssertEquals:

However, the assertEquals will always fail, because the first key is as follows:

Using key() as above returns 'position:protected'. How can I dig into the array and return 123456? The array key represented by 123456 will be dynamic based on the REST response.

Thanks!

0 投票
1 回答
1062 浏览

css - codeception 无法单击 xpath,因为它无法找到 CSS 或 Xpath

任务:我想点击 Craig 的农场标签,但是当我尝试通过 CSS 进行点击时,它在下面给出

错误:CSS 或 XPath '#pageContent.package-menu.container.white.ng-scope>li:nth-child(1)

谁能给我上述代码的确切xpath?

谢谢