PhantomJs 启用复选框
PhantomJs enable checkboxes
我的网页有多个带复选框的表格。在 UI 上,单击按钮会启用所有复选框。我想使用 phantomjs 自动化这个过程。
我尝试单击 phantomjs 中的按钮 - 它确实单击但未启用复选框。
我尝试启用单个复选框。但它没有启用。
是不是找不到selectAll()?反正有调试phantomjs的吗
function () {
page.evaluate(function () {
if ($("id_SelectAllButton").click())
{
if (!this.checked)
{
document.getElementById("id_checkbox1").disabled = false;
}
}
});
}
<div class='Section1'>
<h3>Section 1</h3>
<table width='90%'>
<tr>
<td colspan='4'> <input id = 'id_SelectAllButton' type='button' value='SelectAll' onclick='selectAll(this.parentElement)'/></td>
</tr>
<tr>
<td></td>
<td class='b'>Name</td>
<td class='b'>DOB</td>
<td class='b'>Rank</td>
</tr>
<tr>
<td><input id='id_checkbox1' type='checkbox'></td>
<td>Abc</td>
<td>01/01/0001</td>
<td>2</td>
</tr>
</table>
</div>
非常感谢您的帮助!
我假设您定位的按钮具有 id="id_SelectAllButton"
属性。如果是这样,您 select 它在 ID 前加上 #
:$("#id_SelectAllButton").click()
。同样,定位任何其他 ID。
我的网页有多个带复选框的表格。在 UI 上,单击按钮会启用所有复选框。我想使用 phantomjs 自动化这个过程。
我尝试单击 phantomjs 中的按钮 - 它确实单击但未启用复选框。 我尝试启用单个复选框。但它没有启用。 是不是找不到selectAll()?反正有调试phantomjs的吗
function () {
page.evaluate(function () {
if ($("id_SelectAllButton").click())
{
if (!this.checked)
{
document.getElementById("id_checkbox1").disabled = false;
}
}
});
}
<div class='Section1'>
<h3>Section 1</h3>
<table width='90%'>
<tr>
<td colspan='4'> <input id = 'id_SelectAllButton' type='button' value='SelectAll' onclick='selectAll(this.parentElement)'/></td>
</tr>
<tr>
<td></td>
<td class='b'>Name</td>
<td class='b'>DOB</td>
<td class='b'>Rank</td>
</tr>
<tr>
<td><input id='id_checkbox1' type='checkbox'></td>
<td>Abc</td>
<td>01/01/0001</td>
<td>2</td>
</tr>
</table>
</div>
非常感谢您的帮助!
我假设您定位的按钮具有 id="id_SelectAllButton"
属性。如果是这样,您 select 它在 ID 前加上 #
:$("#id_SelectAllButton").click()
。同样,定位任何其他 ID。