Skip to main content
Commonmark migration
Source Link

Uploading files using Webdriver

#Uploading files using Webdriver Note: this answer applies to Selenium 2. Apparently Selenium 3 changed the interface again.

Locally

##Locally IfIf the file is on the same machine or a mapped network drive, this is actually really straightforward: You need to "type" the path to the file into the file upload control. Example:

driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
element.send_keys("C:\myfile.txt")

(Code from This SO answer)

Using RemoteWebDriver

##Using RemoteWebDriver InIn order to enable the transfer of the file from your local machine to the remote machine so it can be uploaded, you need to set what's called a File Detector. Java example:

    driver.setFileDetector(new LocalFileDetector());
    WebElement upload = driver.findElement(By.id("myfile"));
    upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");

(Code from, and more information located at, Sauce Labs)

#Uploading files using Webdriver Note: this answer applies to Selenium 2. Apparently Selenium 3 changed the interface again.

##Locally If the file is on the same machine or a mapped network drive, this is actually really straightforward: You need to "type" the path to the file into the file upload control. Example:

driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
element.send_keys("C:\myfile.txt")

(Code from This SO answer)

##Using RemoteWebDriver In order to enable the transfer of the file from your local machine to the remote machine so it can be uploaded, you need to set what's called a File Detector. Java example:

    driver.setFileDetector(new LocalFileDetector());
    WebElement upload = driver.findElement(By.id("myfile"));
    upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");

(Code from, and more information located at, Sauce Labs)

Uploading files using Webdriver

Note: this answer applies to Selenium 2. Apparently Selenium 3 changed the interface again.

Locally

If the file is on the same machine or a mapped network drive, this is actually really straightforward: You need to "type" the path to the file into the file upload control. Example:

driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
element.send_keys("C:\myfile.txt")

(Code from This SO answer)

Using RemoteWebDriver

In order to enable the transfer of the file from your local machine to the remote machine so it can be uploaded, you need to set what's called a File Detector. Java example:

    driver.setFileDetector(new LocalFileDetector());
    WebElement upload = driver.findElement(By.id("myfile"));
    upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");

(Code from, and more information located at, Sauce Labs)

replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

#Uploading files using Webdriver Note: this answer applies to Selenium 2. Apparently Selenium 3 changed the interface again.

##Locally If the file is on the same machine or a mapped network drive, this is actually really straightforward: You need to "type" the path to the file into the file upload control. Example:

driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
element.send_keys("C:\myfile.txt")

(Code from This SO answerThis SO answer)

##Using RemoteWebDriver In order to enable the transfer of the file from your local machine to the remote machine so it can be uploaded, you need to set what's called a File Detector. Java example:

    driver.setFileDetector(new LocalFileDetector());
    WebElement upload = driver.findElement(By.id("myfile"));
    upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");

(Code from, and more information located at, Sauce Labs)

#Uploading files using Webdriver Note: this answer applies to Selenium 2. Apparently Selenium 3 changed the interface again.

##Locally If the file is on the same machine or a mapped network drive, this is actually really straightforward: You need to "type" the path to the file into the file upload control. Example:

driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
element.send_keys("C:\myfile.txt")

(Code from This SO answer)

##Using RemoteWebDriver In order to enable the transfer of the file from your local machine to the remote machine so it can be uploaded, you need to set what's called a File Detector. Java example:

    driver.setFileDetector(new LocalFileDetector());
    WebElement upload = driver.findElement(By.id("myfile"));
    upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");

(Code from, and more information located at, Sauce Labs)

#Uploading files using Webdriver Note: this answer applies to Selenium 2. Apparently Selenium 3 changed the interface again.

##Locally If the file is on the same machine or a mapped network drive, this is actually really straightforward: You need to "type" the path to the file into the file upload control. Example:

driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
element.send_keys("C:\myfile.txt")

(Code from This SO answer)

##Using RemoteWebDriver In order to enable the transfer of the file from your local machine to the remote machine so it can be uploaded, you need to set what's called a File Detector. Java example:

    driver.setFileDetector(new LocalFileDetector());
    WebElement upload = driver.findElement(By.id("myfile"));
    upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");

(Code from, and more information located at, Sauce Labs)

added 95 characters in body
Source Link
Yamikuronue
  • 3.4k
  • 4
  • 22
  • 45

#Uploading files using Webdriver Note: this answer applies to Selenium 2. Apparently Selenium 3 changed the interface again.

##Locally If the file is on the same machine or a mapped network drive, this is actually really straightforward: You need to "type" the path to the file into the file upload control. Example:

driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
element.send_keys("C:\myfile.txt")

(Code from This SO answer)

##Using RemoteWebDriver In order to enable the transfer of the file from your local machine to the remote machine so it can be uploaded, you need to set what's called a File Detector. Java example:

    driver.setFileDetector(new LocalFileDetector());
    WebElement upload = driver.findElement(By.id("myfile"));
    upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");

(Code from, and more information located at, Sauce Labs)

#Uploading files using Webdriver

##Locally If the file is on the same machine or a mapped network drive, this is actually really straightforward: You need to "type" the path to the file into the file upload control. Example:

driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
element.send_keys("C:\myfile.txt")

(Code from This SO answer)

##Using RemoteWebDriver In order to enable the transfer of the file from your local machine to the remote machine so it can be uploaded, you need to set what's called a File Detector. Java example:

    driver.setFileDetector(new LocalFileDetector());
    WebElement upload = driver.findElement(By.id("myfile"));
    upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");

(Code from, and more information located at, Sauce Labs)

#Uploading files using Webdriver Note: this answer applies to Selenium 2. Apparently Selenium 3 changed the interface again.

##Locally If the file is on the same machine or a mapped network drive, this is actually really straightforward: You need to "type" the path to the file into the file upload control. Example:

driver = webdriver.Firefox()
element = driver.find_element_by_id("fileUpload")
element.send_keys("C:\myfile.txt")

(Code from This SO answer)

##Using RemoteWebDriver In order to enable the transfer of the file from your local machine to the remote machine so it can be uploaded, you need to set what's called a File Detector. Java example:

    driver.setFileDetector(new LocalFileDetector());
    WebElement upload = driver.findElement(By.id("myfile"));
    upload.sendKeys("/Users/sso/the/local/path/to/darkbulb.jpg");

(Code from, and more information located at, Sauce Labs)

Source Link
Yamikuronue
  • 3.4k
  • 4
  • 22
  • 45
Loading