【问题标题】:Start a chrome instance with CORS using Robot Framework使用 Robot Framework 使用 CORS 启动 chrome 实例
【发布时间】:2016-12-26 14:50:23
【问题描述】:

我是 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.

任何帮助将不胜感激。

谢谢

【问题讨论】:

    标签: selenium robotframework


    【解决方案1】:

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

    您启动 Chrome 以运行测试的方式不正确。在 StackOverflow 上,关于 Chrome 的类似问题有一个fine example,说明如何使用特定设置启动 Chrome。例如代理。

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

        *** Settings ***
    Library         Selenium2Library
    
    *** Test Cases ***
    Stackoverflow
        ${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。

    【讨论】:

      猜你喜欢
      • 2017-08-04
      • 2020-11-12
      • 2016-01-13
      • 2017-08-08
      • 2018-10-03
      • 2012-11-01
      • 2017-10-12
      • 2015-08-14
      • 1970-01-01
      相关资源
      最近更新 更多