从applescript将整数传递给javascript

时间:2014-02-12 23:15:29

标签: javascript applescript

我试图将一个整数传递给一个执行javascript语句,以用作javascript中数组的索引。这是可能的,如果是这样的话?

set i to 0
tell active tab of win 
    set failedTests to (execute javascript "document.getElementsByClassName('specDetail failed')[i].getElementsByTagName('a')[0].title") as string                  
end tell

1 个答案:

答案 0 :(得分:1)

尝试:

set i to 0
set jsCommand to "document.getElementsByClassName('specDetail failed')[" & i & "].getElementsByTagName('a')[0].title"

tell application "Google Chrome"
    tell active tab of window 1
        set xxx to execute javascript jsCommand
    end tell
end tell