3

嗨,我正在使用机器人框架。

我正在尝试发送获取请求,但收到以下警告

C:\Python27\lib\site-packages\urllib3-1.21.1-py2.7.egg\urllib3\connectionpool.py:852:InsecureRequestWarning:正在发出未经验证的 HTTPS 请求。强烈建议添加证书验证。请参阅:https: //urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecureRequestWarning)

有人遇到过这个问题吗?当我寻找解决方案时,其中一个建议是禁用警告,但该怎么做呢?

提前致谢,

4

2 回答 2

4

以下测试用例运行完美,没有显示警告。请注意关键字verify=true上的选项。Create Session

*** Settings ***
Library           Collections
Library           String
Library           RequestsLibrary
Library           OperatingSystem

*** Test Cases ***
Get Requests
    [Tags]    get
    Create Session    google    http://www.google.com    verify=true
    Create Session    github    https://api.github.com    verify=true
    ${resp}=    Get Request    google    /    timeout=5
    Should Be Equal As Strings    ${resp.status_code}    200
    ${resp}=    Get Request    github    /users/bulkan    timeout=5
    Should Be Equal As Strings    ${resp.status_code}    200
    Dictionary Should Contain Value    ${resp.json()}    Bulkan Evcimen
于 2017-07-20T18:56:45.557 回答
0

与 一起创建会话verify=true,默认情况下它是verify=false

Create Session test_session http://www.example.com **verify=true**

于 2019-10-07T07:12:59.283 回答