赛普拉斯:检查列是否有正确的数据
我创建了测试用例,从表中获取所有信息,在此表中有用户。 姓名, 角色, 地位, 列出了最后一个活动状态,我根据用户的ID选择每一行,我之前从API中获取ID信息,我无法通过API主张它们,因为只有“ ID”,“电子邮件”和“ name”信息,其他信息不可用。 如何测试列角色,状态,最后一个活动状态具有正确的数据?事先感谢您的所有想法。
表的示例;
名称|电子邮件|角色|状态|最后一个活动
user00 | 医生|活动| 1小时前
user01 | 工程师|活动| 2分钟前
user02 | 医生|等待| 2个月前
user03 | 警察|不活动| 11天前*
子元素和[7]子元素不需要检查)
<table>
<tbody class="TableBody-root">
<tr class="TableRow-root user_12341234blabla">
<td class"TableCell-root TableCell-body width">
<td class"TableCell-root TableCell-body">user00</td>
<td class"TableCell-root TableCell-body">[email protected]</td>
<td class"TableCell-root TableCell-body">Doctor</td>
<td class"TableCell-root TableCell-body">Active</td>
<td class"TableCell-root TableCell-body">1 hour ago</td>
<td class"TableCell-root TableCell-body stngs">
</tr>
<tr class="TableRow-root user_42241234alsbla">
<td class"TableCell-root TableCell-body width">
<td class"TableCell-root TableCell-body">user01</td>
<td class"TableCell-root TableCell-body">[email protected]</td>
<td class"TableCell-root TableCell-body">Engineer</td>
<td class"TableCell-root TableCell-body">Active</td>
<td class"TableCell-root TableCell-body">2 minutes ago</td>
<td class"TableCell-root TableCell-body stngs">
</tr>
<tr class="TableRow-root user_3554a234alsbla">
<td class"TableCell-root TableCell-body width">
<td class"TableCell-root TableCell-body">user02</td>
<td class"TableCell-root TableCell-body">[email protected]</td>
<td class"TableCell-root TableCell-body">Doctorr</td>
<td class"TableCell-root TableCell-body">Pending</td>
<td class"TableCell-root TableCell-body">2 months ago</td>
<td class"TableCell-root TableCell-body stngs">
</tr>
<tr class="TableRow-root user_87941234sasbla">
<td class"TableCell-root TableCell-body width">
<td class"TableCell-root TableCell-body">user03</td>
<td class"TableCell-root TableCell-body">[email protected]</td>
<td class"TableCell-root TableCell-body">Police</td>
<td class"TableCell-root TableCell-body">Inactive</td>
<td class"TableCell-root TableCell-body">11 days ago</td>
<td class"TableCell-root TableCell-body stngs">
</tr>
</tbody>
</table>
html部分的示例([1 ] 代码;
cy.wait("@getUsers")
.its("response.body")
.its("user")
.then(user => {
for (let i = 0; i < user.length; i++) {
for (let a = 2; a <= 6; a++) {
cy.get(`.user_${user[i].id}>:nth-child(${a})`)
.invoke("text")
.then(userInfo => {
expect(userInfo).to.equal() // here i stuck
});
}
}
**Its response.body**
user [ {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, … ]
0 Object { id: "user_12341234blabla", name: "user00", email: "[email protected]", … }
1 Object { id: "user_42241234alsbla", name: "user01", email: "[email protected]", … }
2 Object { id: "user_3554a234alsbla", name: "user02", email: "[email protected]", … }
3 Object { id: "user_87941234sasbla", name: "user03", email: "[email protected]", … }
**Under the object [0]**
id "12341234blabla"
name "user00"
email "[email protected]"
locale "en"
receive_notifications true
current_sign_in_at "2022-06-14T00:36:41.240+02:00"
created_at "2022-02-10T10:25:45.333+01:00"
updated_at "2022-06-14T00:36:41.240+02:00"
unconfirmed_email null
pending_reconfirmation false
confirmation_sent_at null
confirmation_period_expired null
is_invited false //if its true it means status is pending otherwise active or inactive
is_managed_externally false
roles_without_context [ {…} ]
resource_role_users [ {…} ]
invitee_invitations []
**Under roles_without_context [{...}]**
0 Object { id: "0a79-43ee-ae43",
created_at: "2022-02-10T10:25:45.345+01:00",
updated_at: "2022-02-10T10:25:45.345+01:00", … }
id "0a79-43ee-ae43"
context_type null
context_id null
role null
created_at "2022-02-10T10:25:45.345+01:00"
updated_at "2022-02-10T10:25:45.345+01:00"
locked true
name "Doctor" //it shows role
clm_name null
client_id "8506-d772d917af86"
I have created test case that gets all informations from table, in this table there is Users;
Name,
Role,
Status,
Last active statuses are listed, I select each line according to the user's id, I get the id information from the API before, I cannot assert them through the API because there are only "id","email" and " name" information, other information is not available.
How can I test that columns Role,Status, Last active status has the correct data? Thanks in advance for all the ideas.
Example of table;
Name |Email | Roles | Status | Last active
user00 |[email protected] | Doctor | Active | 1 hour ago
user01 |[email protected] | Engineer | Active |2 minutes ago
user02 |[email protected] | Doctor | Pending | 2 months ago
user03 |[email protected] | Police |Inactive | 11 days ago*
Example of html part ( [1]child element and [7] child element are not necessary to check)
<table>
<tbody class="TableBody-root">
<tr class="TableRow-root user_12341234blabla">
<td class"TableCell-root TableCell-body width">
<td class"TableCell-root TableCell-body">user00</td>
<td class"TableCell-root TableCell-body">[email protected]</td>
<td class"TableCell-root TableCell-body">Doctor</td>
<td class"TableCell-root TableCell-body">Active</td>
<td class"TableCell-root TableCell-body">1 hour ago</td>
<td class"TableCell-root TableCell-body stngs">
</tr>
<tr class="TableRow-root user_42241234alsbla">
<td class"TableCell-root TableCell-body width">
<td class"TableCell-root TableCell-body">user01</td>
<td class"TableCell-root TableCell-body">[email protected]</td>
<td class"TableCell-root TableCell-body">Engineer</td>
<td class"TableCell-root TableCell-body">Active</td>
<td class"TableCell-root TableCell-body">2 minutes ago</td>
<td class"TableCell-root TableCell-body stngs">
</tr>
<tr class="TableRow-root user_3554a234alsbla">
<td class"TableCell-root TableCell-body width">
<td class"TableCell-root TableCell-body">user02</td>
<td class"TableCell-root TableCell-body">[email protected]</td>
<td class"TableCell-root TableCell-body">Doctorr</td>
<td class"TableCell-root TableCell-body">Pending</td>
<td class"TableCell-root TableCell-body">2 months ago</td>
<td class"TableCell-root TableCell-body stngs">
</tr>
<tr class="TableRow-root user_87941234sasbla">
<td class"TableCell-root TableCell-body width">
<td class"TableCell-root TableCell-body">user03</td>
<td class"TableCell-root TableCell-body">[email protected]</td>
<td class"TableCell-root TableCell-body">Police</td>
<td class"TableCell-root TableCell-body">Inactive</td>
<td class"TableCell-root TableCell-body">11 days ago</td>
<td class"TableCell-root TableCell-body stngs">
</tr>
</tbody>
</table>
And this is my code;
cy.wait("@getUsers")
.its("response.body")
.its("user")
.then(user => {
for (let i = 0; i < user.length; i++) {
for (let a = 2; a <= 6; a++) {
cy.get(`.user_${user[i].id}>:nth-child(${a})`)
.invoke("text")
.then(userInfo => {
expect(userInfo).to.equal() // here i stuck
});
}
}
**Its response.body**
user [ {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, … ]
0 Object { id: "user_12341234blabla", name: "user00", email: "[email protected]", … }
1 Object { id: "user_42241234alsbla", name: "user01", email: "[email protected]", … }
2 Object { id: "user_3554a234alsbla", name: "user02", email: "[email protected]", … }
3 Object { id: "user_87941234sasbla", name: "user03", email: "[email protected]", … }
**Under the object [0]**
id "12341234blabla"
name "user00"
email "[email protected]"
locale "en"
receive_notifications true
current_sign_in_at "2022-06-14T00:36:41.240+02:00"
created_at "2022-02-10T10:25:45.333+01:00"
updated_at "2022-06-14T00:36:41.240+02:00"
unconfirmed_email null
pending_reconfirmation false
confirmation_sent_at null
confirmation_period_expired null
is_invited false //if its true it means status is pending otherwise active or inactive
is_managed_externally false
roles_without_context [ {…} ]
resource_role_users [ {…} ]
invitee_invitations []
**Under roles_without_context [{...}]**
0 Object { id: "0a79-43ee-ae43",
created_at: "2022-02-10T10:25:45.345+01:00",
updated_at: "2022-02-10T10:25:45.345+01:00", … }
id "0a79-43ee-ae43"
context_type null
context_id null
role null
created_at "2022-02-10T10:25:45.345+01:00"
updated_at "2022-02-10T10:25:45.345+01:00"
locked true
name "Doctor" //it shows role
clm_name null
client_id "8506-d772d917af86"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否需要在
用户
对象上进行比较的值?使用
console.log(user)
检查一下
Are the values you need to compare on the
user
object?Check it out with
console.log(user)
, for example ifuser
looks likethen in the test (roughly)