MacOS:如何使用url参数打开本地html文件?

时间:2018-09-21 09:34:29

标签: macos applescript selenium-ide kantu

我想在Mac上启动Kantu网络宏from the command line。本质上,这就像打开带有本地html页面(包含宏代码)的Chrome或Firefox浏览器一样简单。在Windows上一切正常。但是在MacO上,当我使用

mac:~ open 'file:////Users/fabrice/Kantu/demoautofill.html?direct=1&close=1&savelog=demotestlog.txt'

Chrome启动,打开文件URL,但是 '?direct=1&close=1&savelog=demotestlog.txt' GET参数部分丢失。

所以问题是:如何使用GET参数启动本地html文件?

我发现Open a local html file with url params through applescript使用Applescript作为解决方法,但是对于Safari,我需要Chrome。另外,如果可能的话,我想避免使用苹果脚本。

2 个答案:

答案 0 :(得分:1)

尽管您希望避免使用AppleScript,但是如果找不到更合适的替代方法,我在命令行程序osascript中使用它,您可以从终端执行该操作:

osascript <<OSA
    tell application "Google Chrome"
        activate
        if not (window 1 exists) then make new window
        make new tab at the end of tabs of window 1 ¬
        with properties { URL: ¬
            "file:///Users/fabrice/Kantu/demoautofill.html" & ¬
            "?direct=1&close=1&savelog=demotestlog.txt" ¬
        }
    end tell
OSA

如果 Google Chrome 已经是系统的默认浏览器,则:

osascript <<<'open location "file:///Users/fabrice/Kantu/demoautofill.html?direct=1&close=1&savelog=demotestlog.txt"'

答案 1 :(得分:0)

  

请注意,您可以通过bash脚本或函数或通过在终端上添加osascript作为前缀来执行Applescript

好的,谢谢。这行解决了我的问题:

db_1             | 2018-09-21 15:35:12.284 UTC [58] ERROR:  relation "app_planit_location" does not exist at character 153
db_1             | 2018-09-21 15:35:12.284 UTC [58] STATEMENT:  DECLARE 
"_django_curs_140423080417024_3" NO SCROLL CURSOR WITH HOLD FOR SELECT "app_planit_location"."id", "app_planit_location"."Planit_location" FROM "app_planit_location"
db_1             | 2018-09-21 15:35:12.285 UTC [58] ERROR:  cursor "_django_curs_140423080417024_3" does not exist
db_1             | 2018-09-21 15:35:12.285 UTC [58] STATEMENT:  CLOSE "_django_curs_140423080417024_3"

Exception Type: OperationalError at /adddata/
Exception Value: cursor "_django_curs_140244427998976_3" does not exist