我正在尝试用 cypress 测试分页栏。
我想断言仅在此栏中包含数字的按钮数量,并忽略其他按钮(上一页、下一页...)
这些按钮看起来像这样:
<button class="...">33</button>
Run Code Online (Sandbox Code Playgroud)
我首先尝试了这个测试:
cy.get('.pagination')
.find('button')
.contains(/\d+/)
.should('have.length.gte', 2)
Run Code Online (Sandbox Code Playgroud)
但这给了我一个警告,即 contains 只会返回一个元素,使得“长度”测试毫无用处。
我还尝试了许多基于过滤器的组合,即“:contains”jquery关键字,但没有一个有效:
.filter(`:contains('/\d+\')`)
// >> finds nothing
.filter((elt) => { return elt.contains(rx) })
// >> throws 'elt.contains is not a function'
.filter((elt) => { return rx.test(elt.text()) })
// >> throws 'elt.text is not a function'
.filter(() => { return rx.test(Cypress.$(this).text()) })
// filter everything and return nothing, even the buttons containing the text '1'
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试为Visual Studio Code编写扩展,但我无法理解如何读取剪贴板内容。
该VSCode API指定此方法:
readText ():Thenable<String>
按照我阅读的内容Thenable,我应该能够获得这样的剪贴板文本:
var clipboard_content = vscode.env.clipboard.readText().then((text)=>text);
Run Code Online (Sandbox Code Playgroud)
但我设法得到的只是一个Promise { pending }对象。
我想得到的是剪贴板内容作为string
clipboard node.js promise visual-studio-code vscode-extensions