May 6, 2022
How to upload a file in remote webdriver.
In this example, let’s look at the possibility of attaching an image to JIRA.
Code is as per below-
import org.openqa.selenium.remote.LocalFileDetector;
import org.openqa.selenium.remote.RemoteWebDriver;
((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector());
String filePath = System.getProperty("user.dir") + "/src/Attachments/SnowAttachment.png";
WebElement element = findElements(By.xpath("//element[@attribute='value']"));
element.sendKeys(inputText);