I am crawling with CasperJS, but I need to click something to finish the search process of the page at first. But I cannot select the spcific option by its value or its content.
1.Once click the button "All" in the parent frame:
<select name="sort_id" id="sort_id" class="p9"; display: block;" onclick="javascript: window.setTimeout('Hide_Select("sort_id",false)',3); showDialog('LIST','SearchList.aspx?ddl_id=sort_id&key=lar~sort_id&EncodingName=',460,360,true);return false;">
<option value="">All</option>
</select>
2.The page with jump to the child frame:
<div id="b_div" class="ym-body">
<iframe>
#document
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>
</head>
<body>
<form method="post" action="SearchList.aspx?ddl_id=sort_id&key=lar%7esort_id&EncodingName=" id="form1">
<table>
<tbody>
<tr>
<td>
<select size="2" name="listb_sor" id="listb_sor" onchange="javascript:OptionClick(this,'sort_id');" style="height:300px;width:220px;">
<option value="">All</option>
<option value="001">OptionA</option>
<option value="00001">OptionB</option>
</select>
.......
</iframe>
3.I want to select OptionA. If success, the child frame will automatically close. But I cannot sucessfully select OptionA.
Currently my code is:
casper.then(function(){
this.click('#sort_id.p9');
this.page.switchToChildFrame(0);
this.evaluate(function() {
var sel = document.querySelectorAll('#listb_sor option');
sel.val('001').onchange();
});
});
But when I get captured page, it seems the code cannot select OptionA sucessfully.