ReactJS dropzone upload file via webdriver
Basically, two steps:
- find the element:
- send the key with the location of the file you want to upload.
JavaScript:
const {Builder, By, Key, until} = require('selenium-webdriver');let driver = new Builder() .forBrowser('chrome') .build();driver.get('http://reactdropzone.azurewebsites.net/example/');driver.findElement(By.xpath('.//input[@type="file"]')).sendKeys('full_path_to_your_file.png');
Python:
from selenium import webdriverdriver = webdriver.Chrome()driver.get('http://reactdropzone.azurewebsites.net/example/')input_field = driver.find_element_by_xpath('.//input[@type="file"]')input_field.send_keys('full_path_to_your_file.png')
So, I've found easy way to upload image in react dropzone.React creates hiden inputs in DOM (Body > input)And after that I just use selenium sendKeys("pathToImg")