Skip to content

Elmasekar/UnitTest-upload-file

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

How to upload file on LambdaTest for automation test in UnitTest

If you want to upload a file to the LambdaTest and use it in your UnitTest automation test, you can follow the below steps. You can refer to sample test repo here.

Steps:

Step 1: Upload the file to LamdbaTest using API

Use the LambdaTest file upload API to upload the file to the backend -https://api.lambdatest.com/automation/api/v1/user-files

Step 2: Pass file in capabilities

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:

desired_caps = {
            'LT:Options': {
                "build": "Python Demo",  # Change your build name here
                "name": "Python Demo Test",  # Change your test name here
                "platformName": "Windows 11",
                "selenium_version": "4.0.0",
                "lambda:userFiles": ["photo1.png","photo2.png"]
            },
            "browserName": "Chrome",
            "browserVersion": "98.0",
        }

Step 3: Use the file in your test

The files can be used in your test like so:

  • For Windows:
elm = driver.find_element_by_xpath("//input[@type='file']")
elm.send_keys("C:\\Users\\ltuser\\Downloads\\photo1.png")
  • For MacOS:
elm = driver.find_element_by_xpath("//input[@type='file']")
elm.send_keys("/Users/ltuser/Downloads/photo1.png")

Step 4: Run your test

python lambdatest_test.py
```# Links:

[LambdaTest Community](http://community.lambdatest.com/)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy