【问题标题】:Dismissing Modal from Script / osx 10.7+ / safari / automator / objective-c从脚本 / osx 10.7+ / safari / automator / objective-c 中消除模态
【发布时间】:2013-07-06 05:08:17
【问题描述】:

我正在尝试将焦点放在 safari 浏览器模式框并控制其输入和关闭。

示例:导航到一个网站,它会抛出一个模态框,是否可以创建一个自动化工作流或脚本,以赋予模态焦点并与其内容进行交互?

TIA,

BK

【问题讨论】:

    标签: c++ objective-c safari applescript osx-lion


    【解决方案1】:

    尝试使用系统事件:

    tell application "System Events" to tell process "Safari"
        click button "OK" of window 1
    end tell
    
    tell application "System Events" to tell process "Safari"
        set value of text field 1 of window 1 to "aa"
        click button "OK" of window 1
    end tell
    

    【讨论】:

    • Ranta 非常感谢您的快速回复。我看到这应该可行,我只是不知道如何获取模式窗口的名称来定位它。该窗口是一个文件上传窗口,我想设置它的值并提交。 我收到此错误: '错误“系统事件出现错误:无法获取进程 \"Safari\" 的窗口 1 的文本字段 1。无效索引。”进程“Safari”的窗口 1 的文本字段 1 中的数字 -1719'
    • 如果它不是 OS X 窗口而是网站的一部分,请尝试tell application "Safari" to do JavaScript "document.querySelectorAll('#search input')[0].value='aa'" in document 1
    猜你喜欢
    • 1970-01-01
    • 2016-02-29
    • 1970-01-01
    • 1970-01-01
    • 2012-01-19
    • 1970-01-01
    • 1970-01-01
    • 2014-09-29
    • 1970-01-01
    相关资源
    最近更新 更多