File Input

Use an absolute path with Selenium's sendKeys.

How to test
driver.findElement(By.id("element_file")).sendKeys("C:\\path\\to\\file.txt");
# Python similar: send_keys('C:/path/to/file.txt')

// Java - Full Test
WebElement fileInput = driver.findElement(By.id("element_file"));
fileInput.sendKeys("C:\\path\\to\\file.txt");
assert fileInput.getAttribute("value").contains("file.txt");

# Python - Full Test
file_input = driver.find_element(By.ID, "element_file")
file_input.send_keys("C:/path/to/file.txt")
assert "file.txt" in file_input.get_attribute("value")

// Java - Alternative Solution
driver.findElement(By.id("element_file")).sendKeys("C:\\path\\to\\file.txt");

# Python - Alternative Solution
driver.find_element(By.ID, "element_file").send_keys("C:/path/to/file.txt")


Tester Task
  1. Locate the file input using id element_file.
  2. Upload a file using an absolute path.
  3. Read the file input value.
  4. Verify the selected value contains the uploaded file name.