admin管理员组文章数量:1404579
I have the following form:
<form name="security_page_toplevel_page_itsec_settings" method="post" action="options.php">
<select id="itsec_strong_passwords_roll" name="itsec_strong_passwords[roll]">
<option value="admin">admin</option>
<option value="subscriber">subscriber</option>
</select>
</form>
but I am unable to select the "subscriber" option with the following code:
this.fillSelectors('form#security_page_toplevel_page_itsec_settings', {
'select[name="itsec_strong_passwords[roll]"]': 'subscriber'
}, true);
What am I doing wrong?
I have the following form:
<form name="security_page_toplevel_page_itsec_settings" method="post" action="options.php">
<select id="itsec_strong_passwords_roll" name="itsec_strong_passwords[roll]">
<option value="admin">admin</option>
<option value="subscriber">subscriber</option>
</select>
</form>
but I am unable to select the "subscriber" option with the following code:
this.fillSelectors('form#security_page_toplevel_page_itsec_settings', {
'select[name="itsec_strong_passwords[roll]"]': 'subscriber'
}, true);
What am I doing wrong?
Share Improve this question edited Mar 29, 2016 at 19:18 Artjom B. 62k26 gold badges135 silver badges230 bronze badges asked May 8, 2014 at 17:09 SulliSulli 8671 gold badge14 silver badges39 bronze badges 01 Answer
Reset to default 5The name attribute of the form is not the same as the id attribute.
You have to select the form
using
this.fillSelectors('form[name="security_page_toplevel_page_itsec_settings"]', {
'select[name="itsec_strong_passwords[roll]"]': 'subscriber'
}, true);
If this does not work, you could try explicitly setting the select option in the page context:
var index = 2; // the index to select, you may calculate the index programatically from the option value
this.evaluate(function(index) {
var sel = document.querySelector('form[name="security_page_toplevel_page_itsec_settings"] select[name="itsec_strong_passwords[roll]"]');
sel.selectedIndex = index;
sel.onchange();
}, index);
本文标签: javascriptHow to select dropdown option with Casperjs and fillSelectorsStack Overflow
版权声明:本文标题:javascript - How to select dropdown option with Casperjs and fillSelectors - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744837514a2627721.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论