我希望遍历下拉菜单中存在的所有选项,并能够在每次迭代中单击或选择一个选项。这些选项是从服务器响应创建的,因此菜单中的选项数量并不总是相同的。
下面是下拉菜单的HTML代码:
<select id="filter1" class="form-control abc">
<option value="" selected="selected">text1</option>
<option value="text2">text2</option>
<option value="text3">text3</option><!----></select>这是我对柏树的密码:
cy.wait(2000).get('#filter1').each(($el, index) => {
cy.log("loop index: " + index)
cy.wrap($el).select(index)
})我在控制台中得到一个TypeError : v.replace不是一个函数
我怎么才能解决这个问题?
谢谢
发布于 2021-10-04 14:32:38
我不知道您在何处以及如何使用此.replace方法,您必须在其他地方查找它,但这将满足您所提供的示例的要求:
cy.wait(2000).get('#filter1 option').each(($el, index) => {
cy.log("loop index: " + index)
cy.get('#filter1').select(index)
})https://stackoverflow.com/questions/69437278
复制相似问题