我是质量分析师,我正在尝试自动化我们的系统,我遇到了问题,我需要帮助,我使用带有java的webdriver并需要插入图像:
String diretorio = "/img/imagemteste.jpg";
try {
URL resource = getClass().getResource(diretorio);
File file = new File(resource.toURI());
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(idSelecionarImagem))).sendKeys(file.getPath());
它位于文件夹资源中并且由selenium"未找到图像",系统应该打开图像,但只通知图像名称,我不知道如何找到图片。
答案 0 :(得分:0)
这是一个已知问题。对于文件上载,您需要使用绝对路径。这应该有效:
wait.until(ExpectedConditions.visibilityOfElementLocated(By.id(idSelecionarImagem))).sendKeys(file.getAbsolutePath());