好的,我已经有一段时间了,现在是时候问了。 几个小时的搜索让我无处可去。
我正在使用applescript并执行java来: √-加载页面 √延迟 √-自动填充文本字段 从下拉列表中选择X选项 ... 更多要添加但坚持到这里 ...
tell application "Safari"
activate
set VAR to "foo"
tell (make new document) to set URL to "site.exam.pl"
delay 2
do JavaScript "document.forms[1]['edit-title'].value = '" & VAR & "'" in document 1
do JavaScript "document.forms[1]['field_original[und][0][value]'].value = '" & VAR & "'" in document 1
(* Group *)
do JavaScript "$('#edit-field').val('2').change();" in current tab of window 1
结束告诉 取自网站:(略有修改)
<select id="edit-field" name="field_group[foo]" class="form-select required">
<option value="_none">- Select a value -</option>
<option value="3">foo3</option>
<option value="0">foo0</option>
<option value="4">Foo4</option>
<option value="1">foo1</option>
<option value="2">foo2</option>
$('#edit-field').val('2').change();
上正常工作
但是我不能通过这个脚本让它在网站上工作。 我也尝试过:
--do JavaScript document.forms[1][field_group[foo]].value = 2
--do JavaScript document.getElementById
--do JavaScript "document.getElementById ('field_group[foo]').selectedIndex" = 4
--do JavaScript "document.edit-field-group.xxform-select.required.selectedIndex" = 4
--do JavaScript "document.forms['edit-field-group']['field_group[foo]'].option.value = '2'" in front document
--do JavaScript " $('select#'edit-field-group' option:nth-child(1)');" in current tab of window 1
--do JavaScript " $('select#'edit-field-group' option:eq(2)');" in current tab of window 1
--do JavaScript " $('select#edit-field-group option:eq(3)').attr('selected', true);" in current tab of window 1
但我不能让它在网站上工作。 Anyideas?
答案 0 :(得分:1)
这对我有用:
tell application "Safari"
do JavaScript "document.getElementById('edit-field').value = '1'" in document 1
end tell