Skip to content

Instantly share code, notes, and snippets.

@SarahElson
Created August 12, 2022 14:10
Show Gist options
  • Save SarahElson/01b799117b48b31ec7d699d6d8621144 to your computer and use it in GitHub Desktop.
Save SarahElson/01b799117b48b31ec7d699d6d8621144 to your computer and use it in GitHub Desktop.
test_download_file.py
class TestAPIDownloadFile():
username = "username"
access_Key = "access key"
#POST_REQUEST
url = "https://api.lambdatest.com/automation/api/v1/user-files"
payload={}
files=[
('files',('Lambdainfo.txt',open('/Users/macbookair/Downloads/Lambdainfo.txt','rb'),'text/plain'))
]
headers = {
'authority': 'api.lambdatest.com',
'accept': 'application/json',
}
response = requests.request("POST", url, auth=(username, access_Key), headers=headers, data=payload, files=files)
print(response.text)
#PUT_REQUEST
url = "https://api.lambdatest.com/automation/api/v1/user-files/download"
payload = json.dumps({
"key": "Lambdainfo.txt"
})
headers = {
'accept': 'application/octet-stream',
'Content-Type': 'application/json'
}
response = requests.request("PUT", url, auth=(username, access_Key), headers=headers, data=payload)
open('/Users/macbookair/Documents/how_download_files_selenium_python/download/Lambdainfo.txt', 'wb').write(response.content)
print(response.text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment