2
Can someone help me to upload a file using Selenium using Java code?
I made the code below:
firefoxDriver.findElement(By.xpath("//a[@ng-model='picFile']"));
aP.selecionarArquivo(dir+"C:\\Users\\Imagens\\tela.jpg");
public void selecionarArquivo(String path) throws InterruptedException
{
WebElement fileInput = firefoxDriver.findElement(By.xpath("//input[@type='file']"));
fileInput.sendKeys(path);
}
It shows no error, but does not attach the file. It even fills the file name field as if it had attached, but does not enable(The button is only enabled when attaching a file) the Confirm button.
I found my problem. It was the file path that was wrong. I thought that when putting a wrong path presented some error message.
– Gustavo do Nascimento