Skip to content

Commit a5cfc4a

Browse files
committed
initial commit
0 parents  commit a5cfc4a

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

README.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# How to upload file on [LambdaTest](https://www.lambdatest.com/?utm_source=github&utm_medium=repo&utm_campaign=Python-selenium-upload-file) for automation test in Python-selenium
2+
3+
If you want to upload a file to the LambdaTest and use it in your Python-selenium automation test, you can follow the below steps. You can refer to sample test repo [here](https://github.com/LambdaTest/python-selenium-sample).
4+
5+
# Steps:
6+
7+
### Step 1: Upload the file to LamdbaTest using API
8+
9+
Use the LambdaTest file upload API to upload the file to the backend -https://api.lambdatest.com/automation/api/v1/user-files
10+
11+
12+
### Step 2: Pass file in capabilities
13+
14+
In the test file, you need to update the test capabilities and add the filename for the `lambda:userFiles` capability. For example, if two files with filenames `photo1.png` and `photo2.png`, it has to be passed like so in the capability:
15+
16+
17+
```python
18+
desired_caps = {
19+
'LT:Options': {
20+
"build": "Python Demo", # Change your build name here
21+
"name": "Python Demo Test", # Change your test name here
22+
"platformName": "Windows 11",
23+
"selenium_version": "4.0.0",
24+
"lambda:userFiles": ["photo1.png","photo2.png"]
25+
},
26+
"browserName": "Chrome",
27+
"browserVersion": "98.0",
28+
}
29+
30+
```
31+
32+
### Step 3: Use the file in your test
33+
34+
The files can be used in your test like so:
35+
36+
* For Windows:
37+
```python
38+
elm = driver.find_element_by_xpath("//input[@type='file']")
39+
elm.send_keys("C:\\Users\\ltuser\\Downloads\\photo1.png")
40+
```
41+
* For MacOS:
42+
```python
43+
elm = driver.find_element_by_xpath("//input[@type='file']")
44+
elm.send_keys("/Users/ltuser/Downloads/photo1.png")
45+
```
46+
### Step 4: Run your test
47+
48+
```bash
49+
python lambdatest_test.py
50+
```# Links:
51+
52+
[LambdaTest Community](http://community.lambdatest.com/)

0 commit comments

Comments
 (0)