我需要与之交互的网页上有一个是/否滑块。我需要单击其中一个元素,以便值从 true 变为 false 或 false 变为 true。使用 id 我可以得到元素的值
find_field('passcode_policies__allow_simple').find('option[selected]').value
但是我一遍又一遍地尝试模拟单击此对象以更改值并且没有成功。
<div class="control-group">
<select class="toggle" id="passcode_policies__allow_simple" name="passcode_policies[][allow_simple]" style="display: none; " tabindex="-1">
<option value="true" selected="selected">Yes</option>
<option value="false">No</option>
</select>
<div class="ui-switch off" tabindex="0">
<div class="ui-switch-mask">
<div class="ui-switch-master" style="left: -38px; ">
<div class="ui-switch-upper">
<span class="ui-switch-handle" style="left: 33px; "></span>
</div>
<div class="ui-switch-lower">
<div class="ui-switch-labels">
<a href="#" class="ui-switch-on" style="width: 17px; " tabindex="-1">Yes</a>
<a href="#" class="ui-switch-off" style="width: 17px; " tabindex="-1">No</a>
</div>
</div>
</div>
</div>
<div class="ui-switch-middle" style="width: 60px; ">
</div>
</div>
<label class="inline">Allow simple value</label>
<span class="help-block">Permit the use of repeating, ascending, and descending character sequences</span>
</div>