【发布时间】:2021-07-15 12:18:36
【问题描述】:
我正在使用 cypress 测试我的应用程序。例如,我的表中有 4 个值。
在这种情况下,我想获取具有特定值的行 cypress-farm,然后我想获取具有 cypress-farm 的行的 id 列,但 cypress 获取表中的每个 id 列。有人可以告诉我一个指针怎么做吗?我想念什么 在这种情况下,值“选择器”是 id 列我的问题是 cy.request
上面的行public static addproductToFarm(selector:string, productName:string) {
cy.get(".list").then(($temp1) =>{
cy.get(".list")
.contains("cypress-farm")
.get(selector).then(($temp)=>{
const txt = $temp.text()
cy.request({
url: Cypress.env("api_server") + "products/",
method: 'POST',
form: false,
headers: {
'Content-Type': 'application/json; charset=utf-8',
},
body: {
availability: true,
category: {
hasOthers: false,
id: 1,
indexRanking: 0,
name: "Obst",
shown: true,
subCategories: [
null
]
},
delivery: true,
description: productName,
descriptionExcerpt: "Cypress Product",
farmId: txt,
name: "Apple by Postman",
pickUp: true,
price: 10.00,
quantity: 10,
storageLimit: 10,
unit: "kg",
visibility: true
}
})
})
} )
return this;
}
【问题讨论】:
标签: javascript typescript automated-tests cypress