Javascript 在 AppleScript 'cannot make script into type specifier' 中(用于单击 Chrome 中的按钮)
Javascript within AppleScript 'cannot make script into type specifier' (for clicking button in Chrome)
我正在尝试让苹果脚本点击单选按钮。我对此很陌生。我收到此错误:错误 "Google Chrome got an error: Can’t make theScript of active tab of tab id 1.521810707E+9 of window id 1.52181061E+9 into type specifier." 编号 -1700 来自选项卡 ID 1.521810707E+9 的活动选项卡的脚本 window id 1.52181061E+9 到说明符
代码:
to clickID(theID)
tell application "Google Chrome"
tell window 1 to tell (make new tab)
set its URL to "https://www.colonialfirststate.com.au/FirstNet/FNA/Controls/AdviserHosting.aspx?Page=BusinessReporting"
delay 5
set theScript to "document.getElementById('" & theID & "')'.click();"
execute javascript theScript in active tab
end tell
end tell
结束点击ID
点击ID("optFormatCSV")
这是按钮的屏幕截图和检查元素的副本:
InspectElement
请帮忙:(
您的脚本有几个错误:
tell application "Google Chrome"
tell window 1 to tell (make new tab)
set its URL to "https://www.colonialfirststate.com.au/FirstNet/FNA/Controls/AdviserHosting.aspx?Page=BusinessReporting"
delay 5
set theScript to "document.getElementById('" & theID & "')'.click();"
execute javascript theScript in active tab
end tell
end tell
您在 ".click()"
之前有一个引号,这使得 JavaScript 无效;并且您的目标是 tell (make new tab)
块内的 active tab
。是后者导致了你的错误:
Can’t make theScript of active tab of tab id ... of window id ...
没有 active tab
这样的对象属于 window 1
的 tab id ...
(您刚刚创建的选项卡)。
只需删除对 active tab
的引用,您的代码就可以正常工作。更正后的处理程序应如下所示:
tell application "Google Chrome"
tell window 1 to tell (make new tab)
set its URL to "https://www.colonialfirststate.com.au/FirstNet/FNA/Controls/AdviserHosting.aspx?Page=BusinessReporting"
delay 5
set theScript to "document.getElementById('" & theID & "').click();"
execute javascript theScript
end tell
end tell
系统信息: AppleScript 版本: 2.7
系统版本: 10.13.6
Chrome 版本: 69
我正在尝试让苹果脚本点击单选按钮。我对此很陌生。我收到此错误:错误 "Google Chrome got an error: Can’t make theScript of active tab of tab id 1.521810707E+9 of window id 1.52181061E+9 into type specifier." 编号 -1700 来自选项卡 ID 1.521810707E+9 的活动选项卡的脚本 window id 1.52181061E+9 到说明符
代码:
to clickID(theID)
tell application "Google Chrome"
tell window 1 to tell (make new tab)
set its URL to "https://www.colonialfirststate.com.au/FirstNet/FNA/Controls/AdviserHosting.aspx?Page=BusinessReporting"
delay 5
set theScript to "document.getElementById('" & theID & "')'.click();"
execute javascript theScript in active tab
end tell
end tell
结束点击ID 点击ID("optFormatCSV")
这是按钮的屏幕截图和检查元素的副本:
InspectElement
请帮忙:(
您的脚本有几个错误:
tell application "Google Chrome"
tell window 1 to tell (make new tab)
set its URL to "https://www.colonialfirststate.com.au/FirstNet/FNA/Controls/AdviserHosting.aspx?Page=BusinessReporting"
delay 5
set theScript to "document.getElementById('" & theID & "')'.click();"
execute javascript theScript in active tab
end tell
end tell
您在 ".click()"
之前有一个引号,这使得 JavaScript 无效;并且您的目标是 tell (make new tab)
块内的 active tab
。是后者导致了你的错误:
Can’t make theScript of active tab of tab id ... of window id ...
没有 active tab
这样的对象属于 window 1
的 tab id ...
(您刚刚创建的选项卡)。
只需删除对 active tab
的引用,您的代码就可以正常工作。更正后的处理程序应如下所示:
tell application "Google Chrome"
tell window 1 to tell (make new tab)
set its URL to "https://www.colonialfirststate.com.au/FirstNet/FNA/Controls/AdviserHosting.aspx?Page=BusinessReporting"
delay 5
set theScript to "document.getElementById('" & theID & "').click();"
execute javascript theScript
end tell
end tell
系统信息: AppleScript 版本: 2.7
系统版本: 10.13.6
Chrome 版本: 69