Git Product home page Git Product logo

saksham2541996 / pytest-upload-file Goto Github PK

View Code? Open in Web Editor NEW

This project forked from riadayal/pytest-upload-file

0.0 0.0 0.0 0 B

A sample repo to help you upload files on LambdaTest for automation tests in Pytest. Run your automated scripts in Pytest on LambdaTest.

Home Page: https://www.lambdatest.com/pytest-testing/?utm_source=github&utm_medium=about&utm_campaign=pytest_upload_file

pytest-upload-file's Introduction

How to upload file on LambdaTest for automation test in Pytest

If you want to upload a file to the LambdaTest and use it in your Pytest 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 conftest.py 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:

capabilities = {
        "build": "Sample PY Build",
        "platformName": "Windows 11",
        "browserName": "Chrome",
        "browserVersion": "latest",
		"lambda:userFiles": ["photo1.png","photo2.png"]
}

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

cd tests //navigate to tests directory
python sample_todo.py

Links:

LambdaTest Community

pytest-upload-file's People

Contributors

riadayal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.