Firefox AppleScript-如何在没有标题的弹出按钮中选择菜单项?

Firefox AppleScript-如何在没有标题的弹出按钮中选择菜单项?,firefox,applescript,Firefox,Applescript,这里的AppleScript相对较新 我正在尝试创建一个AppleScript来自动将文件/页面另存为。。。Firefox中的操作。具体来说,我需要从另存为中选择“网页,完成”。。。对话框,而不是对话框底部弹出按钮中的默认“所有文件”选择。(我之所以使用Firefox和这个选项,是因为我想在一些JavaScript代码运行后保存当前的html内容,以便为后续处理解析出值) 我已经能够通过使用以下选项选择弹出菜单(没有标题)来解决此问题: ((pop up buttons of window "S

这里的AppleScript相对较新

我正在尝试创建一个AppleScript来自动将文件/页面另存为。。。Firefox中的操作。具体来说,我需要从另存为中选择“网页,完成”。。。对话框,而不是对话框底部弹出按钮中的默认“所有文件”选择。(我之所以使用Firefox和这个选项,是因为我想在一些JavaScript代码运行后保存当前的html内容,以便为后续处理解析出值)

我已经能够通过使用以下选项选择弹出菜单(没有标题)来解决此问题:

((pop up buttons of window "Save As") whose description is "All Files")
通过发送按键“w”在弹出菜单中选择“网页,完成”

我试图找到一种更可靠的方法来实现这一点,而不是依赖于“w”选择我想要的菜单项这一事实。我试过:

click menu item "Web Page, complete" of 
    ((pop up buttons of window "Save As") whose description is "All Files")
但那没用。在查看可访问性检查器时,在弹出按钮(下拉列表)和菜单项之间似乎有一个菜单,但我不知道如何引用它

任何帮助都将不胜感激。以下是完整的脚本:

tell application "Firefox" to activate
delay 0.25

    tell application "System Events"

        tell process "Firefox"
            set frontmost to true

            click menu item "Save Page As…" of menu "File" of menu bar 1
            delay 0.25

            repeat until window "Save As" exists
                delay 0.5
            end repeat

            click ((pop up buttons of window "Save As") whose description is "All Files")
            delay 0.5

            -- This didn't work:
            click menu item "Web Page, complete" of ((pop up buttons of window "Save As") whose description is "All Files")

            -- This works but only because the first entry is "Web Page, complete"
            keystroke "w"
            keystroke return
            delay 0.5

            set outputfilename to "foo3.html" as text

            keystroke outputfilename
            keystroke return

            delay 0.5
      end tell
end tell
试试这个

activate application "Firefox"

tell application "System Events"

    tell process "Firefox"
        set frontmost to true
        click menu item "Save Page As…" of menu "File" of menu bar 1
        repeat until window "Save As" exists
            delay 0.2
        end repeat

        tell window "Save As"
            tell pop up button 1 of group 1
                if value is not "Web Page, complete" then
                    click
                    delay 0.5
                    pick menu item "Web Page, complete" of menu 1
                end if
            end tell

            set outputfilename to "foo3.html"
            keystroke outputfilename
            click button "Save"
        end tell
    end tell
end tell