使用CasperJS以特定格式单击具有可变属性值的元素

Clicking on an element with a variable attribute value in a certain format with CasperJS

本文关键字:属性 元素 CasperJS 定格 单击 格式 使用      更新时间:2023-09-26

我有这个代码片段可以在CasperJS中单击按钮。

this.click('input[name="suggestion-to-repeat:5:suggestion:subForm:select-email"]');

问题是,名称中有一个可变数字。在本例中,"5"。数字可以在1-10之间。是否有机会使用通配符或任何其他选择按钮的可能性?

查看https://www.w3.org/TR/selectors/#selectors以下内容可能会有所帮助:

E[foo^="bar"]一个E元素,其"foo"属性值完全以字符串"bar"开头
E[foo$="bar"]一个E元素,其"foo"属性值以字符串"bar"结束

尝试:

 'input[Name^="suggestion-to-repeat:"][Name$=":suggestion:subForm:select-email"]'