我试图将一个整数传递给一个执行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
答案 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