Is there a sample code I can refer to for uploading files on LambdaTest desktop browser automation test sessions?

Is there a sample code I can refer to for uploading files on LambdaTest desktop browser automation test sessions?

Hello Tom-dale,

Yes, kindly refer to the below code.

 public static RemoteWebDriver driver;
    public static String uname = System.getenv("LT_USERNAME");
    public static String akey = System.getenv("LT_ACCESS_KEY");
    public static String[] a= {"lambda_error_UL.csv"};
    public static void main(String[] args) {

        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability("build", "File Upload");
        capabilities.setCapability("name", "Test 2");
        capabilities.setCapability("platformName", "MacOS Monterey");
        capabilities.setCapability("browserName", "Chrome");
        capabilities.setCapability("browserVersion", "latest");
        capabilities.setCapability("resolution", "1920x1080");
        capabilities.setCapability("lambda:userFiles", a);
        driver = new RemoteWebDriver(new URL("https://"+ uname+":"+akey+""+"@hub.lambdatest.com/wd/hub"),capabilities);
        driver.get("https://the-internet.herokuapp.com/upload");
        Thread.sleep(5000);
        WebElement addfile = driver.findElementById("file-upload");
        addfile.sendKeys("/Users/ltuser/Downloads/lambda_error_UL.csv");
        Thread.sleep(10000);
        driver.findElementById("file-submit").click();
        Thread.sleep(5000);
        driver.quit();