使用 Robot Framework 通过 CORS 启动一个 chrome 实例

Start a chrome instance with CORS using Robot Framework

我是 Robot Framework 的新手,但想问一下是否可以在启用 CORS 的情况下启动 Chrome 实例?

Run process  open -n -a /Applications/Google\ Chrome.app/ --args  --user-data-dir=/tmp/chrome_dev_session  --disable-web-security  --allow-running-insecure-content  --new-window

我已经尝试了上面的方法,但不幸的是在 运行

时出现错误

Keyword 'Process.Run Process' got positional argument after named arguments.

我也试过参数之间没有双倍间距

Run process open -n -a /Applications/Google\ Chrome.app/ --args --user-data-dir=/tmp/chrome_dev_session --disable-web-security --allow-running-insecure-content --new-window

但是出现如下错误

Keyword 'Process.Run Process' expected at least 1 non-keyword argument, got 0.

如有任何帮助,我们将不胜感激。

谢谢

由于我没有测试来验证您的用例,所以我将分享一些简短调查的结果。

您开始 Chrome 到 运行 测试的方式不正确。在 Whosebug 上,关于 Chrome 的类似问题包含 fine example 如何使用特定设置集启动 Chrome。例如代理。

使用该机制应该可以像这样设置您的特定参数:

    *** Settings ***
Library         Selenium2Library

*** Test Cases ***
Whosebug
    ${options}=  Evaluate  sys.modules['selenium.webdriver'].ChromeOptions()  sys, selenium.webdriver
    Call Method    ${options}    add_argument      disable-web-security
    Call Method    ${options}    add_argument      allow-running-insecure-content
    Call Method    ${options}    add_argument      user-data-dir=/tmp/chrome_dev_session
    Create WebDriver  Chrome    chrome_options=${options}
    Go To    https://www.java.com/verify
    Close All Browsers

这应该允许您使用执行本地测试所需的特定设置开始Chrome。