Loading...
「ツール」は右上に移動しました。
利用したサーバー: natural-voltaic-titanium
15いいね 608回再生

How to Upload a File using Selenium WebDriver II Selenium with Java Automation

In this session you will learn How to handle uploading a file.
In many applications you may be different kinds of upload features which varies from browsers.

To download the project or programs for practice , download from below GitHub Repository
github.com/knowledgeshare-technologies/SeleniumBas…

To see the list of sessions step by step , check below playlist
   • How to handle Authentication Popups on a w...  

To join Facebook Group and get more updates join by using below link
www.facebook.com/groups/4754296501308288
------------------------------------------
Overview on File Upload and Download
==========================

What is File Upload/Download

Uploading a File in to a webpage
Download a File from a webpage
Example :
(Upload) Profile Photo upload on any web page
(Download) any file from webpage

Note : File Download is varies from different browser to browser, and also depends on Operating Systems and Operating System versions itself

Different Methods to Upload / Download

Simple SendKeys to upload
Robot
Auto IT


*************************************
Program for File Upload
*************************************
package com.seleniumbasics;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class FileUpload_Example
{
public static void main(String args[])
{
System.setProperty("webdriver.chrome.driver", ".\\drivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.navigate().to("the-internet.herokuapp.com/upload");

WebElement upload_button = driver.findElement(By.xpath("//input[@id='file-upload']"));
upload_button.sendKeys("C:\\Users\\SAM\\Documents\\Files\\test.txt");

driver.findElement(By.xpath("//input[@id='file-submit']")).click();

if (driver.findElement(By.xpath("//*[text()='File Uploaded!']")).isDisplayed())
{
System.out.println("File upload is successfull");
}

else
{
System.out.println("File upload is not successfull");
}
}
}

コメント