【问题标题】:How to mimic export CSV functionality via Python code (where如何通过 Python 代码模拟导出 CSV 功能(其中
【发布时间】:2020-07-18 11:44:58
【问题描述】:

当我在 testrail 中使用导出 CSV 功能时,我看到它向以下 API 发出 POST 请求:/index.php?/plans/export_csv/:plan_id。

_token: <APIToken>
section_ids: 
section_include: 
columns: tests:id,cases:title,tests:assignedto_id,tests:original_case_id,tests:elapsed,cases:priority_id,tests:run_name,tests:tested_by,tests:tested_on
layout: results
separator_hint: 1
format: excel

连同以下请求标头。

authority: <Authority>
:method: POST
:path: /index.php?/plans/export_csv/:plan_id
:scheme: https
accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
accept-encoding: gzip, deflate, br
accept-language: en-GB,en-US;q=0.9,en;q=0.8
cache-control: max-age=0
content-length: 320
content-type: application/x-www-form-urlencoded
cookie: notificationbar=12345; tr_session=<session_id>; tr_rememberme=<id>
origin: <Origin>
referer: <Referer>
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: same-origin
sec-fetch-user: ?1
upgrade-insecure-requests: 1
user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36

有没有办法让我通过 Python 来模仿这个?

【问题讨论】:

    标签: python request automated-tests testrail


    【解决方案1】:

    你应该看看requests 包。

    Requests 是一个帮助您发出 HTTP1.1 请求的库。

    【讨论】:

    • 我之前使用过请求。 Testrails 是一个棘手的案例,无论我如何发送表单数据,它都不接受它。他们的 Rest API 接口不支持相同的功能。因此试图模仿 UI 的作用
    猜你喜欢
    • 2013-02-16
    • 2012-08-16
    • 1970-01-01
    • 2021-12-19
    • 2013-08-31
    • 2017-09-10
    • 1970-01-01
    • 2011-05-15
    • 2021-09-10
    相关资源
    最近更新 更多