gpt4 book ai didi

html-parsing - 无法从 Cypress 中的 html 正文中提取 CSRF token

转载 作者:行者123 更新时间:2023-12-05 07:20:46 25 4
gpt4 key购买 nike

我无法在 Cypress 中从 html 解析 CSRF token 。我正在关注此链接:Logging in using CSRF Token in Cypress

尝试遵循上述链接中的策略#1,但我一直收到未定义的 token 。

这是我的 html 的样子:

Return html looks like this

我的代码是这样的:

           cy.request({
url: returnUrlFromLoginAPI,
followRedirect: false
})
.its('body')
.then((body) => {
const $html = Cypress.$(body)
const requestVerificationToken = $html.find("input[name=__RequestVerificationToken]").val()
console.log(requestVerificationToken)
})
})

最佳答案

.find 查找当前元素集的后代,而我的元标记是该集的一部分,而不是后代。这就是你应该使用 .filter 的原因,因为过滤器会查找当前集及其后代

关于html-parsing - 无法从 Cypress 中的 html 正文中提取 CSRF token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57344228/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com